From b8966986df5b6d1dab95965ce0d35498c725b59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Mon, 15 Jan 2018 20:52:23 +0100 Subject: [PATCH 1/4] add few tests for factorial including edge cases --- test/factorial/factorial.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/factorial/factorial.test.js b/test/factorial/factorial.test.js index 6b67865ea..6eb4467ff 100644 --- a/test/factorial/factorial.test.js +++ b/test/factorial/factorial.test.js @@ -5,7 +5,11 @@ test('Testing factorial', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof factorial === 'function', 'factorial is a Function'); - // t.equal(factorial(6), 720, "Calculates the factorial of a number"); DOESN'T WORK + t.equal(factorial(6), 720, "Calculates the factorial of 720"); + t.equal(factorial(0), 1, "Calculates the factorial of 0"); + t.equal(factorial(1), 1, "Calculates the factorial of 1"); + t.equal(factorial(4), 24, "Calculates the factorial of 4"); + t.equal(factorial(10), 3628800, "Calculates the factorial of 10"); //t.deepEqual(factorial(args..), 'Expected'); //t.equal(factorial(args..), 'Expected'); //t.false(factorial(args..), 'Expected'); From b2ed45a3340449686ff64aa5980811e30938f132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Mon, 15 Jan 2018 20:53:27 +0100 Subject: [PATCH 2/4] add 2 tests for curry --- test/curry/curry.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/curry/curry.test.js b/test/curry/curry.test.js index 1271e74ff..a8014b100 100644 --- a/test/curry/curry.test.js +++ b/test/curry/curry.test.js @@ -5,8 +5,8 @@ test('Testing curry', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof curry === 'function', 'curry is a Function'); - //BROKEN - // t.equal(curry(Math.pow)(2)(10), 1024, "Curries a function"); + t.equal(curry(Math.pow)(2)(10), 1024, "curries a Math.pow"); + t.equal(curry(Math.min, 3)(10)(50)(2), 2, "curries a Math.min"); //t.deepEqual(curry(args..), 'Expected'); //t.equal(curry(args..), 'Expected'); //t.false(curry(args..), 'Expected'); From f214d7c1c4d7f4000d094b524e8631b3de0c9e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Mon, 15 Jan 2018 20:54:38 +0100 Subject: [PATCH 3/4] add 4 tests for elo snippet --- test/elo/elo.test.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/elo/elo.test.js b/test/elo/elo.test.js index a86587170..b425f7fb1 100644 --- a/test/elo/elo.test.js +++ b/test/elo/elo.test.js @@ -4,11 +4,10 @@ const elo = require('./elo.js'); test('Testing elo', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape - // BORKEN - // t.true(typeof elo === 'function', 'elo is a Function'); - // t.deepEqual(elo([1200, 1200]), [1216, 1184], "Standard 1v1s"); - // t.deepEqual(elo([1200, 1200], 64), [1232, 1168]), "Standard 1v1s"; - // t.deepEqual(elo([1200, 1200, 1200, 1200]).map(Math.round), [1246, 1215, 1185, 1154], "4 player FFA, all same rank"); + t.true(typeof elo === 'function', 'elo is a Function'); + t.deepEqual(elo([1200, 1200]), [1216, 1184], "Standard 1v1s"); + t.deepEqual(elo([1200, 1200], 64), [1232, 1168]), "Standard 1v1s"; + t.deepEqual(elo([1200, 1200, 1200, 1200]).map(Math.round), [1246, 1215, 1185, 1154], "4 player FFA, all same rank"); //t.deepEqual(elo(args..), 'Expected'); //t.equal(elo(args..), 'Expected'); //t.false(elo(args..), 'Expected'); From 31c9437946239e16c361ab4bc06925d1d5e87372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Mon, 15 Jan 2018 21:03:32 +0100 Subject: [PATCH 4/4] add test for cleanObj --- test/cleanObj/cleanObj.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cleanObj/cleanObj.test.js b/test/cleanObj/cleanObj.test.js index 47e035791..8869354da 100644 --- a/test/cleanObj/cleanObj.test.js +++ b/test/cleanObj/cleanObj.test.js @@ -5,6 +5,8 @@ test('Testing cleanObj', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof cleanObj === 'function', 'cleanObj is a Function'); + const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } }; + t.deepEqual(cleanObj(testObj, ['a'], 'children'), { a: 1, children : { a: 1}}, "Removes any properties except the ones specified from a JSON object"); //t.deepEqual(cleanObj(args..), 'Expected'); //t.equal(cleanObj(args..), 'Expected'); //t.false(cleanObj(args..), 'Expected');