From f1a34b4925f4779d13be075dfe0d883c8a8e1404 Mon Sep 17 00:00:00 2001 From: hamzaelkhatri Date: Mon, 9 Oct 2023 12:21:08 +0100 Subject: [PATCH] test:add test for add exercise --- js/tests/add_test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 js/tests/add_test.js diff --git a/js/tests/add_test.js b/js/tests/add_test.js new file mode 100644 index 000000000..b6b8ecda0 --- /dev/null +++ b/js/tests/add_test.js @@ -0,0 +1,19 @@ +export const tests = [] +const t = (f) => tests.push(f) + + +// add is declared and is a function and take 2 arguments +t(() => typeof Add === 'function') +t(() => Add.length === 2) + +// add works with positive numbers +t(() => Add(5, 6) === 11) + +// Add works with negative numbers +t(() => Add(-5, -6) === -11) + +// Add works with mixed numbers +t(() => Add(-5, 6) === 1) + +// Add works with zero +t(() => Add(0, 0) === 0)