From 92639e6a702c01a1019fdf1bc5fed377e352af0d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 31 May 2025 09:39:42 +0100 Subject: Add tests for promises.props() --- test/promises.tests.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) 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 + }); + }); + } +}); -- cgit v1.2.3