feat(js-checkpoint):add test for more exercise

This commit is contained in:
root 2023-10-02 15:25:35 +01:00
parent e7054b5077
commit 012be53557
1 changed files with 19 additions and 0 deletions

19
js/tests/more_test.js Normal file
View File

@ -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)