aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-05-31 09:39:42 +0100
committerMichael Williamson <mike@zwobble.org>2026-09-16 23:38:01 +0100
commit92639e6a702c01a1019fdf1bc5fed377e352af0d (patch)
treef77497a285fd6c01be78dba8a3fc6d23406ea007
parentef510294e64ac5c40a5155567ec9e7d5e328293c (diff)
Add tests for promises.props()
-rw-r--r--test/promises.tests.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/promises.tests.js b/test/promises.tests.js
index 3dd24be..f54245b 100644
--- a/test/promises.tests.js
+++ b/test/promises.tests.js
@@ -46,3 +46,54 @@ test("try", {
);
}
});
+
+test("props", {
+ "props({}) resolve to {}": function() {
+ return promises.props({}).then(function(result) {
+ assert.deepStrictEqual(result, {});
+ });
+ },
+
+ "when object has promise values then props returns with all values resolved": function() {
+ return promises.props({
+ a: promises.resolve(1),
+ b: promises.resolve(2),
+ c: promises.resolve(3)
+ }).then(function(result) {
+ assert.deepStrictEqual(result, {
+ a: 1,
+ b: 2,
+ c: 3
+ });
+ });
+ },
+
+ "when object has non-promise values then props returns with same values": function() {
+ return promises.props({
+ a: 1,
+ b: 2,
+ c: 3
+ }).then(function(result) {
+ assert.deepStrictEqual(result, {
+ a: 1,
+ b: 2,
+ c: 3
+ });
+ });
+ },
+
+ "props(...).also(...) can be used to add props": function() {
+ return promises.props({
+ a: promises.resolve(1)
+ }).also(function(result) {
+ return {
+ b: result.a + 1
+ };
+ }).then(function(result) {
+ assert.deepStrictEqual(result, {
+ a: 1,
+ b: 2
+ });
+ });
+ }
+});