From da70ff6e9ca48a008678c4838e97664b3b73de41 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar Date: Thu, 8 Feb 2018 20:28:01 +0530 Subject: [PATCH 1/5] test for randomNumberInRange --- test/randomNumberInRange/randomNumberInRange.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/randomNumberInRange/randomNumberInRange.test.js b/test/randomNumberInRange/randomNumberInRange.test.js index 2d3d46bde..0461ae4a9 100644 --- a/test/randomNumberInRange/randomNumberInRange.test.js +++ b/test/randomNumberInRange/randomNumberInRange.test.js @@ -5,6 +5,10 @@ test('Testing randomNumberInRange', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof randomNumberInRange === 'function', 'randomNumberInRange is a Function'); + const lowerLimit = Math.floor(Math.random() * 20); + const upperLimit = Math.floor(lowerLimit + Math.random() * 10); + const numberForTest = randomNumberInRange(lowerLimit,upperLimit); + t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provied lowerLimit and upperLimit (both inclusive).'); //t.deepEqual(randomNumberInRange(args..), 'Expected'); //t.equal(randomNumberInRange(args..), 'Expected'); //t.false(randomNumberInRange(args..), 'Expected'); From f4cd39d1367fbd3c06f4abb45e593d591e1ff047 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar Date: Thu, 8 Feb 2018 20:38:16 +0530 Subject: [PATCH 2/5] update test for random hexColorCode --- test/randomHexColorCode/randomHexColorCode.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/randomHexColorCode/randomHexColorCode.test.js b/test/randomHexColorCode/randomHexColorCode.test.js index eb2cdba9f..d604bc77e 100644 --- a/test/randomHexColorCode/randomHexColorCode.test.js +++ b/test/randomHexColorCode/randomHexColorCode.test.js @@ -7,6 +7,8 @@ test('Testing randomHexColorCode', (t) => { t.true(typeof randomHexColorCode === 'function', 'randomHexColorCode is a Function'); //t.deepEqual(randomHexColorCode(args..), 'Expected'); t.equal(randomHexColorCode().length, 7); + t.true(randomHexColorCode().startsWith('#'),'The color code starts with "#"'); + t.true(randomHexColorCode().slice(1).match(/[^0123456789abcdef]/i) === null) //t.false(randomHexColorCode(args..), 'Expected'); //t.throws(randomHexColorCode(args..), 'Expected'); t.end(); From b55227f7662bb12debcc9477b4f0f21a603c2f32 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar Date: Sat, 10 Feb 2018 19:59:42 +0530 Subject: [PATCH 3/5] test for randomIntArray --- test/randomIntArrayInRange/randomIntArrayInRange.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/randomIntArrayInRange/randomIntArrayInRange.test.js b/test/randomIntArrayInRange/randomIntArrayInRange.test.js index 9a7735e44..68c977c4a 100644 --- a/test/randomIntArrayInRange/randomIntArrayInRange.test.js +++ b/test/randomIntArrayInRange/randomIntArrayInRange.test.js @@ -5,6 +5,12 @@ test('Testing randomIntArrayInRange', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof randomIntArrayInRange === 'function', 'randomIntArrayInRange is a Function'); + const lowerLimit = Math.floor(Math.random() * 20); + const upperLimit = Math.floor(lowerLimit + Math.random() * 10); + const randLength = Math.floor(Math.random() * 10) + t.true(randomIntArrayInRange(lowerLimit,upperLimit).length === 1,'The default value of returned array is 1'); + t.true(randomIntArrayInRange(lowerLimit,upperLimit,randLength).length === randLength,'The length of returned array is the same as the provided value.') + t.true(randomIntArrayInRange(lowerLimit,upperLimit,randLength).filter(el => !((el>=lowerLimit) && (el <= upperLimit))).length === 0,'The returned values is in range.') //t.deepEqual(randomIntArrayInRange(args..), 'Expected'); //t.equal(randomIntArrayInRange(args..), 'Expected'); //t.false(randomIntArrayInRange(args..), 'Expected'); From 0776ed5c4d74a3a71bc460df76a38e5b055dd8f8 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar Date: Fri, 16 Feb 2018 14:10:55 +0530 Subject: [PATCH 4/5] fix typo in average test --- test/average/average.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/average/average.test.js b/test/average/average.test.js index dff7df5a7..16a9471c7 100644 --- a/test/average/average.test.js +++ b/test/average/average.test.js @@ -19,6 +19,6 @@ test('Testing average', (t) => { let start = new Date().getTime(); average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631); let end = new Date().getTime(); - t.true((end - start) < 2000, 'head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run'); + t.true((end - start) < 2000, 'average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run'); t.end(); }); \ No newline at end of file From 77031a7e576dd6874b65a8cfe2fe0ea53ac91df0 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Fri, 16 Feb 2018 14:23:11 +0530 Subject: [PATCH 5/5] Update randomHexColorCode.js Add missing semicolon --- test/randomHexColorCode/randomHexColorCode.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/randomHexColorCode/randomHexColorCode.test.js b/test/randomHexColorCode/randomHexColorCode.test.js index d604bc77e..7d9946955 100644 --- a/test/randomHexColorCode/randomHexColorCode.test.js +++ b/test/randomHexColorCode/randomHexColorCode.test.js @@ -8,8 +8,8 @@ test('Testing randomHexColorCode', (t) => { //t.deepEqual(randomHexColorCode(args..), 'Expected'); t.equal(randomHexColorCode().length, 7); t.true(randomHexColorCode().startsWith('#'),'The color code starts with "#"'); - t.true(randomHexColorCode().slice(1).match(/[^0123456789abcdef]/i) === null) + t.true(randomHexColorCode().slice(1).match(/[^0123456789abcdef]/i) === null,'The color code contains only valid hex-digits'); //t.false(randomHexColorCode(args..), 'Expected'); //t.throws(randomHexColorCode(args..), 'Expected'); t.end(); -}); \ No newline at end of file +});