From 012be53557e0500011413e4fe05bcf6e8d3fdcb2 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Oct 2023 15:25:35 +0100 Subject: [PATCH] feat(js-checkpoint):add test for more exercise --- js/tests/more_test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 js/tests/more_test.js diff --git a/js/tests/more_test.js b/js/tests/more_test.js new file mode 100644 index 000000000..c88a9c19c --- /dev/null +++ b/js/tests/more_test.js @@ -0,0 +1,19 @@ +export const tests = [] +const t = (f) => tests.push(f) + +// more is declared and is a function and take 1 argument +t(() => typeof more === 'function') +t(() => more.length === 1) + +// more works with positive numbers +t(() => more(5) === 6) +t(() => more(more(more(5))) === 8) + +// more works with negative numbers +t(() => more(-5) === -4) +t(() => more(more(more(-5))) === -2) + +const rand = Math.random() +t(() => more(rand) === rand + 1) + +Object.freeze(tests) \ No newline at end of file