From 7553d3d9941119a248e4b00609b647696b3e352d Mon Sep 17 00:00:00 2001 From: nprimo Date: Wed, 8 Mar 2023 15:42:29 +0000 Subject: [PATCH] feat(kept-promise): add test --- js/tests/kept-promise_test.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/js/tests/kept-promise_test.js b/js/tests/kept-promise_test.js index dd35de170..e752c87ec 100644 --- a/js/tests/kept-promise_test.js +++ b/js/tests/kept-promise_test.js @@ -1,6 +1,19 @@ -import keptPromise +export const tests = [] -const getImportantInfo = _ => - new Promise(resolve => { - setTimeout(_ => resolve(Math.round(Math.random() * 10)), 1000) - }) +const testZero = async _ => { + return (await processInfo(_ => new Promise(resolve => resolve(0)))) === 'Ok!' +} + +const testOddNumber = async _ => { + return ( + (await processInfo(_ => new Promise(resolve => resolve(1)))) === 'Error!' + ) +} + +const testEvenNumber = async _ => { + return (await processInfo(_ => new Promise(resolve => resolve(4)))) === 'Ok!' +} + +tests.push(testZero, testOddNumber, testEvenNumber) + +Object.freeze(tests)