From 185fef6ec28fc2db81ffdd154f3e199680a74f2a Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 3 Feb 2018 12:18:04 +0200 Subject: [PATCH] Tests for takeWhile, takeRightWhile, times --- test/takeRightWhile/takeRightWhile.test.js | 3 ++- test/takeWhile/takeWhile.test.js | 3 ++- test/testlog | 9 ++++++--- test/times/times.test.js | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/test/takeRightWhile/takeRightWhile.test.js b/test/takeRightWhile/takeRightWhile.test.js index bfe8ab71e..c841d410d 100644 --- a/test/takeRightWhile/takeRightWhile.test.js +++ b/test/takeRightWhile/takeRightWhile.test.js @@ -5,9 +5,10 @@ test('Testing takeRightWhile', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof takeRightWhile === 'function', 'takeRightWhile is a Function'); + t.deepEqual(takeRightWhile([1, 2, 3, 4], n => n < 3), [3, 4], 'Removes elements until the function returns true'); //t.deepEqual(takeRightWhile(args..), 'Expected'); //t.equal(takeRightWhile(args..), 'Expected'); //t.false(takeRightWhile(args..), 'Expected'); //t.throws(takeRightWhile(args..), 'Expected'); t.end(); -}); \ No newline at end of file +}); diff --git a/test/takeWhile/takeWhile.test.js b/test/takeWhile/takeWhile.test.js index 0cd167bf4..09f5d5cb7 100644 --- a/test/takeWhile/takeWhile.test.js +++ b/test/takeWhile/takeWhile.test.js @@ -5,9 +5,10 @@ test('Testing takeWhile', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof takeWhile === 'function', 'takeWhile is a Function'); + t.deepEqual(takeWhile([1, 2, 3, 4], n => n >= 3), [1, 2], 'Removes elements until the function returns true'); //t.deepEqual(takeWhile(args..), 'Expected'); //t.equal(takeWhile(args..), 'Expected'); //t.false(takeWhile(args..), 'Expected'); //t.throws(takeWhile(args..), 'Expected'); t.end(); -}); \ No newline at end of file +}); diff --git a/test/testlog b/test/testlog index 8361aebe6..04671bf37 100644 --- a/test/testlog +++ b/test/testlog @@ -1,4 +1,4 @@ -Test log for: Sat Feb 03 2018 12:08:59 GMT+0200 (GTB Standard Time) +Test log for: Sat Feb 03 2018 12:17:47 GMT+0200 (GTB Standard Time) > 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code > tape test/**/*.test.js | tap-spec @@ -1346,10 +1346,12 @@ Test log for: Sat Feb 03 2018 12:08:59 GMT+0200 (GTB Standard Time) Testing takeRightWhile √ takeRightWhile is a Function + √ Removes elements until the function returns true Testing takeWhile √ takeWhile is a Function + √ Removes elements until the function returns true Testing throttle @@ -1358,6 +1360,7 @@ Test log for: Sat Feb 03 2018 12:08:59 GMT+0200 (GTB Standard Time) Testing times √ times is a Function + √ Runs a function the specified amount of times Testing timeTaken @@ -1636,8 +1639,8 @@ Test log for: Sat Feb 03 2018 12:08:59 GMT+0200 (GTB Standard Time) √ Works with multiple promises - total: 740 - passing: 740 + total: 743 + passing: 743 duration: 2.4s diff --git a/test/times/times.test.js b/test/times/times.test.js index 4e94c7d20..dcf2d7e28 100644 --- a/test/times/times.test.js +++ b/test/times/times.test.js @@ -5,9 +5,12 @@ test('Testing times', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof times === 'function', 'times is a Function'); + var output = ''; + times(5, i => (output += i)); + t.equals(output, '01234', 'Runs a function the specified amount of times'); //t.deepEqual(times(args..), 'Expected'); //t.equal(times(args..), 'Expected'); //t.false(times(args..), 'Expected'); //t.throws(times(args..), 'Expected'); t.end(); -}); \ No newline at end of file +});