diff --git a/package.json b/package.json index b2a1e4c0f..60601fc5f 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "packager": "node ./scripts/module.js", "localizer": "node ./scripts/localize.js", "test": "tape test/**/*.test.js | tap-spec", - "test2": "jest ./jesttest/**/*.test.js" + "test2": "jest test/**/*.test.js" }, "repository": { "type": "git", diff --git a/test4/JSONToDate/JSONToDate.js b/test/JSONToDate/JSONToDate.js similarity index 100% rename from test4/JSONToDate/JSONToDate.js rename to test/JSONToDate/JSONToDate.js diff --git a/test/JSONToDate/JSONToDate.test.js b/test/JSONToDate/JSONToDate.test.js new file mode 100644 index 000000000..9e271ee0c --- /dev/null +++ b/test/JSONToDate/JSONToDate.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const JSONToDate = require('./JSONToDate.js'); + + + test('JSONToDate is a Function', () => { + expect(JSONToDate).toBeInstanceOf(Function); +}); + diff --git a/test4/JSONToFile/JSONToFile.js b/test/JSONToFile/JSONToFile.js similarity index 100% rename from test4/JSONToFile/JSONToFile.js rename to test/JSONToFile/JSONToFile.js diff --git a/test/JSONToFile/JSONToFile.test.js b/test/JSONToFile/JSONToFile.test.js new file mode 100644 index 000000000..cdec2fda6 --- /dev/null +++ b/test/JSONToFile/JSONToFile.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const JSONToFile = require('./JSONToFile.js'); + + + test('JSONToFile is a Function', () => { + expect(JSONToFile).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test5/RGBToHex/RGBToHex.js b/test/RGBToHex/RGBToHex.js similarity index 100% rename from test5/RGBToHex/RGBToHex.js rename to test/RGBToHex/RGBToHex.js diff --git a/test/RGBToHex/RGBToHex.test.js b/test/RGBToHex/RGBToHex.test.js new file mode 100644 index 000000000..e290b6bb5 --- /dev/null +++ b/test/RGBToHex/RGBToHex.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const RGBToHex = require('./RGBToHex.js'); + + + test('RGBToHex is a Function', () => { + expect(RGBToHex).toBeInstanceOf(Function); +}); + t.equal(RGBToHex(255, 165, 1), 'ffa501', "Converts the values of RGB components to a color code."); + diff --git a/test6/URLJoin/URLJoin.js b/test/URLJoin/URLJoin.js similarity index 86% rename from test6/URLJoin/URLJoin.js rename to test/URLJoin/URLJoin.js index 0125c4ffa..5280f8ac7 100644 --- a/test6/URLJoin/URLJoin.js +++ b/test/URLJoin/URLJoin.js @@ -2,7 +2,7 @@ const URLJoin = (...args) => args .join('/') .replace(/[\/]+/g, '/') -.replace(/^(.+):\//, '$1://') +.replace(/^(.+):\ .replace(/^file:/, 'file:/') .replace(/\/(\?|&|#[^!])/g, '$1') .replace(/\?/g, '&') diff --git a/test/URLJoin/URLJoin.test.js b/test/URLJoin/URLJoin.test.js new file mode 100644 index 000000000..fd51c5c5b --- /dev/null +++ b/test/URLJoin/URLJoin.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const URLJoin = require('./URLJoin.js'); + + + test('URLJoin is a Function', () => { + expect(URLJoin).toBeInstanceOf(Function); +}); + t.equal(URLJoin('http: + t.equal(URLJoin('file: + + diff --git a/test6/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js similarity index 100% rename from test6/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js rename to test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js diff --git a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js new file mode 100644 index 000000000..cf2376860 --- /dev/null +++ b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const UUIDGeneratorBrowser = require('./UUIDGeneratorBrowser.js'); + + + test('UUIDGeneratorBrowser is a Function', () => { + expect(UUIDGeneratorBrowser).toBeInstanceOf(Function); +}); + t.pass('Tested 09/02/2018 by @chalarangelo'); + + diff --git a/test6/UUIDGeneratorNode/UUIDGeneratorNode.js b/test/UUIDGeneratorNode/UUIDGeneratorNode.js similarity index 100% rename from test6/UUIDGeneratorNode/UUIDGeneratorNode.js rename to test/UUIDGeneratorNode/UUIDGeneratorNode.js diff --git a/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js b/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js new file mode 100644 index 000000000..85ebf8b53 --- /dev/null +++ b/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const UUIDGeneratorNode = require('./UUIDGeneratorNode.js'); + + + test('UUIDGeneratorNode is a Function', () => { + expect(UUIDGeneratorNode).toBeInstanceOf(Function); +}); + const uuid = UUIDGeneratorNode(); + t.deepEqual([uuid[8], uuid[13], uuid[18], uuid[23]], ['-', '-', '-', '-'], 'Contains dashes in the proper places'); + test('Only contains hexadecimal digits', () => { + expect(/^[0-9A-Fa-f-]+$/.test(uuid)).toBeTruthy(); +}); + + diff --git a/test/all/all.test.js b/test/all/all.test.js index b3b238577..9c07329df 100644 --- a/test/all/all.test.js +++ b/test/all/all.test.js @@ -1,16 +1,30 @@ const expect = require('expect'); const all = require('./all.js'); -test('Testing all', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof all === 'function').toBeTruthy(); +test('all is a Function', () => { + expect(all).toBeInstanceOf(Function); +}); +test('Returns true for arrays with no falsey values', () => { expect(all([4,1,2,3])).toBeTruthy(); +}); +test('Returns false for arrays with 0', () => { expect(all([0,1])).toBeFalsy(); +}); +test('Returns false for arrays with NaN', () => { expect(all([NaN,1])).toBeFalsy(); +}); +test('Returns false for arrays with undefined', () => { expect(all([undefined,1])).toBeFalsy(); +}); +test('Returns false for arrays with null', () => { expect(all([null,1])).toBeFalsy(); +}); +test('Returns false for arrays with empty strings', () => { expect(all(['',1])).toBeFalsy(); +}); +test('Returns true with predicate function', () => { expect(all([4,1,2,3], x => x >= 1)).toBeTruthy(); +}); +test('Returns false with a predicate function', () => { expect(all([0,1], x => x >= 1)).toBeFalsy(); }); diff --git a/test/any/any.test.js b/test/any/any.test.js index a5ae70981..083545c1e 100644 --- a/test/any/any.test.js +++ b/test/any/any.test.js @@ -1,13 +1,21 @@ const expect = require('expect'); const any = require('./any.js'); -test('Testing any', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof any === 'function').toBeTruthy(); +test('any is a Function', () => { + expect(any).toBeInstanceOf(Function); +}); +test('Returns true for arrays with at least one truthy value', () => { expect(any([0,1,2,3])).toBeTruthy(); +}); +test('Returns false for arrays with no truthy values', () => { expect(any([0,0])).toBeFalsy(); +}); +test('Returns false for arrays with no truthy values', () => { expect(any([NaN,0,undefined,null,''])).toBeFalsy(); +}); +test('Returns true with predicate function', () => { expect(any([4,1,0,3], x => x >= 1)).toBeTruthy(); +}); +test('Returns false with a predicate function', () => { expect(any([0,1], x => x < 0)).toBeFalsy(); }); diff --git a/test/approximatelyEqual/approximatelyEqual.test.js b/test/approximatelyEqual/approximatelyEqual.test.js index 5e223172e..87272be4e 100644 --- a/test/approximatelyEqual/approximatelyEqual.test.js +++ b/test/approximatelyEqual/approximatelyEqual.test.js @@ -1,12 +1,21 @@ const expect = require('expect'); const approximatelyEqual = require('./approximatelyEqual.js'); -test('Testing approximatelyEqual', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof approximatelyEqual === 'function').toBeTruthy(); + + test('approximatelyEqual is a Function', () => { + expect(approximatelyEqual).toBeInstanceOf(Function); +}); + test('Works for PI / 2', () => { expect(approximatelyEqual(Math.PI / 2.0 , 1.5708)).toBeTruthy(); +}); + test('Works for 0.1 + 0.2 === 0.3', () => { expect(approximatelyEqual(0.1 + 0.2, 0.3)).toBeTruthy(); +}); + test('Works for exactly equal values', () => { expect(approximatelyEqual(0.5, 0.5)).toBeTruthy(); +}); + test('Works for a custom epsilon', () => { expect(approximatelyEqual(0.501, 0.5, 0.1)).toBeTruthy(); }); + + diff --git a/test/arrayToHtmlList/arrayToHtmlList.test.js b/test/arrayToHtmlList/arrayToHtmlList.test.js index 005e1a472..33ad61cae 100644 --- a/test/arrayToHtmlList/arrayToHtmlList.test.js +++ b/test/arrayToHtmlList/arrayToHtmlList.test.js @@ -1,8 +1,10 @@ const expect = require('expect'); const arrayToHtmlList = require('./arrayToHtmlList.js'); -test('Testing arrayToHtmlList', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof arrayToHtmlList === 'function').toBeTruthy(); + + test('arrayToHtmlList is a Function', () => { + expect(arrayToHtmlList).toBeInstanceOf(Function); }); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test/ary/ary.test.js b/test/ary/ary.test.js index 66ca2da84..45ada26a6 100644 --- a/test/ary/ary.test.js +++ b/test/ary/ary.test.js @@ -1,10 +1,13 @@ const expect = require('expect'); const ary = require('./ary.js'); -test('Testing ary', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof ary === 'function').toBeTruthy(); - const firstTwoMax = ary(Math.max, 2); - expect([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x))).toEqual([6, 8, 10]); + + test('ary is a Function', () => { + expect(ary).toBeInstanceOf(Function); }); + const firstTwoMax = ary(Math.max, 2); + test('Discards arguments with index >=n', () => { + expect([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)), [6, 8, 10]).toEqual() +}); + + diff --git a/test/atob/atob.test.js b/test/atob/atob.test.js index 1ea997aed..4032a531a 100644 --- a/test/atob/atob.test.js +++ b/test/atob/atob.test.js @@ -1,10 +1,15 @@ const expect = require('expect'); const atob = require('./atob.js'); -test('Testing atob', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof atob === 'function').toBeTruthy(); - expect(atob('Zm9vYmFy')).toBe('foobar'); - expect(atob('Z')).toBe(''); + + test('atob is a Function', () => { + expect(atob).toBeInstanceOf(Function); }); + test('atob("Zm9vYmFy") equals "foobar"', () => { + expect(atob('Zm9vYmFy'), 'foobar').toBe() +}); + test('atob("Z") returns ""', () => { + expect(atob('Z'), '').toBe() +}); + + diff --git a/test/attempt/attempt.test.js b/test/attempt/attempt.test.js index 0e6b0d5b0..1bd0179da 100644 --- a/test/attempt/attempt.test.js +++ b/test/attempt/attempt.test.js @@ -1,10 +1,15 @@ const expect = require('expect'); const attempt = require('./attempt.js'); -test('Testing attempt', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof attempt === 'function').toBeTruthy(); - expect(attempt(() => 0)).toBe(0); + + test('attempt is a Function', () => { + expect(attempt).toBeInstanceOf(Function); +}); + test('Returns a value', () => { + expect(attempt(() => 0), 0).toBe() +}); + test('Returns an error', () => { expect(attempt(() => {throw new Error();}) instanceof Error).toBeTruthy(); }); + + diff --git a/test/average/average.test.js b/test/average/average.test.js index b07cc6380..039daaba6 100644 --- a/test/average/average.test.js +++ b/test/average/average.test.js @@ -1,23 +1,37 @@ const expect = require('expect'); const average = require('./average.js'); -test('Testing average', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof average === 'function').toBeTruthy(); + + test('average is a Function', () => { + expect(average).toBeInstanceOf(Function); +}); + test('average(true) returns 0', () => { expect(average(true) === 1).toBeTruthy(); +}); + test('average(false) returns 1', () => { expect(average(false) === 0).toBeTruthy(); - expect(average(9, 1)).toBe(5); - expect(average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631)).toBe(32163.909090909092); - expect(average(1, 2, 3)).toBe(2); - expect(average(null)).toBe(0); +}); + t.equal(average(9, 1), 5, 'average(9, 1) returns 5'); + t.equal(average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631), 32163.909090909092, 'average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 '); + t.equal(average(1, 2, 3), 2, 'average(1, 2, 3) returns 2'); + t.equal(average(null), 0, 'average(null) returns 0'); + test('average(1, 2, 3) returns NaN', () => { expect(isNaN(average(undefined))).toBeTruthy(); +}); + test('average(String) returns NaN', () => { expect(isNaN(average('String'))).toBeTruthy(); +}); + test('average({ a: 123}) returns NaN', () => { expect(isNaN(average({ a: 123}))).toBeTruthy(); +}); + test('average([undefined, 0, string]) returns NaN', () => { expect(isNaN(average([undefined, 0, 'string']))).toBeTruthy(); +}); let start = new Date().getTime(); average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631); - let end = new Date().getTime(); + let end = new Date().getTime(); + test('average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run', () => { expect((end - start) < 2000).toBeTruthy(); -}); \ No newline at end of file +}); + diff --git a/test/averageBy/averageBy.test.js b/test/averageBy/averageBy.test.js index d1a1839c3..1176c7e65 100644 --- a/test/averageBy/averageBy.test.js +++ b/test/averageBy/averageBy.test.js @@ -1,10 +1,15 @@ const expect = require('expect'); const averageBy = require('./averageBy.js'); -test('Testing averageBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof averageBy === 'function').toBeTruthy(); - expect(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n)).toBe(5); - expect(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n')).toBe(5); + + test('averageBy is a Function', () => { + expect(averageBy).toBeInstanceOf(Function); }); + test('Produces the right result with a function', () => { + expect(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 5).toBe() +}); + test('Produces the right result with a property name', () => { + expect(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 5).toBe() +}); + + diff --git a/test/bifurcate/bifurcate.test.js b/test/bifurcate/bifurcate.test.js index b8bbda4bf..c7707c710 100644 --- a/test/bifurcate/bifurcate.test.js +++ b/test/bifurcate/bifurcate.test.js @@ -1,9 +1,10 @@ const expect = require('expect'); const bifurcate = require('./bifurcate.js'); -test('Testing bifurcate', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof bifurcate === 'function').toBeTruthy(); - expect(bifurcate([ 'beep', 'boop', 'foo', 'bar' ], [ true, true, false, true ])).toEqual([ ['beep', 'boop', 'bar'], ['foo'] ]); + + test('bifurcate is a Function', () => { + expect(bifurcate).toBeInstanceOf(Function); }); + t.deepEqual(bifurcate([ 'beep', 'boop', 'foo', 'bar' ], [ true, true, false, true ]), [ ['beep', 'boop', 'bar'], ['foo'] ], 'Splits the collection into two groups'); + + diff --git a/test/bifurcateBy/bifurcateBy.test.js b/test/bifurcateBy/bifurcateBy.test.js index 2eebcb6e6..ca3864909 100644 --- a/test/bifurcateBy/bifurcateBy.test.js +++ b/test/bifurcateBy/bifurcateBy.test.js @@ -1,9 +1,10 @@ const expect = require('expect'); const bifurcateBy = require('./bifurcateBy.js'); -test('Testing bifurcateBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof bifurcateBy === 'function').toBeTruthy(); - expect(bifurcateBy([ 'beep', 'boop', 'foo', 'bar' ], x => x[0] === 'b')).toEqual([ ['beep', 'boop', 'bar'], ['foo'] ]); + + test('bifurcateBy is a Function', () => { + expect(bifurcateBy).toBeInstanceOf(Function); }); + t.deepEqual(bifurcateBy([ 'beep', 'boop', 'foo', 'bar' ], x => x[0] === 'b'), [ ['beep', 'boop', 'bar'], ['foo'] ], 'Splits the collection into two groups'); + + diff --git a/test/binarySearch/binarySearch.test.js b/test/binarySearch/binarySearch.test.js index 34620e797..7fcee6d01 100644 --- a/test/binarySearch/binarySearch.test.js +++ b/test/binarySearch/binarySearch.test.js @@ -1,13 +1,12 @@ const expect = require('expect'); const binarySearch = require('./binarySearch.js'); -test('Testing binarySearch', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof binarySearch === 'function').toBeTruthy(); - //t.deepEqual(binarySearch(args..), 'Expected'); - expect(binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 6)).toBe(2); - expect(binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 21)).toBe(-1); - expect(binarySearch([], 21)).toBe(-1); - expect(binarySearch([1], 1)).toBe(0); -}); \ No newline at end of file + + test('binarySearch is a Function', () => { + expect(binarySearch).toBeInstanceOf(Function); +}); + t.equal(binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 6), 2, 'Finds item in array'); + t.equal(binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 21), -1, 'Returns -1 when not found'); + t.equal(binarySearch([], 21), -1, 'Works with empty arrays'); + t.equal(binarySearch([1], 1), 0, "Works for one element arrays"); + diff --git a/test/bind/bind.test.js b/test/bind/bind.test.js index 552c40249..db56f2d50 100644 --- a/test/bind/bind.test.js +++ b/test/bind/bind.test.js @@ -1,14 +1,17 @@ const expect = require('expect'); const bind = require('./bind.js'); -test('Testing bind', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof bind === 'function').toBeTruthy(); + + test('bind is a Function', () => { + expect(bind).toBeInstanceOf(Function); +}); function greet(greeting, punctuation) { return greeting + ' ' + this.user + punctuation; } const freddy = { user: 'fred' }; const freddyBound = bind(greet, freddy); - expect(freddyBound('hi', '!')).toBe('hi fred!'); + test('Binds to an object context', () => { + expect(freddyBound('hi', '!'),'hi fred!').toBe() }); + + diff --git a/test/bindAll/bindAll.test.js b/test/bindAll/bindAll.test.js index 2d6a07c8d..0e2ddb66d 100644 --- a/test/bindAll/bindAll.test.js +++ b/test/bindAll/bindAll.test.js @@ -1,10 +1,10 @@ const expect = require('expect'); const bindAll = require('./bindAll.js'); -test('Testing bindAll', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof bindAll === 'function').toBeTruthy(); + + test('bindAll is a Function', () => { + expect(bindAll).toBeInstanceOf(Function); +}); var view = { label: 'docs', 'click': function() { @@ -12,5 +12,6 @@ test('Testing bindAll', () => { } }; bindAll(view, 'click'); - expect(view.click()).toBe('clicked docs'); -}); + t.equal(view.click(), 'clicked docs', 'Binds to an object context'); + + diff --git a/test/bindKey/bindKey.test.js b/test/bindKey/bindKey.test.js index b34d80dd3..d526a79f8 100644 --- a/test/bindKey/bindKey.test.js +++ b/test/bindKey/bindKey.test.js @@ -1,10 +1,10 @@ const expect = require('expect'); const bindKey = require('./bindKey.js'); -test('Testing bindKey', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof bindKey === 'function').toBeTruthy(); + + test('bindKey is a Function', () => { + expect(bindKey).toBeInstanceOf(Function); +}); const freddy = { user: 'fred', greet: function(greeting, punctuation) { @@ -12,5 +12,6 @@ test('Testing bindKey', () => { } }; const freddyBound = bindKey(freddy, 'greet'); - expect(freddyBound('hi', '!')).toBe('hi fred!'); -}); + t.equal(freddyBound('hi', '!'), 'hi fred!', 'Binds function to an object context'); + + diff --git a/test/binomialCoefficient/binomialCoefficient.test.js b/test/binomialCoefficient/binomialCoefficient.test.js index 2549bb0e8..74b9f5b2e 100644 --- a/test/binomialCoefficient/binomialCoefficient.test.js +++ b/test/binomialCoefficient/binomialCoefficient.test.js @@ -1,13 +1,18 @@ const expect = require('expect'); const binomialCoefficient = require('./binomialCoefficient.js'); -test('Testing binomialCoefficient', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof binomialCoefficient === 'function').toBeTruthy(); - expect(binomialCoefficient(8, 2)).toBe(28); - expect(binomialCoefficient(0, 0)).toBe(1); - expect(binomialCoefficient(5, 3)).toBe(10); + + test('binomialCoefficient is a Function', () => { + expect(binomialCoefficient).toBeInstanceOf(Function); +}); + t.equal(binomialCoefficient(8, 2), 28, 'Returns the appropriate value'); + t.equal(binomialCoefficient(0, 0), 1, 'Returns the appropriate value'); + t.equal(binomialCoefficient(5, 3), 10, 'Returns the appropriate value'); + test('Returns NaN', () => { expect(Number.isNaN(binomialCoefficient(NaN, 3))).toBeTruthy(); +}); + test('Returns NaN', () => { expect(Number.isNaN(binomialCoefficient(5, NaN))).toBeTruthy(); }); + + diff --git a/test/bottomVisible/bottomVisible.test.js b/test/bottomVisible/bottomVisible.test.js index ba92fa3de..f81b9b59a 100644 --- a/test/bottomVisible/bottomVisible.test.js +++ b/test/bottomVisible/bottomVisible.test.js @@ -1,8 +1,10 @@ const expect = require('expect'); const bottomVisible = require('./bottomVisible.js'); -test('Testing bottomVisible', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof bottomVisible === 'function').toBeTruthy(); + + test('bottomVisible is a Function', () => { + expect(bottomVisible).toBeInstanceOf(Function); }); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test/btoa/btoa.test.js b/test/btoa/btoa.test.js index 6720da7bc..d0d97bb75 100644 --- a/test/btoa/btoa.test.js +++ b/test/btoa/btoa.test.js @@ -1,9 +1,12 @@ const expect = require('expect'); const btoa = require('./btoa.js'); -test('Testing btoa', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof btoa === 'function').toBeTruthy(); - expect(btoa('foobar')).toBe('Zm9vYmFy'); + + test('btoa is a Function', () => { + expect(btoa).toBeInstanceOf(Function); }); + test('btoa("foobar") equals "Zm9vYmFy"', () => { + expect(btoa('foobar'), 'Zm9vYmFy').toBe() +}); + + diff --git a/test/byteSize/byteSize.test.js b/test/byteSize/byteSize.test.js index f0cafd212..2e6bfee63 100644 --- a/test/byteSize/byteSize.test.js +++ b/test/byteSize/byteSize.test.js @@ -1,4 +1,4 @@ -import expect from 'expect'; +const expect = require('expect'); const Blob = class{ constructor(s) { return { @@ -6,14 +6,13 @@ const Blob = class{ }; } }; -// const byteSize = require('./byteSize.js'); -// Override const byteSize = str => new Blob([str]).size; -test('Testing byteSize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof byteSize === 'function').toBeTruthy(); - expect(byteSize('a')).toBe(1); - expect(byteSize('Hello World')).toBe(11); - expect(byteSize('😀')).toBe(4); + + test('byteSize is a Function', () => { + expect(byteSize).toBeInstanceOf(Function); }); + t.equal(byteSize('a'), 1, 'Works for a single letter'); + t.equal(byteSize('Hello World'), 11, 'Works for a common string'); + t.equal(byteSize('😀'), 4, 'Works for emoji'); + + diff --git a/test/call/call.test.js b/test/call/call.test.js index 831054502..a4585ac22 100644 --- a/test/call/call.test.js +++ b/test/call/call.test.js @@ -1,10 +1,9 @@ const expect = require('expect'); const call = require('./call.js'); -test('Testing call', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof call === 'function').toBeTruthy(); - //t.deepEqual(call(args..), 'Expected'); + + test('call is a Function', () => { + expect(call).toBeInstanceOf(Function); +}); t.looseEqual(call('map', x => x * 2)([1, 2, 3]), [2, 4, 6], 'Calls function on given object'); -}); \ No newline at end of file + diff --git a/test/capitalize/capitalize.test.js b/test/capitalize/capitalize.test.js index 677d1198b..c031fedf2 100644 --- a/test/capitalize/capitalize.test.js +++ b/test/capitalize/capitalize.test.js @@ -1,12 +1,12 @@ const expect = require('expect'); const capitalize = require('./capitalize.js'); -test('Testing capitalize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof capitalize === 'function').toBeTruthy(); - expect(capitalize('fooBar')).toBe('FooBar'); - expect(capitalize('fooBar', true)).toBe('Foobar'); - expect(capitalize('#!#', true)).toBe('#!#'); - expect(capitalize('a', true)).toBe('A'); -}); \ No newline at end of file + + test('capitalize is a Function', () => { + expect(capitalize).toBeInstanceOf(Function); +}); + t.equal(capitalize('fooBar'), 'FooBar', "Capitalizes the first letter of a string"); + t.equal(capitalize('fooBar', true), 'Foobar', "Capitalizes the first letter of a string"); + t.equal(capitalize('#!#', true), '#!#', "Works with characters"); + t.equal(capitalize('a', true), 'A', "Works with single character words"); + diff --git a/test/capitalizeEveryWord/capitalizeEveryWord.test.js b/test/capitalizeEveryWord/capitalizeEveryWord.test.js index 2f3482a35..7da925b9a 100644 --- a/test/capitalizeEveryWord/capitalizeEveryWord.test.js +++ b/test/capitalizeEveryWord/capitalizeEveryWord.test.js @@ -1,11 +1,11 @@ const expect = require('expect'); const capitalizeEveryWord = require('./capitalizeEveryWord.js'); -test('Testing capitalizeEveryWord', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof capitalizeEveryWord === 'function').toBeTruthy(); - expect(capitalizeEveryWord('hello world!')).toBe('Hello World!'); - expect(capitalizeEveryWord('$# @!')).toBe('$# @!'); - expect(capitalizeEveryWord('a')).toBe('A'); -}); \ No newline at end of file + + test('capitalizeEveryWord is a Function', () => { + expect(capitalizeEveryWord).toBeInstanceOf(Function); +}); + t.equal(capitalizeEveryWord('hello world!'), 'Hello World!', "Capitalizes the first letter of every word in a string"); + t.equal(capitalizeEveryWord('$# @!'), '$# @!', "Works with characters"); + t.equal(capitalizeEveryWord('a'), 'A', "Works with one word string"); + diff --git a/test/castArray/castArray.test.js b/test/castArray/castArray.test.js index b66526e2f..5b849197c 100644 --- a/test/castArray/castArray.test.js +++ b/test/castArray/castArray.test.js @@ -1,13 +1,14 @@ const expect = require('expect'); const castArray = require('./castArray.js'); -test('Testing castArray', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof castArray === 'function').toBeTruthy(); - expect(castArray(1)).toEqual([1]); - expect(castArray([1])).toEqual([1]); - expect(castArray([1,2,3])).toEqual([1,2,3]); - expect(castArray('test')).toEqual(['test']); - expect(castArray({})).toEqual([{}]); + + test('castArray is a Function', () => { + expect(castArray).toBeInstanceOf(Function); }); + t.deepEqual(castArray(1), [1], 'Works for single values'); + t.deepEqual(castArray([1]), [1], 'Works for arrays with one value'); + t.deepEqual(castArray([1,2,3]), [1,2,3], 'Works for arrays with multiple value'); + t.deepEqual(castArray('test'), ['test'], 'Works for strings'); + t.deepEqual(castArray({}), [{}], 'Works for objects'); + + diff --git a/test/chainAsync/chainAsync.test.js b/test/chainAsync/chainAsync.test.js index 1fa7bf1eb..43cd39c4f 100644 --- a/test/chainAsync/chainAsync.test.js +++ b/test/chainAsync/chainAsync.test.js @@ -1,10 +1,10 @@ const expect = require('expect'); const chainAsync = require('./chainAsync.js'); -test('Testing chainAsync', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof chainAsync === 'function').toBeTruthy(); + + test('chainAsync is a Function', () => { + expect(chainAsync).toBeInstanceOf(Function); +}); chainAsync([ next => { next(); @@ -14,6 +14,9 @@ test('Testing chainAsync', () => { next(); })(); }, - next => {} + next => { + t.pass("Calls all functions in an array"); + } ]); -}); + + diff --git a/test/chunk/chunk.test.js b/test/chunk/chunk.test.js index 18b6bf623..8db6625c8 100644 --- a/test/chunk/chunk.test.js +++ b/test/chunk/chunk.test.js @@ -1,21 +1,24 @@ const expect = require('expect'); const chunk = require('./chunk.js'); -test('Testing chunk', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof chunk === 'function').toBeTruthy(); - expect(chunk([1, 2, 3, 4, 5], 2)).toEqual([[1,2],[3,4],[5]]); - expect(chunk([])).toEqual([]); - expect(chunk(123)).toEqual([]); - expect(chunk({ a: 123})).toEqual([]); - expect(chunk('string', 2)).toEqual([ 'st', 'ri', 'ng' ]); - expect(() => chunk()).toThrow(); - expect(() => chunk(undefined)).toThrow(); - expect(() => chunk(null)).toThrow(); + + test('chunk is a Function', () => { + expect(chunk).toBeInstanceOf(Function); +}); + t.deepEqual(chunk([1, 2, 3, 4, 5], 2), [[1,2],[3,4],[5]], "chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] "); + t.deepEqual(chunk([]), [], 'chunk([]) returns []'); + t.deepEqual(chunk(123), [], 'chunk(123) returns []'); + t.deepEqual(chunk({ a: 123}), [], 'chunk({ a: 123}) returns []'); + t.deepEqual(chunk('string', 2), [ 'st', 'ri', 'ng' ], 'chunk(string, 2) returns [ st, ri, ng ]'); + t.throws(() => chunk(), 'chunk() throws an error'); + t.throws(() => chunk(undefined), 'chunk(undefined) throws an error'); + t.throws(() => chunk(null), 'chunk(null) throws an error'); let start = new Date().getTime(); chunk('This is a string', 2); let end = new Date().getTime(); + test('chunk(This is a string, 2) takes less than 2s to run', () => { expect((end - start) < 2000).toBeTruthy(); }); + + diff --git a/test/clampNumber/clampNumber.test.js b/test/clampNumber/clampNumber.test.js index 2ee01ebc7..9d4cd64b3 100644 --- a/test/clampNumber/clampNumber.test.js +++ b/test/clampNumber/clampNumber.test.js @@ -1,9 +1,9 @@ const expect = require('expect'); const clampNumber = require('./clampNumber.js'); -test('Testing clampNumber', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof clampNumber === 'function').toBeTruthy(); - expect(clampNumber(2, 3, 5)).toBe(3); -}); \ No newline at end of file + + test('clampNumber is a Function', () => { + expect(clampNumber).toBeInstanceOf(Function); +}); + t.equal(clampNumber(2, 3, 5), 3, "Clamps num within the inclusive range specified by the boundary values a and b"); + diff --git a/test/cleanObj/cleanObj.js b/test/cleanObj/cleanObj.js index 0d38b03f8..9e7573fb4 100644 --- a/test/cleanObj/cleanObj.js +++ b/test/cleanObj/cleanObj.js @@ -5,7 +5,7 @@ cleanObj(obj[key], keysToKeep, childIndicator); } else if (!keysToKeep.includes(key)) { delete obj[key]; } -}); + return obj; }; module.exports = cleanObj; \ No newline at end of file diff --git a/test/cleanObj/cleanObj.test.js b/test/cleanObj/cleanObj.test.js index 15ea30712..916281b31 100644 --- a/test/cleanObj/cleanObj.test.js +++ b/test/cleanObj/cleanObj.test.js @@ -1,10 +1,10 @@ const expect = require('expect'); const cleanObj = require('./cleanObj.js'); -test('Testing cleanObj', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof cleanObj === 'function').toBeTruthy(); + + test('cleanObj is a Function', () => { + expect(cleanObj).toBeInstanceOf(Function); +}); const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } }; - expect(cleanObj(testObj, ['a'], 'children')).toEqual({ a: 1, children : { a: 1}}); -}); \ No newline at end of file + t.deepEqual(cleanObj(testObj, ['a'], 'children'), { a: 1, children : { a: 1}}, "Removes any properties except the ones specified from a JSON object"); + diff --git a/test/cloneRegExp/cloneRegExp.test.js b/test/cloneRegExp/cloneRegExp.test.js index 3a323061b..8f6e675c9 100644 --- a/test/cloneRegExp/cloneRegExp.test.js +++ b/test/cloneRegExp/cloneRegExp.test.js @@ -1,10 +1,11 @@ const expect = require('expect'); const cloneRegExp = require('./cloneRegExp.js'); -test('Testing cloneRegExp', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof cloneRegExp === 'function').toBeTruthy(); - const rgTest = /./g; - expect(cloneRegExp(rgTest)).not.toBe(rgTest); + + test('cloneRegExp is a Function', () => { + expect(cloneRegExp).toBeInstanceOf(Function); }); + const rgTest = /./g; + t.notEqual(cloneRegExp(rgTest), rgTest, 'Clones regular expressions properly'); + + diff --git a/test/coalesce/coalesce.test.js b/test/coalesce/coalesce.test.js index fb0876734..aacedc163 100644 --- a/test/coalesce/coalesce.test.js +++ b/test/coalesce/coalesce.test.js @@ -1,9 +1,9 @@ const expect = require('expect'); const coalesce = require('./coalesce.js'); -test('Testing coalesce', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof coalesce === 'function').toBeTruthy(); - expect(coalesce(null, undefined, '', NaN, 'Waldo')).toEqual(''); -}); \ No newline at end of file + + test('coalesce is a Function', () => { + expect(coalesce).toBeInstanceOf(Function); +}); + t.deepEqual(coalesce(null, undefined, '', NaN, 'Waldo'), '', "Returns the first non-null/undefined argument"); + diff --git a/test/coalesceFactory/coalesceFactory.test.js b/test/coalesceFactory/coalesceFactory.test.js index 74cd3b817..f6645b692 100644 --- a/test/coalesceFactory/coalesceFactory.test.js +++ b/test/coalesceFactory/coalesceFactory.test.js @@ -1,10 +1,10 @@ const expect = require('expect'); const coalesceFactory = require('./coalesceFactory.js'); -test('Testing coalesceFactory', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof coalesceFactory === 'function').toBeTruthy(); + + test('coalesceFactory is a Function', () => { + expect(coalesceFactory).toBeInstanceOf(Function); +}); const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_)); - expect(customCoalesce(undefined, null, NaN, '', 'Waldo')).toEqual('Waldo'); -}); \ No newline at end of file + t.deepEqual(customCoalesce(undefined, null, NaN, '', 'Waldo'), 'Waldo', "Returns a customized coalesce function"); + diff --git a/test/collatz/collatz.test.js b/test/collatz/collatz.test.js index 3163ac75c..fa2b6ed25 100644 --- a/test/collatz/collatz.test.js +++ b/test/collatz/collatz.test.js @@ -1,19 +1,20 @@ const expect = require('expect'); const collatz = require('./collatz.js'); -test('Testing collatz', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof collatz === 'function').toBeTruthy(); - //t.deepEqual(collatz(args..), 'Expected'); - expect(collatz(8)).toBe(4); - expect(collatz(9)).toBe(28); + + test('collatz is a Function', () => { + expect(collatz).toBeInstanceOf(Function); +}); + t.equal(collatz(8), 4, 'When n is even, divide by 2'); + t.equal(collatz(9), 28, 'When n is odd, times by 3 and add 1'); let n = 9; while(true){ if (n === 1){ + t.pass('Eventually reaches 1'); break; } n = collatz(n); } -}); + + diff --git a/test/collectInto/collectInto.test.js b/test/collectInto/collectInto.test.js index ecfc30293..30e358c50 100644 --- a/test/collectInto/collectInto.test.js +++ b/test/collectInto/collectInto.test.js @@ -1,13 +1,14 @@ const expect = require('expect'); const collectInto = require('./collectInto.js'); -test('Testing collectInto', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof collectInto === 'function').toBeTruthy(); + + test('collectInto is a Function', () => { + expect(collectInto).toBeInstanceOf(Function); +}); const Pall = collectInto(Promise.all.bind(Promise)); let p1 = Promise.resolve(1); let p2 = Promise.resolve(2); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); - Pall(p1, p2, p3).then(function(val){ expect(val).toEqual([1,2,3]);}, function(reason){}); -}); + Pall(p1, p2, p3).then(function(val){ t.deepEqual(val, [1,2,3], 'Works with multiple promises');}, function(reason){ + + diff --git a/test/colorize/colorize.js b/test/colorize/colorize.js index 7c8fe1846..1322cc934 100644 --- a/test/colorize/colorize.js +++ b/test/colorize/colorize.js @@ -15,5 +15,5 @@ bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`, bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`, bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`, bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m` -}); + module.exports = colorize; \ No newline at end of file diff --git a/test/colorize/colorize.test.js b/test/colorize/colorize.test.js index 85def3607..b708096d8 100644 --- a/test/colorize/colorize.test.js +++ b/test/colorize/colorize.test.js @@ -1,8 +1,10 @@ const expect = require('expect'); const colorize = require('./colorize.js'); -test('Testing colorize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof colorize === 'function').toBeTruthy(); + + test('colorize is a Function', () => { + expect(colorize).toBeInstanceOf(Function); }); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test/compact/compact.test.js b/test/compact/compact.test.js index f3a4af122..087340a4c 100644 --- a/test/compact/compact.test.js +++ b/test/compact/compact.test.js @@ -1,9 +1,9 @@ const expect = require('expect'); const compact = require('./compact.js'); -test('Testing compact', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof compact === 'function').toBeTruthy(); - expect(compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34])).toEqual([ 1, 2, 3, 'a', 's', 34 ]); -}); \ No newline at end of file + + test('compact is a Function', () => { + expect(compact).toBeInstanceOf(Function); +}); + t.deepEqual(compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]), [ 1, 2, 3, 'a', 's', 34 ], "Removes falsey values from an array"); + diff --git a/test/compose/compose.test.js b/test/compose/compose.test.js index b8788829b..b5332a0be 100644 --- a/test/compose/compose.test.js +++ b/test/compose/compose.test.js @@ -1,12 +1,12 @@ const expect = require('expect'); const compose = require('./compose.js'); -test('Testing compose', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof compose === 'function').toBeTruthy(); + + test('compose is a Function', () => { + expect(compose).toBeInstanceOf(Function); +}); const add5 = x => x + 5; const multiply = (x, y) => x * y; const multiplyAndAdd5 = compose(add5, multiply); - expect(multiplyAndAdd5(5, 2)).toBe(15); -}); \ No newline at end of file + t.equal(multiplyAndAdd5(5, 2), 15, "Performs right-to-left function composition"); + diff --git a/test/composeRight/composeRight.test.js b/test/composeRight/composeRight.test.js index bf6ff5ed9..f24024bdd 100644 --- a/test/composeRight/composeRight.test.js +++ b/test/composeRight/composeRight.test.js @@ -1,12 +1,13 @@ const expect = require('expect'); const composeRight = require('./composeRight.js'); -test('Testing composeRight', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof composeRight === 'function').toBeTruthy(); + + test('composeRight is a Function', () => { + expect(composeRight).toBeInstanceOf(Function); +}); const add = (x, y) => x + y; const square = x => x * x; const addAndSquare = composeRight(add, square); - expect(addAndSquare(1, 2)).toBe(9); -}); + t.equal(addAndSquare(1, 2), 9, "Performs left-to-right function composition"); + + diff --git a/test/converge/converge.test.js b/test/converge/converge.test.js index d066c0937..34c71906d 100644 --- a/test/converge/converge.test.js +++ b/test/converge/converge.test.js @@ -1,18 +1,19 @@ const expect = require('expect'); const converge = require('./converge.js'); -test('Testing converge', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof converge === 'function').toBeTruthy(); + + test('converge is a Function', () => { + expect(converge).toBeInstanceOf(Function); +}); const average = converge((a, b) => a / b, [ arr => arr.reduce((a, v) => a + v, 0), arr => arr.length, ]); - expect(average([1, 2, 3, 4, 5, 6, 7])).toBe(4); + t.equal(average([1, 2, 3, 4, 5, 6, 7]), 4, 'Produces the average of the array'); const strangeConcat = converge((a, b) => a + b, [ x => x.toUpperCase(), x => x.toLowerCase()] ); - expect(strangeConcat('Yodel')).toBe("YODELyodel"); -}); + t.equal(strangeConcat('Yodel'), "YODELyodel", 'Produces the strange concatenation'); + + diff --git a/test/copyToClipboard/copyToClipboard.test.js b/test/copyToClipboard/copyToClipboard.test.js index 3dbcdf2db..9344d6296 100644 --- a/test/copyToClipboard/copyToClipboard.test.js +++ b/test/copyToClipboard/copyToClipboard.test.js @@ -1,8 +1,10 @@ const expect = require('expect'); const copyToClipboard = require('./copyToClipboard.js'); -test('Testing copyToClipboard', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof copyToClipboard === 'function').toBeTruthy(); + + test('copyToClipboard is a Function', () => { + expect(copyToClipboard).toBeInstanceOf(Function); }); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test/countBy/countBy.js b/test/countBy/countBy.js index 256070afb..c75f9fd51 100644 --- a/test/countBy/countBy.js +++ b/test/countBy/countBy.js @@ -2,5 +2,5 @@ const countBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { acc[val] = (acc[val] || 0) + 1; return acc; -}, {}); +}, { module.exports = countBy; \ No newline at end of file diff --git a/test/countBy/countBy.test.js b/test/countBy/countBy.test.js index 87b969afa..c73ffa3ac 100644 --- a/test/countBy/countBy.test.js +++ b/test/countBy/countBy.test.js @@ -1,10 +1,11 @@ const expect = require('expect'); const countBy = require('./countBy.js'); -test('Testing countBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof countBy === 'function').toBeTruthy(); - expect(countBy([6.1, 4.2, 6.3], Math.floor)).toEqual({4: 1, 6: 2}); - expect(countBy(['one', 'two', 'three'], 'length')).toEqual({3: 2, 5: 1}); + + test('countBy is a Function', () => { + expect(countBy).toBeInstanceOf(Function); }); + t.deepEqual(countBy([6.1, 4.2, 6.3], Math.floor), {4: 1, 6: 2}, 'Works for functions'); + t.deepEqual(countBy(['one', 'two', 'three'], 'length'), {3: 2, 5: 1}, 'Works for property names'); + + diff --git a/test/countOccurrences/countOccurrences.test.js b/test/countOccurrences/countOccurrences.test.js index 518b29888..1b43f1be8 100644 --- a/test/countOccurrences/countOccurrences.test.js +++ b/test/countOccurrences/countOccurrences.test.js @@ -1,9 +1,9 @@ const expect = require('expect'); const countOccurrences = require('./countOccurrences.js'); -test('Testing countOccurrences', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof countOccurrences === 'function').toBeTruthy(); - expect(countOccurrences([1, 1, 2, 1, 2, 3], 1)).toEqual(3); -}); \ No newline at end of file + + test('countOccurrences is a Function', () => { + expect(countOccurrences).toBeInstanceOf(Function); +}); + t.deepEqual(countOccurrences([1, 1, 2, 1, 2, 3], 1), 3, "Counts the occurrences of a value in an array"); + diff --git a/test/countVowels/countVowels.test.js b/test/countVowels/countVowels.test.js index f631109ec..dc5fc72a7 100644 --- a/test/countVowels/countVowels.test.js +++ b/test/countVowels/countVowels.test.js @@ -1,8 +1,8 @@ const expect = require('expect'); const countVowels = require('./countVowels.js'); -test('Testing countVowels', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof countVowels === 'function').toBeTruthy(); -}); \ No newline at end of file + + test('countVowels is a Function', () => { + expect(countVowels).toBeInstanceOf(Function); +}); + diff --git a/test/counter/counter.test.js b/test/counter/counter.test.js index 93c889ed4..d7a7e4e91 100644 --- a/test/counter/counter.test.js +++ b/test/counter/counter.test.js @@ -1,8 +1,8 @@ const expect = require('expect'); const counter = require('./counter.js'); -test('Testing counter', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof counter === 'function').toBeTruthy(); -}); \ No newline at end of file + + test('counter is a Function', () => { + expect(counter).toBeInstanceOf(Function); +}); + diff --git a/test/createElement/createElement.test.js b/test/createElement/createElement.test.js index f8dadcc16..2ad5a2124 100644 --- a/test/createElement/createElement.test.js +++ b/test/createElement/createElement.test.js @@ -1,8 +1,10 @@ const expect = require('expect'); const createElement = require('./createElement.js'); -test('Testing createElement', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof createElement === 'function').toBeTruthy(); + + test('createElement is a Function', () => { + expect(createElement).toBeInstanceOf(Function); }); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test/createEventHub/createEventHub.js b/test/createEventHub/createEventHub.js index 949f8fbc0..d219a0815 100644 --- a/test/createEventHub/createEventHub.js +++ b/test/createEventHub/createEventHub.js @@ -11,5 +11,5 @@ off(event, handler) { const i = (this.hub[event] || []).findIndex(h => h === handler); if (i > -1) this.hub[event].splice(i, 1); } -}); + module.exports = createEventHub; \ No newline at end of file diff --git a/test/createEventHub/createEventHub.test.js b/test/createEventHub/createEventHub.test.js index 4991ebaca..179f2c7c1 100644 --- a/test/createEventHub/createEventHub.test.js +++ b/test/createEventHub/createEventHub.test.js @@ -1,8 +1,10 @@ const expect = require('expect'); const createEventHub = require('./createEventHub.js'); -test('Testing createEventHub', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof createEventHub === 'function').toBeTruthy(); + + test('createEventHub is a Function', () => { + expect(createEventHub).toBeInstanceOf(Function); }); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test/currentURL/currentURL.test.js b/test/currentURL/currentURL.test.js index 52aeb37b3..8344c7163 100644 --- a/test/currentURL/currentURL.test.js +++ b/test/currentURL/currentURL.test.js @@ -1,8 +1,10 @@ const expect = require('expect'); const currentURL = require('./currentURL.js'); -test('Testing currentURL', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof currentURL === 'function').toBeTruthy(); + + test('currentURL is a Function', () => { + expect(currentURL).toBeInstanceOf(Function); }); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test/curry/curry.test.js b/test/curry/curry.test.js index b2f8cae8a..f97b6a260 100644 --- a/test/curry/curry.test.js +++ b/test/curry/curry.test.js @@ -1,10 +1,10 @@ const expect = require('expect'); const curry = require('./curry.js'); -test('Testing curry', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof curry === 'function').toBeTruthy(); - expect(curry(Math.pow)(2)(10)).toBe(1024); - expect(curry(Math.min, 3)(10)(50)(2)).toBe(2); -}); \ No newline at end of file + + test('curry is a Function', () => { + expect(curry).toBeInstanceOf(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"); + diff --git a/test/debounce/debounce.test.js b/test/debounce/debounce.test.js index 88d9c3b75..81e49d2bd 100644 --- a/test/debounce/debounce.test.js +++ b/test/debounce/debounce.test.js @@ -1,9 +1,10 @@ const expect = require('expect'); const debounce = require('./debounce.js'); -test('Testing debounce', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof debounce === 'function').toBeTruthy(); - debounce(() => {}, 250); + + test('debounce is a Function', () => { + expect(debounce).toBeInstanceOf(Function); }); + debounce(() => {t.pass('Works as expected');}, 250); + + diff --git a/test/decapitalize/decapitalize.test.js b/test/decapitalize/decapitalize.test.js index b600ace89..5adbd21a1 100644 --- a/test/decapitalize/decapitalize.test.js +++ b/test/decapitalize/decapitalize.test.js @@ -1,10 +1,11 @@ const expect = require('expect'); const decapitalize = require('./decapitalize.js'); -test('Testing decapitalize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof decapitalize === 'function').toBeTruthy(); - expect(decapitalize('FooBar')).toBe('fooBar'); - expect(decapitalize('FooBar', true)).toBe('fOOBAR'); + + test('decapitalize is a Function', () => { + expect(decapitalize).toBeInstanceOf(Function); }); + t.equal(decapitalize('FooBar'), 'fooBar', 'Works with default parameter'); + t.equal(decapitalize('FooBar', true), 'fOOBAR', 'Works with second parameter set to true'); + + diff --git a/test/deepClone/deepClone.test.js b/test/deepClone/deepClone.test.js index dca7e3a64..8996449eb 100644 --- a/test/deepClone/deepClone.test.js +++ b/test/deepClone/deepClone.test.js @@ -1,16 +1,17 @@ const expect = require('expect'); const deepClone = require('./deepClone.js'); -test('Testing deepClone', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof deepClone === 'function').toBeTruthy(); + + test('deepClone is a Function', () => { + expect(deepClone).toBeInstanceOf(Function); +}); const a = { foo: 'bar', obj: { a: 1, b: 2 } }; const b = deepClone(a); const c = [{foo: "bar"}]; const d = deepClone(c); - expect(a).not.toBe(b); - expect(a.obj).not.toBe(b.obj); - expect(c).not.toBe(d); - expect(c[0]).not.toBe(d[0]); -}); + t.notEqual(a, b, 'Shallow cloning works'); + t.notEqual(a.obj, b.obj, 'Deep cloning works'); + t.notEqual(c, d, "Array shallow cloning works"); + t.notEqual(c[0], d[0], "Array deep cloning works"); + + diff --git a/test/deepFlatten/deepFlatten.test.js b/test/deepFlatten/deepFlatten.test.js index 2d57901e4..fa77ac6a7 100644 --- a/test/deepFlatten/deepFlatten.test.js +++ b/test/deepFlatten/deepFlatten.test.js @@ -1,9 +1,9 @@ const expect = require('expect'); const deepFlatten = require('./deepFlatten.js'); -test('Testing deepFlatten', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof deepFlatten === 'function').toBeTruthy(); - expect(deepFlatten([1, [2], [[3], 4], 5])).toEqual([1, 2, 3, 4, 5]); -}); \ No newline at end of file + + test('deepFlatten is a Function', () => { + expect(deepFlatten).toBeInstanceOf(Function); +}); + t.deepEqual(deepFlatten([1, [2], [[3], 4], 5]), [1, 2, 3, 4, 5], "Deep flattens an array"); + diff --git a/test2/defaults/defaults.js b/test/defaults/defaults.js similarity index 100% rename from test2/defaults/defaults.js rename to test/defaults/defaults.js diff --git a/test/defaults/defaults.test.js b/test/defaults/defaults.test.js new file mode 100644 index 000000000..41e3224aa --- /dev/null +++ b/test/defaults/defaults.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const defaults = require('./defaults.js'); + + + test('defaults is a Function', () => { + expect(defaults).toBeInstanceOf(Function); +}); + t.deepEqual(defaults({ a: 1 }, { b: 2 }, { b: 6 }, { a: 3 }), { a: 1, b: 2 }, 'Assigns default values for undefined properties'); + + diff --git a/test2/defer/defer.js b/test/defer/defer.js similarity index 100% rename from test2/defer/defer.js rename to test/defer/defer.js diff --git a/test/defer/defer.test.js b/test/defer/defer.test.js new file mode 100644 index 000000000..1e05fdb09 --- /dev/null +++ b/test/defer/defer.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const defer = require('./defer.js'); + + + test('defer is a Function', () => { + expect(defer).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test2/degreesToRads/degreesToRads.js b/test/degreesToRads/degreesToRads.js similarity index 100% rename from test2/degreesToRads/degreesToRads.js rename to test/degreesToRads/degreesToRads.js diff --git a/test/degreesToRads/degreesToRads.test.js b/test/degreesToRads/degreesToRads.test.js new file mode 100644 index 000000000..a434d4bbd --- /dev/null +++ b/test/degreesToRads/degreesToRads.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const degreesToRads = require('./degreesToRads.js'); + + + const approxeq = (v1,v2, diff = 0.001) => Math.abs(v1 - v2) < diff; + test('degreesToRads is a Function', () => { + expect(degreesToRads).toBeInstanceOf(Function); +}); + test('Returns the appropriate value', () => { + expect(approxeq(degreesToRads(90.0), Math.PI / 2)).toBeTruthy(); +}); + + diff --git a/test2/delay/delay.js b/test/delay/delay.js similarity index 100% rename from test2/delay/delay.js rename to test/delay/delay.js diff --git a/test/delay/delay.test.js b/test/delay/delay.test.js new file mode 100644 index 000000000..afe547b5f --- /dev/null +++ b/test/delay/delay.test.js @@ -0,0 +1,18 @@ +const expect = require('expect'); +const delay = require('./delay.js'); + + + test('delay is a Function', () => { + expect(delay).toBeInstanceOf(Function); +}); + delay( + function(text) { + test('Works as expecting, passing arguments properly', () => { + expect(text, 'test').toBe() +}); + }, + 1000, + 'test' + ); + + diff --git a/test2/detectDeviceType/detectDeviceType.js b/test/detectDeviceType/detectDeviceType.js similarity index 100% rename from test2/detectDeviceType/detectDeviceType.js rename to test/detectDeviceType/detectDeviceType.js diff --git a/test/detectDeviceType/detectDeviceType.test.js b/test/detectDeviceType/detectDeviceType.test.js new file mode 100644 index 000000000..55f89c2e1 --- /dev/null +++ b/test/detectDeviceType/detectDeviceType.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const detectDeviceType = require('./detectDeviceType.js'); + + + test('detectDeviceType is a Function', () => { + expect(detectDeviceType).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test2/difference/difference.js b/test/difference/difference.js similarity index 100% rename from test2/difference/difference.js rename to test/difference/difference.js diff --git a/test/difference/difference.test.js b/test/difference/difference.test.js new file mode 100644 index 000000000..6062511a3 --- /dev/null +++ b/test/difference/difference.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const difference = require('./difference.js'); + + + test('difference is a Function', () => { + expect(difference).toBeInstanceOf(Function); +}); + t.deepEqual(difference([1, 2, 3], [1, 2, 4]), [3], "Returns the difference between two arrays"); + diff --git a/test2/differenceBy/differenceBy.js b/test/differenceBy/differenceBy.js similarity index 100% rename from test2/differenceBy/differenceBy.js rename to test/differenceBy/differenceBy.js diff --git a/test/differenceBy/differenceBy.test.js b/test/differenceBy/differenceBy.test.js new file mode 100644 index 000000000..dc25227a6 --- /dev/null +++ b/test/differenceBy/differenceBy.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const differenceBy = require('./differenceBy.js'); + + + test('differenceBy is a Function', () => { + expect(differenceBy).toBeInstanceOf(Function); +}); + t.deepEqual(differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor), [1.2], 'Works using a native function and numbers'); + t.deepEqual(differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], v => v.x), [ { x: 2 } ], 'Works with arrow function and objects'); + + diff --git a/test2/differenceWith/differenceWith.js b/test/differenceWith/differenceWith.js similarity index 100% rename from test2/differenceWith/differenceWith.js rename to test/differenceWith/differenceWith.js diff --git a/test/differenceWith/differenceWith.test.js b/test/differenceWith/differenceWith.test.js new file mode 100644 index 000000000..2d840b5bf --- /dev/null +++ b/test/differenceWith/differenceWith.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const differenceWith = require('./differenceWith.js'); + + + test('differenceWith is a Function', () => { + expect(differenceWith).toBeInstanceOf(Function); +}); + t.deepEqual(differenceWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Math.round(b)), [1, 1.2], "Filters out all values from an array"); + diff --git a/test2/digitize/digitize.js b/test/digitize/digitize.js similarity index 100% rename from test2/digitize/digitize.js rename to test/digitize/digitize.js diff --git a/test/digitize/digitize.test.js b/test/digitize/digitize.test.js new file mode 100644 index 000000000..27ef11539 --- /dev/null +++ b/test/digitize/digitize.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const digitize = require('./digitize.js'); + + + test('digitize is a Function', () => { + expect(digitize).toBeInstanceOf(Function); +}); + t.deepEqual(digitize(123), [1, 2, 3], "Converts a number to an array of digits"); + diff --git a/test2/distance/distance.js b/test/distance/distance.js similarity index 100% rename from test2/distance/distance.js rename to test/distance/distance.js diff --git a/test/distance/distance.test.js b/test/distance/distance.test.js new file mode 100644 index 000000000..769d128c2 --- /dev/null +++ b/test/distance/distance.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const distance = require('./distance.js'); + + + test('distance is a Function', () => { + expect(distance).toBeInstanceOf(Function); +}); + test('Calculates the distance between two points', () => { + expect(distance(1, 1, 2, 3), 2.23606797749979).toBe() +}); + + diff --git a/test2/drop/drop.js b/test/drop/drop.js similarity index 100% rename from test2/drop/drop.js rename to test/drop/drop.js diff --git a/test/drop/drop.test.js b/test/drop/drop.test.js new file mode 100644 index 000000000..679f96926 --- /dev/null +++ b/test/drop/drop.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const drop = require('./drop.js'); + + + test('drop is a Function', () => { + expect(drop).toBeInstanceOf(Function); +}); + t.deepEqual(drop([1, 2, 3]), [2,3], 'Works without the last argument'); + t.deepEqual(drop([1, 2, 3], 2), [3], 'Removes appropriate element count as specified'); + t.deepEqual(drop([1, 2, 3], 42), [], 'Empties array given a count greater than length'); + + diff --git a/test2/dropRight/dropRight.js b/test/dropRight/dropRight.js similarity index 100% rename from test2/dropRight/dropRight.js rename to test/dropRight/dropRight.js diff --git a/test/dropRight/dropRight.test.js b/test/dropRight/dropRight.test.js new file mode 100644 index 000000000..e5d4523ec --- /dev/null +++ b/test/dropRight/dropRight.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const dropRight = require('./dropRight.js'); + + + test('dropRight is a Function', () => { + expect(dropRight).toBeInstanceOf(Function); +}); + t.deepEqual(dropRight([1, 2, 3]), [1,2], "Returns a new array with n elements removed from the right"); + t.deepEqual(dropRight([1, 2, 3], 2), [1], "Returns a new array with n elements removed from the right"); + t.deepEqual(dropRight([1, 2, 3], 42), [], "Returns a new array with n elements removed from the right"); + diff --git a/test2/dropRightWhile/dropRightWhile.js b/test/dropRightWhile/dropRightWhile.js similarity index 100% rename from test2/dropRightWhile/dropRightWhile.js rename to test/dropRightWhile/dropRightWhile.js diff --git a/test/dropRightWhile/dropRightWhile.test.js b/test/dropRightWhile/dropRightWhile.test.js new file mode 100644 index 000000000..b59d5d0e3 --- /dev/null +++ b/test/dropRightWhile/dropRightWhile.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const dropRightWhile = require('./dropRightWhile.js'); + + + test('dropRightWhile is a Function', () => { + expect(dropRightWhile).toBeInstanceOf(Function); +}); + t.deepEqual(dropRightWhile([1, 2, 3, 4], n => n < 3), [1, 2], 'Removes elements from the end of an array until the passed function returns true.'); + + diff --git a/test2/dropWhile/dropWhile.js b/test/dropWhile/dropWhile.js similarity index 100% rename from test2/dropWhile/dropWhile.js rename to test/dropWhile/dropWhile.js diff --git a/test/dropWhile/dropWhile.test.js b/test/dropWhile/dropWhile.test.js new file mode 100644 index 000000000..380a55d10 --- /dev/null +++ b/test/dropWhile/dropWhile.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const dropWhile = require('./dropWhile.js'); + + + test('dropWhile is a Function', () => { + expect(dropWhile).toBeInstanceOf(Function); +}); + t.deepEqual(dropWhile([1, 2, 3, 4], n => n >= 3), [3,4], 'Removes elements in an array until the passed function returns true.'); + + diff --git a/test2/elementIsVisibleInViewport/elementIsVisibleInViewport.js b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js similarity index 100% rename from test2/elementIsVisibleInViewport/elementIsVisibleInViewport.js rename to test/elementIsVisibleInViewport/elementIsVisibleInViewport.js diff --git a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js new file mode 100644 index 000000000..0970f53cf --- /dev/null +++ b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const elementIsVisibleInViewport = require('./elementIsVisibleInViewport.js'); + + + test('elementIsVisibleInViewport is a Function', () => { + expect(elementIsVisibleInViewport).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test2/elo/elo.js b/test/elo/elo.js similarity index 100% rename from test2/elo/elo.js rename to test/elo/elo.js diff --git a/test/elo/elo.test.js b/test/elo/elo.test.js new file mode 100644 index 000000000..28aaf5c5c --- /dev/null +++ b/test/elo/elo.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const elo = require('./elo.js'); + + + test('elo is a Function', () => { + expect(elo).toBeInstanceOf(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"); + diff --git a/test2/equals/equals.js b/test/equals/equals.js similarity index 100% rename from test2/equals/equals.js rename to test/equals/equals.js diff --git a/test/equals/equals.test.js b/test/equals/equals.test.js new file mode 100644 index 000000000..4cdb12e39 --- /dev/null +++ b/test/equals/equals.test.js @@ -0,0 +1,22 @@ +const expect = require('expect'); +const equals = require('./equals.js'); + + + test('equals is a Function', () => { + expect(equals).toBeInstanceOf(Function); +}); + t.true(equals({ a: [2, {e: 3}], b: [4], c: 'foo' }, { a: [2, {e: 3}], b: [4], c: 'foo' }), "{ a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' }"); + test('[1,2,3] is equal to [1,2,3]', () => { + expect(equals([1, 2, 3], [1, 2, 3])).toBeTruthy(); +}); + test('{ a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] }', () => { + expect(equals({ a: [2, 3], b: [4] }, { a: [2, 3], b: [6] })).toBeFalsy(); +}); + test('[1,2,3] is not equal to [1,2,4]', () => { + expect(equals([1, 2, 3], [1, 2, 4])).toBeFalsy(); +}); + test('[1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match.', () => { + expect(equals([1, 2, 3], { 0: 1, 1: 2, 2: 3 })).toBeTruthy(); +}); + + diff --git a/test2/escapeHTML/escapeHTML.js b/test/escapeHTML/escapeHTML.js similarity index 100% rename from test2/escapeHTML/escapeHTML.js rename to test/escapeHTML/escapeHTML.js diff --git a/test/escapeHTML/escapeHTML.test.js b/test/escapeHTML/escapeHTML.test.js new file mode 100644 index 000000000..8d280f42e --- /dev/null +++ b/test/escapeHTML/escapeHTML.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const escapeHTML = require('./escapeHTML.js'); + + + test('escapeHTML is a Function', () => { + expect(escapeHTML).toBeInstanceOf(Function); +}); + t.equal(escapeHTML('Me & you'), '<a href="#">Me & you</a>', "Escapes a string for use in HTML"); + diff --git a/test2/escapeRegExp/escapeRegExp.js b/test/escapeRegExp/escapeRegExp.js similarity index 100% rename from test2/escapeRegExp/escapeRegExp.js rename to test/escapeRegExp/escapeRegExp.js diff --git a/test/escapeRegExp/escapeRegExp.test.js b/test/escapeRegExp/escapeRegExp.test.js new file mode 100644 index 000000000..a39ebd21e --- /dev/null +++ b/test/escapeRegExp/escapeRegExp.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const escapeRegExp = require('./escapeRegExp.js'); + + + test('escapeRegExp is a Function', () => { + expect(escapeRegExp).toBeInstanceOf(Function); +}); + t.equal(escapeRegExp('(test)'), '\\(test\\)', "Escapes a string to use in a regular expression"); + diff --git a/test2/everyNth/everyNth.js b/test/everyNth/everyNth.js similarity index 100% rename from test2/everyNth/everyNth.js rename to test/everyNth/everyNth.js diff --git a/test/everyNth/everyNth.test.js b/test/everyNth/everyNth.test.js new file mode 100644 index 000000000..4bc7aabea --- /dev/null +++ b/test/everyNth/everyNth.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const everyNth = require('./everyNth.js'); + + + test('everyNth is a Function', () => { + expect(everyNth).toBeInstanceOf(Function); +}); + t.deepEqual(everyNth([1, 2, 3, 4, 5, 6], 2), [ 2, 4, 6 ], "Returns every nth element in an array"); + diff --git a/test2/extendHex/extendHex.js b/test/extendHex/extendHex.js similarity index 100% rename from test2/extendHex/extendHex.js rename to test/extendHex/extendHex.js diff --git a/test/extendHex/extendHex.test.js b/test/extendHex/extendHex.test.js new file mode 100644 index 000000000..798dee0e6 --- /dev/null +++ b/test/extendHex/extendHex.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const extendHex = require('./extendHex.js'); + + + test('extendHex is a Function', () => { + expect(extendHex).toBeInstanceOf(Function); +}); + t.equal(extendHex('#03f'), '#0033ff', "Extends a 3-digit color code to a 6-digit color code"); + t.equal(extendHex('05a'), '#0055aa', "Extends a 3-digit color code to a 6-digit color code"); + diff --git a/test2/factorial/factorial.js b/test/factorial/factorial.js similarity index 100% rename from test2/factorial/factorial.js rename to test/factorial/factorial.js diff --git a/test/factorial/factorial.test.js b/test/factorial/factorial.test.js new file mode 100644 index 000000000..7bf338a83 --- /dev/null +++ b/test/factorial/factorial.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const factorial = require('./factorial.js'); + + + test('factorial is a Function', () => { + expect(factorial).toBeInstanceOf(Function); +}); + 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"); + diff --git a/test2/factors/factors.js b/test/factors/factors.js similarity index 100% rename from test2/factors/factors.js rename to test/factors/factors.js diff --git a/test/factors/factors.test.js b/test/factors/factors.test.js new file mode 100644 index 000000000..f25d0073a --- /dev/null +++ b/test/factors/factors.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const factors = require('./factors.js'); + + + test('factors is a Function', () => { + expect(factors).toBeInstanceOf(Function); +}); + diff --git a/test2/fibonacci/fibonacci.js b/test/fibonacci/fibonacci.js similarity index 100% rename from test2/fibonacci/fibonacci.js rename to test/fibonacci/fibonacci.js diff --git a/test/fibonacci/fibonacci.test.js b/test/fibonacci/fibonacci.test.js new file mode 100644 index 000000000..6db435ec9 --- /dev/null +++ b/test/fibonacci/fibonacci.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const fibonacci = require('./fibonacci.js'); + + + test('fibonacci is a Function', () => { + expect(fibonacci).toBeInstanceOf(Function); +}); + t.deepEqual(fibonacci(6), [0, 1, 1, 2, 3, 5], "Generates an array, containing the Fibonacci sequence"); + diff --git a/test2/fibonacciCountUntilNum/fibonacciCountUntilNum.js b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js similarity index 100% rename from test2/fibonacciCountUntilNum/fibonacciCountUntilNum.js rename to test/fibonacciCountUntilNum/fibonacciCountUntilNum.js diff --git a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js new file mode 100644 index 000000000..015094d79 --- /dev/null +++ b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const fibonacciCountUntilNum = require('./fibonacciCountUntilNum.js'); + + + test('fibonacciCountUntilNum is a Function', () => { + expect(fibonacciCountUntilNum).toBeInstanceOf(Function); +}); + diff --git a/test2/fibonacciUntilNum/fibonacciUntilNum.js b/test/fibonacciUntilNum/fibonacciUntilNum.js similarity index 100% rename from test2/fibonacciUntilNum/fibonacciUntilNum.js rename to test/fibonacciUntilNum/fibonacciUntilNum.js diff --git a/test/fibonacciUntilNum/fibonacciUntilNum.test.js b/test/fibonacciUntilNum/fibonacciUntilNum.test.js new file mode 100644 index 000000000..7ad0c0649 --- /dev/null +++ b/test/fibonacciUntilNum/fibonacciUntilNum.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const fibonacciUntilNum = require('./fibonacciUntilNum.js'); + + + test('fibonacciUntilNum is a Function', () => { + expect(fibonacciUntilNum).toBeInstanceOf(Function); +}); + diff --git a/test2/filterNonUnique/filterNonUnique.js b/test/filterNonUnique/filterNonUnique.js similarity index 100% rename from test2/filterNonUnique/filterNonUnique.js rename to test/filterNonUnique/filterNonUnique.js diff --git a/test/filterNonUnique/filterNonUnique.test.js b/test/filterNonUnique/filterNonUnique.test.js new file mode 100644 index 000000000..003c26e07 --- /dev/null +++ b/test/filterNonUnique/filterNonUnique.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const filterNonUnique = require('./filterNonUnique.js'); + + + test('filterNonUnique is a Function', () => { + expect(filterNonUnique).toBeInstanceOf(Function); +}); + t.deepEqual(filterNonUnique([1, 2, 2, 3, 4, 4, 5]), [1,3,5], "Filters out the non-unique values in an array"); + diff --git a/test2/findKey/findKey.js b/test/findKey/findKey.js similarity index 100% rename from test2/findKey/findKey.js rename to test/findKey/findKey.js diff --git a/test/findKey/findKey.test.js b/test/findKey/findKey.test.js new file mode 100644 index 000000000..44fe47811 --- /dev/null +++ b/test/findKey/findKey.test.js @@ -0,0 +1,17 @@ +const expect = require('expect'); +const findKey = require('./findKey.js'); + + + test('findKey is a Function', () => { + expect(findKey).toBeInstanceOf(Function); +}); + t.deepEqual(findKey( + { + barney: { age: 36, active: true }, + fred: { age: 40, active: false }, + pebbles: { age: 1, active: true } + }, + o => o['active'] +), 'barney', 'Returns the appropriate key'); + + diff --git a/test2/findLast/findLast.js b/test/findLast/findLast.js similarity index 100% rename from test2/findLast/findLast.js rename to test/findLast/findLast.js diff --git a/test/findLast/findLast.test.js b/test/findLast/findLast.test.js new file mode 100644 index 000000000..2435d0b09 --- /dev/null +++ b/test/findLast/findLast.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const findLast = require('./findLast.js'); + + + test('findLast is a Function', () => { + expect(findLast).toBeInstanceOf(Function); +}); + t.equal(findLast([1, 2, 3, 4], n => n % 2 === 1), 3, 'Finds last element for which the given function returns true'); + + diff --git a/test2/findLastIndex/findLastIndex.js b/test/findLastIndex/findLastIndex.js similarity index 100% rename from test2/findLastIndex/findLastIndex.js rename to test/findLastIndex/findLastIndex.js diff --git a/test/findLastIndex/findLastIndex.test.js b/test/findLastIndex/findLastIndex.test.js new file mode 100644 index 000000000..5fc425166 --- /dev/null +++ b/test/findLastIndex/findLastIndex.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const findLastIndex = require('./findLastIndex.js'); + + + test('findLastIndex is a Function', () => { + expect(findLastIndex).toBeInstanceOf(Function); +}); + t.equal(findLastIndex([1, 2, 3, 4], n => n % 2 === 1), 2, 'Finds last index for which the given function returns true'); + + diff --git a/test2/findLastKey/findLastKey.js b/test/findLastKey/findLastKey.js similarity index 100% rename from test2/findLastKey/findLastKey.js rename to test/findLastKey/findLastKey.js diff --git a/test/findLastKey/findLastKey.test.js b/test/findLastKey/findLastKey.test.js new file mode 100644 index 000000000..3ab1dc4ce --- /dev/null +++ b/test/findLastKey/findLastKey.test.js @@ -0,0 +1,17 @@ +const expect = require('expect'); +const findLastKey = require('./findLastKey.js'); + + + test('findLastKey is a Function', () => { + expect(findLastKey).toBeInstanceOf(Function); +}); + t.equal(findLastKey( + { + barney: { age: 36, active: true }, + fred: { age: 40, active: false }, + pebbles: { age: 1, active: true } + }, + o => o['active'] +), 'pebbles', 'Returns the appropriate key'); + + diff --git a/test2/flatten/flatten.js b/test/flatten/flatten.js similarity index 100% rename from test2/flatten/flatten.js rename to test/flatten/flatten.js diff --git a/test/flatten/flatten.test.js b/test/flatten/flatten.test.js new file mode 100644 index 000000000..fa1c01167 --- /dev/null +++ b/test/flatten/flatten.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const flatten = require('./flatten.js'); + + + test('flatten is a Function', () => { + expect(flatten).toBeInstanceOf(Function); +}); + t.deepEqual(flatten([1, [2], 3, 4]), [1, 2, 3, 4], "Flattens an array"); + t.deepEqual(flatten([1, [2, [3, [4, 5], 6], 7], 8], 2), [1, 2, 3, [4, 5], 6, 7, 8], "Flattens an array"); + diff --git a/test2/flattenObject/flattenObject.js b/test/flattenObject/flattenObject.js similarity index 97% rename from test2/flattenObject/flattenObject.js rename to test/flattenObject/flattenObject.js index 1a01f7f0a..9607a2fb8 100644 --- a/test2/flattenObject/flattenObject.js +++ b/test/flattenObject/flattenObject.js @@ -4,5 +4,5 @@ const pre = prefix.length ? prefix + '.' : ''; if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k)); else acc[pre + k] = obj[k]; return acc; -}, {}); +}, { module.exports = flattenObject; \ No newline at end of file diff --git a/test/flattenObject/flattenObject.test.js b/test/flattenObject/flattenObject.test.js new file mode 100644 index 000000000..2d3b9a758 --- /dev/null +++ b/test/flattenObject/flattenObject.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const flattenObject = require('./flattenObject.js'); + + + test('flattenObject is a Function', () => { + expect(flattenObject).toBeInstanceOf(Function); +}); + t.deepEqual(flattenObject({ a: { b: { c: 1 } }, d: 1 }), { 'a.b.c': 1, d: 1 }, 'Flattens an object with the paths for keys'); + t.deepEqual(flattenObject([0,1,[2,[1]],1]), { 0: 0, 1: 1, 3: 1, '2.0': 2, '2.1.0': 1 }, 'Works with arrays'); + + diff --git a/test2/flip/flip.js b/test/flip/flip.js similarity index 100% rename from test2/flip/flip.js rename to test/flip/flip.js diff --git a/test/flip/flip.test.js b/test/flip/flip.test.js new file mode 100644 index 000000000..f5b120b8c --- /dev/null +++ b/test/flip/flip.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const flip = require('./flip.js'); + + + test('flip is a Function', () => { + expect(flip).toBeInstanceOf(Function); +}); + let a = { name: 'John Smith' }; + let b = {}; + const mergeFrom = flip(Object.assign); + let mergePerson = mergeFrom.bind(null, a); + t.deepEqual(mergePerson(b), a, 'Flips argument order'); + + diff --git a/test2/forEachRight/forEachRight.js b/test/forEachRight/forEachRight.js similarity index 100% rename from test2/forEachRight/forEachRight.js rename to test/forEachRight/forEachRight.js diff --git a/test/forEachRight/forEachRight.test.js b/test/forEachRight/forEachRight.test.js new file mode 100644 index 000000000..69b66df3f --- /dev/null +++ b/test/forEachRight/forEachRight.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const forEachRight = require('./forEachRight.js'); + + + test('forEachRight is a Function', () => { + expect(forEachRight).toBeInstanceOf(Function); +}); + let output = ''; + forEachRight([1, 2, 3, 4], val => output+=val); + t.equal(output, '4321', 'Iterates over the array in reverse'); + + diff --git a/test2/forOwn/forOwn.js b/test/forOwn/forOwn.js similarity index 100% rename from test2/forOwn/forOwn.js rename to test/forOwn/forOwn.js diff --git a/test/forOwn/forOwn.test.js b/test/forOwn/forOwn.test.js new file mode 100644 index 000000000..4b6931628 --- /dev/null +++ b/test/forOwn/forOwn.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const forOwn = require('./forOwn.js'); + + + test('forOwn is a Function', () => { + expect(forOwn).toBeInstanceOf(Function); +}); + let output = []; + forOwn({ foo: 'bar', a: 1 }, v => output.push(v)); + t.deepEqual(output, ['bar', 1], 'Iterates over an element\'s key-value pairs'); + + diff --git a/test2/forOwnRight/forOwnRight.js b/test/forOwnRight/forOwnRight.js similarity index 100% rename from test2/forOwnRight/forOwnRight.js rename to test/forOwnRight/forOwnRight.js diff --git a/test/forOwnRight/forOwnRight.test.js b/test/forOwnRight/forOwnRight.test.js new file mode 100644 index 000000000..9e18b97f7 --- /dev/null +++ b/test/forOwnRight/forOwnRight.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const forOwnRight = require('./forOwnRight.js'); + + + test('forOwnRight is a Function', () => { + expect(forOwnRight).toBeInstanceOf(Function); +}); + let output = []; + forOwnRight({ foo: 'bar', a: 1 }, v => output.push(v)); + t.deepEqual(output, [1, 'bar'], 'Iterates over an element\'s key-value pairs in reverse'); + + diff --git a/test2/formatDuration/formatDuration.js b/test/formatDuration/formatDuration.js similarity index 100% rename from test2/formatDuration/formatDuration.js rename to test/formatDuration/formatDuration.js diff --git a/test/formatDuration/formatDuration.test.js b/test/formatDuration/formatDuration.test.js new file mode 100644 index 000000000..c1b9e7306 --- /dev/null +++ b/test/formatDuration/formatDuration.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const formatDuration = require('./formatDuration.js'); + + + test('formatDuration is a Function', () => { + expect(formatDuration).toBeInstanceOf(Function); +}); + t.equal(formatDuration(1001), '1 second, 1 millisecond', "Returns the human readable format of the given number of milliseconds"); + t.equal(formatDuration(34325055574), '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds', "Returns the human readable format of the given number of milliseconds"); + diff --git a/test2/fromCamelCase/fromCamelCase.js b/test/fromCamelCase/fromCamelCase.js similarity index 100% rename from test2/fromCamelCase/fromCamelCase.js rename to test/fromCamelCase/fromCamelCase.js diff --git a/test/fromCamelCase/fromCamelCase.test.js b/test/fromCamelCase/fromCamelCase.test.js new file mode 100644 index 000000000..5e89f57b6 --- /dev/null +++ b/test/fromCamelCase/fromCamelCase.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const fromCamelCase = require('./fromCamelCase.js'); + + + test('fromCamelCase is a Function', () => { + expect(fromCamelCase).toBeInstanceOf(Function); +}); + t.equal(fromCamelCase('someDatabaseFieldName', ' '), 'some database field name', "Converts a string from camelcase"); + t.equal(fromCamelCase('someLabelThatNeedsToBeCamelized', '-'), 'some-label-that-needs-to-be-camelized', "Converts a string from camelcase"); + t.equal(fromCamelCase('someJavascriptProperty', '_'), 'some_javascript_property', "Converts a string from camelcase"); + diff --git a/test2/functionName/functionName.js b/test/functionName/functionName.js similarity index 100% rename from test2/functionName/functionName.js rename to test/functionName/functionName.js diff --git a/test/functionName/functionName.test.js b/test/functionName/functionName.test.js new file mode 100644 index 000000000..e23478794 --- /dev/null +++ b/test/functionName/functionName.test.js @@ -0,0 +1,19 @@ +const expect = require('expect'); +let output = ''; +const console = {}; +console.debug = (x) => output = x; +const functionName = fn => (console.debug(fn.name), fn); + + test('functionName is a Function', () => { + expect(functionName).toBeInstanceOf(Function); +}); + functionName(Math.max); + t.equal(output, 'max', 'Works for native functions'); + function fun(x) {return x;} + functionName(fun); + t.equal(output, 'fun', 'Works for functions'); + const fn = x => x; + functionName(fn); + t.equal(output, 'fn', 'Works for arrow functions'); + + diff --git a/test2/functions/functions.js b/test/functions/functions.js similarity index 100% rename from test2/functions/functions.js rename to test/functions/functions.js diff --git a/test/functions/functions.test.js b/test/functions/functions.test.js new file mode 100644 index 000000000..eb182cbb0 --- /dev/null +++ b/test/functions/functions.test.js @@ -0,0 +1,16 @@ +const expect = require('expect'); +const functions = require('./functions.js'); + + + test('functions is a Function', () => { + expect(functions).toBeInstanceOf(Function); +}); + function Foo() { + this.a = () => 1; + this.b = () => 2; + } + Foo.prototype.c = () => 3; + t.deepEqual(functions(new Foo()), ['a', 'b'], 'Returns own methods'); + t.deepEqual(functions(new Foo(), true), ['a', 'b', 'c'], 'Returns own and inherited methods'); + + diff --git a/test2/gcd/gcd.js b/test/gcd/gcd.js similarity index 100% rename from test2/gcd/gcd.js rename to test/gcd/gcd.js diff --git a/test/gcd/gcd.test.js b/test/gcd/gcd.test.js new file mode 100644 index 000000000..70fa782f5 --- /dev/null +++ b/test/gcd/gcd.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const gcd = require('./gcd.js'); + + + test('gcd is a Function', () => { + expect(gcd).toBeInstanceOf(Function); +}); + t.equal(gcd(8, 36), 4, "Calculates the greatest common divisor between two or more numbers/arrays"); + t.deepEqual(gcd(...[12, 8, 32]), 4, "Calculates the greatest common divisor between two or more numbers/arrays"); + diff --git a/test2/geometricProgression/geometricProgression.js b/test/geometricProgression/geometricProgression.js similarity index 100% rename from test2/geometricProgression/geometricProgression.js rename to test/geometricProgression/geometricProgression.js diff --git a/test/geometricProgression/geometricProgression.test.js b/test/geometricProgression/geometricProgression.test.js new file mode 100644 index 000000000..f42e0aafb --- /dev/null +++ b/test/geometricProgression/geometricProgression.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const geometricProgression = require('./geometricProgression.js'); + + + test('geometricProgression is a Function', () => { + expect(geometricProgression).toBeInstanceOf(Function); +}); + t.deepEqual(geometricProgression(256), [1, 2, 4, 8, 16, 32, 64, 128, 256], "Initializes an array containing the numbers in the specified range"); + t.deepEqual(geometricProgression(256, 3), [3, 6, 12, 24, 48, 96, 192], "Initializes an array containing the numbers in the specified range"); + t.deepEqual(geometricProgression(256, 1, 4), [1, 4, 16, 64, 256], "Initializes an array containing the numbers in the specified range"); + diff --git a/test2/get/get.js b/test/get/get.js similarity index 100% rename from test2/get/get.js rename to test/get/get.js diff --git a/test/get/get.test.js b/test/get/get.test.js new file mode 100644 index 000000000..667f3e104 --- /dev/null +++ b/test/get/get.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const get = require('./get.js'); + + + test('get is a Function', () => { + expect(get).toBeInstanceOf(Function); +}); + const obj = { selector: { to: { val: 'val to get' } } }; + t.deepEqual(get(obj, 'selector.to.val'), ['val to get'], "Retrieve a property indicated by the selector from an object."); + + diff --git a/test2/getColonTimeFromDate/getColonTimeFromDate.js b/test/getColonTimeFromDate/getColonTimeFromDate.js similarity index 100% rename from test2/getColonTimeFromDate/getColonTimeFromDate.js rename to test/getColonTimeFromDate/getColonTimeFromDate.js diff --git a/test/getColonTimeFromDate/getColonTimeFromDate.test.js b/test/getColonTimeFromDate/getColonTimeFromDate.test.js new file mode 100644 index 000000000..1f863ae33 --- /dev/null +++ b/test/getColonTimeFromDate/getColonTimeFromDate.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const getColonTimeFromDate = require('./getColonTimeFromDate.js'); + + + test('getColonTimeFromDate is a Function', () => { + expect(getColonTimeFromDate).toBeInstanceOf(Function); +}); + diff --git a/test2/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js similarity index 100% rename from test2/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js rename to test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js diff --git a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js new file mode 100644 index 000000000..25052d94d --- /dev/null +++ b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const getDaysDiffBetweenDates = require('./getDaysDiffBetweenDates.js'); + + + test('getDaysDiffBetweenDates is a Function', () => { + expect(getDaysDiffBetweenDates).toBeInstanceOf(Function); +}); + t.equal(getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')), 9, "Returns the difference in days between two dates"); + diff --git a/test2/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.js b/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.js similarity index 100% rename from test2/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.js rename to test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.js diff --git a/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js b/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js new file mode 100644 index 000000000..f18244388 --- /dev/null +++ b/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const getMeridiemSuffixOfInteger = require('./getMeridiemSuffixOfInteger.js'); + + + test('getMeridiemSuffixOfInteger is a Function', () => { + expect(getMeridiemSuffixOfInteger).toBeInstanceOf(Function); +}); + diff --git a/test2/getScrollPosition/getScrollPosition.js b/test/getScrollPosition/getScrollPosition.js similarity index 98% rename from test2/getScrollPosition/getScrollPosition.js rename to test/getScrollPosition/getScrollPosition.js index 5bedcc1fe..ad622cf02 100644 --- a/test2/getScrollPosition/getScrollPosition.js +++ b/test/getScrollPosition/getScrollPosition.js @@ -1,5 +1,5 @@ const getScrollPosition = (el = window) => ({ x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop -}); + module.exports = getScrollPosition; \ No newline at end of file diff --git a/test/getScrollPosition/getScrollPosition.test.js b/test/getScrollPosition/getScrollPosition.test.js new file mode 100644 index 000000000..24746b482 --- /dev/null +++ b/test/getScrollPosition/getScrollPosition.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const getScrollPosition = require('./getScrollPosition.js'); + + + test('getScrollPosition is a Function', () => { + expect(getScrollPosition).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test2/getStyle/getStyle.js b/test/getStyle/getStyle.js similarity index 100% rename from test2/getStyle/getStyle.js rename to test/getStyle/getStyle.js diff --git a/test/getStyle/getStyle.test.js b/test/getStyle/getStyle.test.js new file mode 100644 index 000000000..0c50ec687 --- /dev/null +++ b/test/getStyle/getStyle.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const getStyle = require('./getStyle.js'); + + + test('getStyle is a Function', () => { + expect(getStyle).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test2/getType/getType.js b/test/getType/getType.js similarity index 100% rename from test2/getType/getType.js rename to test/getType/getType.js diff --git a/test/getType/getType.test.js b/test/getType/getType.test.js new file mode 100644 index 000000000..dedd1d8b5 --- /dev/null +++ b/test/getType/getType.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const getType = require('./getType.js'); + + + test('getType is a Function', () => { + expect(getType).toBeInstanceOf(Function); +}); + t.equal(getType(new Set([1, 2, 3])), 'set', "Returns the native type of a value"); + diff --git a/test2/getURLParameters/getURLParameters.js b/test/getURLParameters/getURLParameters.js similarity index 100% rename from test2/getURLParameters/getURLParameters.js rename to test/getURLParameters/getURLParameters.js diff --git a/test/getURLParameters/getURLParameters.test.js b/test/getURLParameters/getURLParameters.test.js new file mode 100644 index 000000000..e9e75eaa1 --- /dev/null +++ b/test/getURLParameters/getURLParameters.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const getURLParameters = require('./getURLParameters.js'); + + + test('getURLParameters is a Function', () => { + expect(getURLParameters).toBeInstanceOf(Function); +}); + t.deepEqual(getURLParameters('http: + diff --git a/test3/groupBy/groupBy.js b/test/groupBy/groupBy.js similarity index 96% rename from test3/groupBy/groupBy.js rename to test/groupBy/groupBy.js index b423945a4..2ab3ffb3d 100644 --- a/test3/groupBy/groupBy.js +++ b/test/groupBy/groupBy.js @@ -2,5 +2,5 @@ const groupBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { acc[val] = (acc[val] || []).concat(arr[i]); return acc; -}, {}); +}, { module.exports = groupBy; \ No newline at end of file diff --git a/test/groupBy/groupBy.test.js b/test/groupBy/groupBy.test.js new file mode 100644 index 000000000..194886b8d --- /dev/null +++ b/test/groupBy/groupBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const groupBy = require('./groupBy.js'); + + + test('groupBy is a Function', () => { + expect(groupBy).toBeInstanceOf(Function); +}); + t.deepEqual(groupBy([6.1, 4.2, 6.3], Math.floor), {4: [4.2], 6: [6.1, 6.3]}, "Groups the elements of an array based on the given function"); + t.deepEqual(groupBy(['one', 'two', 'three'], 'length'), {3: ['one', 'two'], 5: ['three']}, "Groups the elements of an array based on the given function"); + diff --git a/test3/hammingDistance/hammingDistance.js b/test/hammingDistance/hammingDistance.js similarity index 100% rename from test3/hammingDistance/hammingDistance.js rename to test/hammingDistance/hammingDistance.js diff --git a/test/hammingDistance/hammingDistance.test.js b/test/hammingDistance/hammingDistance.test.js new file mode 100644 index 000000000..f72b78043 --- /dev/null +++ b/test/hammingDistance/hammingDistance.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const hammingDistance = require('./hammingDistance.js'); + + + test('hammingDistance is a Function', () => { + expect(hammingDistance).toBeInstanceOf(Function); +}); + t.equal(hammingDistance(2, 3), 1, "retuns hamming disance between 2 values"); + diff --git a/test3/hasClass/hasClass.js b/test/hasClass/hasClass.js similarity index 100% rename from test3/hasClass/hasClass.js rename to test/hasClass/hasClass.js diff --git a/test/hasClass/hasClass.test.js b/test/hasClass/hasClass.test.js new file mode 100644 index 000000000..34ba77c26 --- /dev/null +++ b/test/hasClass/hasClass.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const hasClass = require('./hasClass.js'); + + + test('hasClass is a Function', () => { + expect(hasClass).toBeInstanceOf(Function); +}); + diff --git a/test3/hasFlags/hasFlags.js b/test/hasFlags/hasFlags.js similarity index 100% rename from test3/hasFlags/hasFlags.js rename to test/hasFlags/hasFlags.js diff --git a/test/hasFlags/hasFlags.test.js b/test/hasFlags/hasFlags.test.js new file mode 100644 index 000000000..a8eeb0dc3 --- /dev/null +++ b/test/hasFlags/hasFlags.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const hasFlags = require('./hasFlags.js'); + + + test('hasFlags is a Function', () => { + expect(hasFlags).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test3/hashBrowser/hashBrowser.js b/test/hashBrowser/hashBrowser.js similarity index 98% rename from test3/hashBrowser/hashBrowser.js rename to test/hashBrowser/hashBrowser.js index d7d70d6a7..c2a79576b 100644 --- a/test3/hashBrowser/hashBrowser.js +++ b/test/hashBrowser/hashBrowser.js @@ -5,5 +5,5 @@ view = new DataView(h); for (let i = 0; i < view.byteLength; i += 4) hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); return hexes.join(''); -}); + module.exports = hashBrowser; \ No newline at end of file diff --git a/test/hashBrowser/hashBrowser.test.js b/test/hashBrowser/hashBrowser.test.js new file mode 100644 index 000000000..71043e545 --- /dev/null +++ b/test/hashBrowser/hashBrowser.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const hashBrowser = require('./hashBrowser.js'); + + + test('hashBrowser is a Function', () => { + expect(hashBrowser).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test3/hashNode/hashNode.js b/test/hashNode/hashNode.js similarity index 100% rename from test3/hashNode/hashNode.js rename to test/hashNode/hashNode.js diff --git a/test/hashNode/hashNode.test.js b/test/hashNode/hashNode.test.js new file mode 100644 index 000000000..a66d989e0 --- /dev/null +++ b/test/hashNode/hashNode.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const hashNode = require('./hashNode.js'); + + + test('hashNode is a Function', () => { + expect(hashNode).toBeInstanceOf(Function); +}); + hashNode(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(v => t.equal(v, '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393', 'Produces the appropriate hash')); + + diff --git a/test3/head/head.js b/test/head/head.js similarity index 100% rename from test3/head/head.js rename to test/head/head.js diff --git a/test/head/head.test.js b/test/head/head.test.js new file mode 100644 index 000000000..3a672d76b --- /dev/null +++ b/test/head/head.test.js @@ -0,0 +1,24 @@ +const expect = require('expect'); +const head = require('./head.js'); + + + test('head is a Function', () => { + expect(head).toBeInstanceOf(Function); +}); + test('head({ a: 1234}) returns undefined', () => { + expect(head({ a: 1234}) === undefined).toBeTruthy(); +}); + t.equal(head([1, 2, 3]), 1, "head([1, 2, 3]) returns 1"); + t.equal(head({ 0: false}), false, 'head({ 0: false}) returns false'); + t.equal(head('String'), 'S', 'head(String) returns S'); + t.throws(() => head(null), 'head(null) throws an Error'); + t.throws(() => head(undefined), 'head(undefined) throws an Error'); + t.throws(() => head(), 'head() throws an Error'); + + let start = new Date().getTime(); + head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]); + let end = new Date().getTime(); + test('head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + diff --git a/test3/hexToRGB/hexToRGB.js b/test/hexToRGB/hexToRGB.js similarity index 100% rename from test3/hexToRGB/hexToRGB.js rename to test/hexToRGB/hexToRGB.js diff --git a/test/hexToRGB/hexToRGB.test.js b/test/hexToRGB/hexToRGB.test.js new file mode 100644 index 000000000..a3ffd412c --- /dev/null +++ b/test/hexToRGB/hexToRGB.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const hexToRGB = require('./hexToRGB.js'); + + + test('hexToRGB is a Function', () => { + expect(hexToRGB).toBeInstanceOf(Function); +}); + t.equal(hexToRGB('#27ae60ff'), 'rgba(39, 174, 96, 255)', "Converts a color code to a rgb() or rgba() string"); + t.equal(hexToRGB('27ae60'), 'rgb(39, 174, 96)', "Converts a color code to a rgb() or rgba() string"); + t.equal(hexToRGB('#fff'), 'rgb(255, 255, 255)', "Converts a color code to a rgb() or rgba() string"); + diff --git a/test3/hide/hide.js b/test/hide/hide.js similarity index 100% rename from test3/hide/hide.js rename to test/hide/hide.js diff --git a/test/hide/hide.test.js b/test/hide/hide.test.js new file mode 100644 index 000000000..e5cf19bdd --- /dev/null +++ b/test/hide/hide.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const hide = require('./hide.js'); + + + test('hide is a Function', () => { + expect(hide).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test3/howManyTimes/howManyTimes.js b/test/howManyTimes/howManyTimes.js similarity index 100% rename from test3/howManyTimes/howManyTimes.js rename to test/howManyTimes/howManyTimes.js diff --git a/test/howManyTimes/howManyTimes.test.js b/test/howManyTimes/howManyTimes.test.js new file mode 100644 index 000000000..c5b17e44b --- /dev/null +++ b/test/howManyTimes/howManyTimes.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const howManyTimes = require('./howManyTimes.js'); + + + test('howManyTimes is a Function', () => { + expect(howManyTimes).toBeInstanceOf(Function); +}); + diff --git a/test3/httpDelete/httpDelete.js b/test/httpDelete/httpDelete.js similarity index 100% rename from test3/httpDelete/httpDelete.js rename to test/httpDelete/httpDelete.js diff --git a/test/httpDelete/httpDelete.test.js b/test/httpDelete/httpDelete.test.js new file mode 100644 index 000000000..fc67eb414 --- /dev/null +++ b/test/httpDelete/httpDelete.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const httpDelete = require('./httpDelete.js'); + + + test('httpDelete is a Function', () => { + expect(httpDelete).toBeInstanceOf(Function); +}); + diff --git a/test3/httpGet/httpGet.js b/test/httpGet/httpGet.js similarity index 100% rename from test3/httpGet/httpGet.js rename to test/httpGet/httpGet.js diff --git a/test3/httpGet/httpGet.test.js b/test/httpGet/httpGet.test.js similarity index 80% rename from test3/httpGet/httpGet.test.js rename to test/httpGet/httpGet.test.js index 813289a70..1270778c7 100644 --- a/test3/httpGet/httpGet.test.js +++ b/test/httpGet/httpGet.test.js @@ -1,4 +1,4 @@ -const expect = require("expect"); +const expect = require('expect'); const httpGet = (url, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open('GET', url, true); @@ -7,23 +7,22 @@ const httpGet = (url, callback, err = console.error) => { request.send(); }; -test('Testing httpGet', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof httpGet === 'function').toBeTruthy(); - httpGet('https://jsonplaceholder.typicode.com/posts/1', response => { - expect(JSON.parse(response)).toEqual({ + + test('httpGet is a Function', () => { + expect(httpGet).toBeInstanceOf(Function); +}); + httpGet('https: + t.deepEqual(JSON.parse(response), { userId: 1, id: 1, title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', body: 'quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto', - }); - }); -}); -// Custom implementation of XMLHttpRequest for the requirements of this snippet. -// Based on https://github.com/driverdan/node-XMLHttpRequest + }, 'Sends a GET request'); + + + var Url = require("url"); var spawn = require("child_process").spawn; var fs = require("fs"); @@ -36,19 +35,10 @@ XMLHttpRequest = function() { var self = this; var http = require("http"); var https = require("https"); - - // Holds http.js objects var request; var response; - - // Request settings var settings = {}; - - // Disable header blacklist. - // Not part of XHR specs. var disableHeaderCheck = false; - - // Set some default headers var defaultHeaders = { "User-Agent": "node-XMLHttpRequest", "Accept": "*/*", @@ -56,10 +46,6 @@ XMLHttpRequest = function() { var headers = {}; var headersCase = {}; - - // These headers are not user setable. - // The following are allowed but banned in the spec: - // * user-agent var forbiddenRequestHeaders = [ "accept-charset", "accept-encoding", @@ -82,20 +68,13 @@ XMLHttpRequest = function() { "upgrade", "via" ]; - - // These request methods are not allowed var forbiddenRequestMethods = [ "TRACE", "TRACK", "CONNECT" ]; - - // Send flag var sendFlag = false; - // Error flag, used when errors occur or abort is called var errorFlag = false; - - // Event listeners var listeners = {}; /** @@ -111,21 +90,12 @@ XMLHttpRequest = function() { /** * Public vars */ - - // Current state this.readyState = this.UNSENT; - - // default ready state change handler in case one is not set or is set late this.onreadystatechange = null; - - // Result & response this.responseText = ""; this.responseXML = ""; this.status = null; this.statusText = null; - - // Whether cross-site Access-Control requests should be made using - // credentials such as cookies or authorization headers this.withCredentials = false; /** @@ -168,8 +138,6 @@ XMLHttpRequest = function() { this.open = function(method, url, async, user, password) { this.abort(); errorFlag = false; - - // Check for valid request method if (!isAllowedHttpMethod(method)) { throw new Error("SecurityError: Request method not allowed"); } @@ -249,7 +217,6 @@ XMLHttpRequest = function() { var result = ""; for (var i in response.headers) { - // Cookie headers are excluded if (i !== "set-cookie" && i !== "set-cookie2") { result += i + ": " + response.headers[i] + "\r\n"; } @@ -288,11 +255,9 @@ XMLHttpRequest = function() { var ssl = false, local = false; var url = Url.parse(settings.url); var host; - // Determine the server switch (url.protocol) { case "https:": ssl = true; - // SSL & non-SSL both need host, no break here. case "http:": host = url.hostname; break; @@ -310,8 +275,6 @@ XMLHttpRequest = function() { default: throw new Error("Protocol not supported."); } - - // Load files off the local filesystem (file://) if (local) { if (settings.method !== "GET") { throw new Error("XMLHttpRequest: Only GET method is supported"); @@ -326,7 +289,7 @@ XMLHttpRequest = function() { self.responseText = data; setState(self.DONE); } - }); + } else { try { this.responseText = fs.readFileSync(url.pathname, "utf8"); @@ -339,27 +302,17 @@ XMLHttpRequest = function() { return; } - - // Default to port 80. If accessing localhost on another port be sure - // to use http://localhost:port/path var port = url.port || (ssl ? 443 : 80); - // Add query string if one is used var uri = url.pathname + (url.search ? url.search : ""); - - // Set the defaults if they haven't been set for (var name in defaultHeaders) { if (!headersCase[name.toLowerCase()]) { headers[name] = defaultHeaders[name]; } } - - // Set the Host header or the server may reject the request headers.Host = host; if (!((ssl && port === 443) || port === 80)) { headers.Host += ":" + url.port; } - - // Set Basic Auth if necessary if (settings.user) { if (typeof settings.password === "undefined") { settings.password = ""; @@ -367,8 +320,6 @@ XMLHttpRequest = function() { var authBuf = new Buffer(settings.user + ":" + settings.password); headers.Authorization = "Basic " + authBuf.toString("base64"); } - - // Set content length header if (settings.method === "GET" || settings.method === "HEAD") { data = null; } else if (data) { @@ -378,8 +329,6 @@ XMLHttpRequest = function() { headers["Content-Type"] = "text/plain;charset=UTF-8"; } } else if (settings.method === "POST") { - // For a post with no data set Content-Length: 0. - // This is required by buggy servers that don't meet the specs. headers["Content-Length"] = 0; } @@ -392,35 +341,17 @@ XMLHttpRequest = function() { agent: false, withCredentials: self.withCredentials }; - - // Reset error flag errorFlag = false; - - // Handle async requests if (settings.async) { - // Use the proper protocol var doRequest = ssl ? https.request : http.request; - - // Request is being sent, set send flag sendFlag = true; - - // As per spec, this is called here for historical reasons. self.dispatchEvent("readystatechange"); - - // Handler for the response var responseHandler = function responseHandler(resp) { - // Set response var to the response we got back - // This is so it remains accessable outside this scope response = resp; - // Check for redirect - // @TODO Prevent looped redirects if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) { - // Change URL to the redirect location settings.url = response.headers.location; var url = Url.parse(settings.url); - // Set host var in case it's used later host = url.hostname; - // Options for the new request var newOptions = { hostname: url.hostname, port: url.port, @@ -429,11 +360,8 @@ XMLHttpRequest = function() { headers: headers, withCredentials: self.withCredentials }; - - // Issue the new request request = doRequest(newOptions, responseHandler).on("error", errorHandler); - request.end(); - // @TODO Check if an XHR event needs to be fired here + reques return; } @@ -443,51 +371,40 @@ XMLHttpRequest = function() { self.status = response.statusCode; response.on("data", function(chunk) { - // Make sure there's some data if (chunk) { self.responseText += chunk; } - // Don't emit state changes if the connection has been aborted. if (sendFlag) { setState(self.LOADING); } - }); + response.on("end", function() { if (sendFlag) { - // Discard the end event if the connection has been aborted setState(self.DONE); sendFlag = false; } - }); + response.on("error", function(error) { self.handleError(error); - }); + }; - - // Error handler for the request var errorHandler = function errorHandler(error) { self.handleError(error); }; - - // Create the request request = doRequest(options, responseHandler).on("error", errorHandler); - - // Node 0.4 and later won't accept empty data. Make sure it's needed. if (data) { request.write(data); } - request.end(); + reques self.dispatchEvent("loadstart"); - } else { // Synchronous - // Create a temporary file for communication with the other Node process + } else { var contentFile = ".node-xmlhttprequest-content-" + process.pid; var syncFile = ".node-xmlhttprequest-sync-" + process.pid; fs.writeFileSync(syncFile, "", "utf8"); - // The async request the other Node process executes var execString = "var http = require('http'), https = require('https'), fs = require('fs');" + "var doRequest = http" + (ssl ? "s" : "") + ".request;" + "var options = " + JSON.stringify(options) + ";" @@ -496,30 +413,26 @@ XMLHttpRequest = function() { + "response.setEncoding('utf8');" + "response.on('data', function(chunk) {" + " responseText += chunk;" - + "});" + + "" + "response.on('end', function() {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" - + "});" + + "" + "response.on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" - + "});" + + "" + "}).on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" - + "});" + + "" + (data ? "req.write('" + JSON.stringify(data).slice(1,-1).replace(/'/g, "\\'") + "');":"") + "req.end();"; - // Start the other Node Process, executing this string var syncProc = spawn(process.argv[0], ["-e", execString]); while(fs.existsSync(syncFile)) { - // Wait while the sync file is empty } var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8')); - // Kill the child process once the file has data syncProc.stdin.end(); - // Remove the temporary file fs.unlinkSync(contentFile); if (resp.err) { @@ -578,7 +491,6 @@ XMLHttpRequest = function() { if (!(event in listeners)) { listeners[event] = []; } - // Currently allows duplicate callbacks. Should it? listeners[event].push(callback); }; @@ -588,10 +500,9 @@ XMLHttpRequest = function() { */ this.removeEventListener = function(event, callback) { if (event in listeners) { - // Filter will return a new array with the callback removed listeners[event] = listeners[event].filter(function(ev) { return ev !== callback; - }); + } }; @@ -624,7 +535,6 @@ XMLHttpRequest = function() { if (self.readyState === self.DONE && !errorFlag) { self.dispatchEvent("load"); - // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie) self.dispatchEvent("loadend"); } } diff --git a/test3/httpPost/httpPost.js b/test/httpPost/httpPost.js similarity index 100% rename from test3/httpPost/httpPost.js rename to test/httpPost/httpPost.js diff --git a/test3/httpPost/httpPost.test.js b/test/httpPost/httpPost.test.js similarity index 80% rename from test3/httpPost/httpPost.test.js rename to test/httpPost/httpPost.test.js index e3367ba47..876e5a69d 100644 --- a/test3/httpPost/httpPost.test.js +++ b/test/httpPost/httpPost.test.js @@ -1,4 +1,4 @@ -const expect = require("expect"); +const expect = require('expect'); const httpPost = (url, data, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open('POST', url, true); @@ -7,22 +7,20 @@ const httpPost = (url, data, callback, err = console.error) => { request.onerror = () => err(request); request.send(data); }; -test('Testing httpPost', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof httpPost === 'function').toBeTruthy(); + + test('httpPost is a Function', () => { + expect(httpPost).toBeInstanceOf(Function); +}); const data = { title: 'foo', body: 'bar', userId: 1 }; - httpPost('https://jsonplaceholder.typicode.com/posts', JSON.stringify(data), response => { - expect(JSON.parse(response).id).toEqual(101); - }); -}); + httpPost('https: + t.deepEqual(JSON.parse(response).id, 101, 'Sends a POST request'); + + -// Custom implementation of XMLHttpRequest for the requirements of this snippet. -// Based on https://github.com/driverdan/node-XMLHttpRequest var Url = require("url"); var spawn = require("child_process").spawn; var fs = require("fs"); @@ -35,19 +33,10 @@ XMLHttpRequest = function() { var self = this; var http = require("http"); var https = require("https"); - - // Holds http.js objects var request; var response; - - // Request settings var settings = {}; - - // Disable header blacklist. - // Not part of XHR specs. var disableHeaderCheck = false; - - // Set some default headers var defaultHeaders = { "User-Agent": "node-XMLHttpRequest", "Accept": "*/*", @@ -55,10 +44,6 @@ XMLHttpRequest = function() { var headers = {}; var headersCase = {}; - - // These headers are not user setable. - // The following are allowed but banned in the spec: - // * user-agent var forbiddenRequestHeaders = [ "accept-charset", "accept-encoding", @@ -81,20 +66,13 @@ XMLHttpRequest = function() { "upgrade", "via" ]; - - // These request methods are not allowed var forbiddenRequestMethods = [ "TRACE", "TRACK", "CONNECT" ]; - - // Send flag var sendFlag = false; - // Error flag, used when errors occur or abort is called var errorFlag = false; - - // Event listeners var listeners = {}; /** @@ -110,21 +88,12 @@ XMLHttpRequest = function() { /** * Public vars */ - - // Current state this.readyState = this.UNSENT; - - // default ready state change handler in case one is not set or is set late this.onreadystatechange = null; - - // Result & response this.responseText = ""; this.responseXML = ""; this.status = null; this.statusText = null; - - // Whether cross-site Access-Control requests should be made using - // credentials such as cookies or authorization headers this.withCredentials = false; /** @@ -167,8 +136,6 @@ XMLHttpRequest = function() { this.open = function(method, url, async, user, password) { this.abort(); errorFlag = false; - - // Check for valid request method if (!isAllowedHttpMethod(method)) { throw new Error("SecurityError: Request method not allowed"); } @@ -248,7 +215,6 @@ XMLHttpRequest = function() { var result = ""; for (var i in response.headers) { - // Cookie headers are excluded if (i !== "set-cookie" && i !== "set-cookie2") { result += i + ": " + response.headers[i] + "\r\n"; } @@ -287,11 +253,9 @@ XMLHttpRequest = function() { var ssl = false, local = false; var url = Url.parse(settings.url); var host; - // Determine the server switch (url.protocol) { case "https:": ssl = true; - // SSL & non-SSL both need host, no break here. case "http:": host = url.hostname; break; @@ -309,8 +273,6 @@ XMLHttpRequest = function() { default: throw new Error("Protocol not supported."); } - - // Load files off the local filesystem (file://) if (local) { if (settings.method !== "GET") { throw new Error("XMLHttpRequest: Only GET method is supported"); @@ -325,7 +287,7 @@ XMLHttpRequest = function() { self.responseText = data; setState(self.DONE); } - }); + } else { try { this.responseText = fs.readFileSync(url.pathname, "utf8"); @@ -338,27 +300,17 @@ XMLHttpRequest = function() { return; } - - // Default to port 80. If accessing localhost on another port be sure - // to use http://localhost:port/path var port = url.port || (ssl ? 443 : 80); - // Add query string if one is used var uri = url.pathname + (url.search ? url.search : ""); - - // Set the defaults if they haven't been set for (var name in defaultHeaders) { if (!headersCase[name.toLowerCase()]) { headers[name] = defaultHeaders[name]; } } - - // Set the Host header or the server may reject the request headers.Host = host; if (!((ssl && port === 443) || port === 80)) { headers.Host += ":" + url.port; } - - // Set Basic Auth if necessary if (settings.user) { if (typeof settings.password === "undefined") { settings.password = ""; @@ -366,8 +318,6 @@ XMLHttpRequest = function() { var authBuf = new Buffer(settings.user + ":" + settings.password); headers.Authorization = "Basic " + authBuf.toString("base64"); } - - // Set content length header if (settings.method === "GET" || settings.method === "HEAD") { data = null; } else if (data) { @@ -377,8 +327,6 @@ XMLHttpRequest = function() { headers["Content-Type"] = "text/plain;charset=UTF-8"; } } else if (settings.method === "POST") { - // For a post with no data set Content-Length: 0. - // This is required by buggy servers that don't meet the specs. headers["Content-Length"] = 0; } @@ -391,35 +339,17 @@ XMLHttpRequest = function() { agent: false, withCredentials: self.withCredentials }; - - // Reset error flag errorFlag = false; - - // Handle async requests if (settings.async) { - // Use the proper protocol var doRequest = ssl ? https.request : http.request; - - // Request is being sent, set send flag sendFlag = true; - - // As per spec, this is called here for historical reasons. self.dispatchEvent("readystatechange"); - - // Handler for the response var responseHandler = function responseHandler(resp) { - // Set response var to the response we got back - // This is so it remains accessable outside this scope response = resp; - // Check for redirect - // @TODO Prevent looped redirects if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) { - // Change URL to the redirect location settings.url = response.headers.location; var url = Url.parse(settings.url); - // Set host var in case it's used later host = url.hostname; - // Options for the new request var newOptions = { hostname: url.hostname, port: url.port, @@ -428,11 +358,8 @@ XMLHttpRequest = function() { headers: headers, withCredentials: self.withCredentials }; - - // Issue the new request request = doRequest(newOptions, responseHandler).on("error", errorHandler); - request.end(); - // @TODO Check if an XHR event needs to be fired here + reques return; } @@ -442,51 +369,40 @@ XMLHttpRequest = function() { self.status = response.statusCode; response.on("data", function(chunk) { - // Make sure there's some data if (chunk) { self.responseText += chunk; } - // Don't emit state changes if the connection has been aborted. if (sendFlag) { setState(self.LOADING); } - }); + response.on("end", function() { if (sendFlag) { - // Discard the end event if the connection has been aborted setState(self.DONE); sendFlag = false; } - }); + response.on("error", function(error) { self.handleError(error); - }); + }; - - // Error handler for the request var errorHandler = function errorHandler(error) { self.handleError(error); }; - - // Create the request request = doRequest(options, responseHandler).on("error", errorHandler); - - // Node 0.4 and later won't accept empty data. Make sure it's needed. if (data) { request.write(data); } - request.end(); + reques self.dispatchEvent("loadstart"); - } else { // Synchronous - // Create a temporary file for communication with the other Node process + } else { var contentFile = ".node-xmlhttprequest-content-" + process.pid; var syncFile = ".node-xmlhttprequest-sync-" + process.pid; fs.writeFileSync(syncFile, "", "utf8"); - // The async request the other Node process executes var execString = "var http = require('http'), https = require('https'), fs = require('fs');" + "var doRequest = http" + (ssl ? "s" : "") + ".request;" + "var options = " + JSON.stringify(options) + ";" @@ -495,30 +411,26 @@ XMLHttpRequest = function() { + "response.setEncoding('utf8');" + "response.on('data', function(chunk) {" + " responseText += chunk;" - + "});" + + "" + "response.on('end', function() {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" - + "});" + + "" + "response.on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" - + "});" + + "" + "}).on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" - + "});" + + "" + (data ? "req.write('" + JSON.stringify(data).slice(1,-1).replace(/'/g, "\\'") + "');":"") + "req.end();"; - // Start the other Node Process, executing this string var syncProc = spawn(process.argv[0], ["-e", execString]); while(fs.existsSync(syncFile)) { - // Wait while the sync file is empty } var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8')); - // Kill the child process once the file has data syncProc.stdin.end(); - // Remove the temporary file fs.unlinkSync(contentFile); if (resp.err) { @@ -577,7 +489,6 @@ XMLHttpRequest = function() { if (!(event in listeners)) { listeners[event] = []; } - // Currently allows duplicate callbacks. Should it? listeners[event].push(callback); }; @@ -587,10 +498,9 @@ XMLHttpRequest = function() { */ this.removeEventListener = function(event, callback) { if (event in listeners) { - // Filter will return a new array with the callback removed listeners[event] = listeners[event].filter(function(ev) { return ev !== callback; - }); + } }; @@ -623,7 +533,6 @@ XMLHttpRequest = function() { if (self.readyState === self.DONE && !errorFlag) { self.dispatchEvent("load"); - // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie) self.dispatchEvent("loadend"); } } diff --git a/test3/httpPut/httpPut.js b/test/httpPut/httpPut.js similarity index 100% rename from test3/httpPut/httpPut.js rename to test/httpPut/httpPut.js diff --git a/test/httpPut/httpPut.test.js b/test/httpPut/httpPut.test.js new file mode 100644 index 000000000..a9beac9db --- /dev/null +++ b/test/httpPut/httpPut.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const httpPut = require('./httpPut.js'); + + + test('httpPut is a Function', () => { + expect(httpPut).toBeInstanceOf(Function); +}); + diff --git a/test/httpsRedirect/httpsRedirect.js b/test/httpsRedirect/httpsRedirect.js new file mode 100644 index 000000000..e3084f306 --- /dev/null +++ b/test/httpsRedirect/httpsRedirect.js @@ -0,0 +1,4 @@ +const httpsRedirect = () => { +if (location.protocol !== 'https:') location.replace('https: +}; +module.exports = httpsRedirect; \ No newline at end of file diff --git a/test/httpsRedirect/httpsRedirect.test.js b/test/httpsRedirect/httpsRedirect.test.js new file mode 100644 index 000000000..338c0f925 --- /dev/null +++ b/test/httpsRedirect/httpsRedirect.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const httpsRedirect = require('./httpsRedirect.js'); + + + test('httpsRedirect is a Function', () => { + expect(httpsRedirect).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test3/hz/hz.js b/test/hz/hz.js similarity index 100% rename from test3/hz/hz.js rename to test/hz/hz.js diff --git a/test/hz/hz.test.js b/test/hz/hz.test.js new file mode 100644 index 000000000..a9ae095f1 --- /dev/null +++ b/test/hz/hz.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const hz = require('./hz.js'); + + + test('hz is a Function', () => { + expect(hz).toBeInstanceOf(Function); +}); + diff --git a/test3/inRange/inRange.js b/test/inRange/inRange.js similarity index 100% rename from test3/inRange/inRange.js rename to test/inRange/inRange.js diff --git a/test/inRange/inRange.test.js b/test/inRange/inRange.test.js new file mode 100644 index 000000000..545c3991a --- /dev/null +++ b/test/inRange/inRange.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const inRange = require('./inRange.js'); + + + test('inRange is a Function', () => { + expect(inRange).toBeInstanceOf(Function); +}); + t.equal(inRange(3, 2, 5), true, "The given number falls within the given range"); + t.equal(inRange(3, 4), true, "The given number falls within the given range"); + t.equal(inRange(2, 3, 5), false, "The given number does not falls within the given range"); + t.equal(inRange(3, 2), false, "The given number does not falls within the given range"); + diff --git a/test3/indexOfAll/indexOfAll.js b/test/indexOfAll/indexOfAll.js similarity index 100% rename from test3/indexOfAll/indexOfAll.js rename to test/indexOfAll/indexOfAll.js diff --git a/test/indexOfAll/indexOfAll.test.js b/test/indexOfAll/indexOfAll.test.js new file mode 100644 index 000000000..21fbb0cf3 --- /dev/null +++ b/test/indexOfAll/indexOfAll.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const indexOfAll = require('./indexOfAll.js'); + + + test('indexOfAll is a Function', () => { + expect(indexOfAll).toBeInstanceOf(Function); +}); + t.deepEqual(indexOfAll([1, 2, 3, 1, 2, 3], 1), [0,3], "Returns all indices of val in an array"); + t.deepEqual(indexOfAll([1, 2, 3], 4), [], "Returns all indices of val in an array"); + diff --git a/test3/initial/initial.js b/test/initial/initial.js similarity index 100% rename from test3/initial/initial.js rename to test/initial/initial.js diff --git a/test/initial/initial.test.js b/test/initial/initial.test.js new file mode 100644 index 000000000..7dd301fe4 --- /dev/null +++ b/test/initial/initial.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const initial = require('./initial.js'); + + + test('initial is a Function', () => { + expect(initial).toBeInstanceOf(Function); +}); + t.deepEqual(initial([1, 2, 3]), [1, 2], "Returns all the elements of an array except the last one"); + diff --git a/test3/initialize2DArray/initialize2DArray.js b/test/initialize2DArray/initialize2DArray.js similarity index 100% rename from test3/initialize2DArray/initialize2DArray.js rename to test/initialize2DArray/initialize2DArray.js diff --git a/test/initialize2DArray/initialize2DArray.test.js b/test/initialize2DArray/initialize2DArray.test.js new file mode 100644 index 000000000..441c34a4a --- /dev/null +++ b/test/initialize2DArray/initialize2DArray.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const initialize2DArray = require('./initialize2DArray.js'); + + + test('initialize2DArray is a Function', () => { + expect(initialize2DArray).toBeInstanceOf(Function); +}); + t.deepEqual(initialize2DArray(2, 2, 0), [[0,0], [0,0]], "Initializes a 2D array of given width and height and value"); + diff --git a/test3/initializeArrayWithRange/initializeArrayWithRange.js b/test/initializeArrayWithRange/initializeArrayWithRange.js similarity index 100% rename from test3/initializeArrayWithRange/initializeArrayWithRange.js rename to test/initializeArrayWithRange/initializeArrayWithRange.js diff --git a/test/initializeArrayWithRange/initializeArrayWithRange.test.js b/test/initializeArrayWithRange/initializeArrayWithRange.test.js new file mode 100644 index 000000000..18da3a9e4 --- /dev/null +++ b/test/initializeArrayWithRange/initializeArrayWithRange.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const initializeArrayWithRange = require('./initializeArrayWithRange.js'); + + + test('initializeArrayWithRange is a Function', () => { + expect(initializeArrayWithRange).toBeInstanceOf(Function); +}); + t.deepEqual(initializeArrayWithRange(5), [0, 1, 2, 3, 4, 5], "Initializes an array containing the numbers in the specified range"); + diff --git a/test3/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js similarity index 100% rename from test3/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js rename to test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js diff --git a/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js new file mode 100644 index 000000000..0bc006ff7 --- /dev/null +++ b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const initializeArrayWithRangeRight = require('./initializeArrayWithRangeRight.js'); + + + test('initializeArrayWithRangeRight is a Function', () => { + expect(initializeArrayWithRangeRight).toBeInstanceOf(Function); +}); + diff --git a/test3/initializeArrayWithValues/initializeArrayWithValues.js b/test/initializeArrayWithValues/initializeArrayWithValues.js similarity index 100% rename from test3/initializeArrayWithValues/initializeArrayWithValues.js rename to test/initializeArrayWithValues/initializeArrayWithValues.js diff --git a/test/initializeArrayWithValues/initializeArrayWithValues.test.js b/test/initializeArrayWithValues/initializeArrayWithValues.test.js new file mode 100644 index 000000000..ee1f5ea89 --- /dev/null +++ b/test/initializeArrayWithValues/initializeArrayWithValues.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const initializeArrayWithValues = require('./initializeArrayWithValues.js'); + + + test('initializeArrayWithValues is a Function', () => { + expect(initializeArrayWithValues).toBeInstanceOf(Function); +}); + t.deepEqual(initializeArrayWithValues(5, 2), [2, 2, 2, 2, 2], "Initializes and fills an array with the specified values"); + diff --git a/test3/initializeNDArray/initializeNDArray.js b/test/initializeNDArray/initializeNDArray.js similarity index 100% rename from test3/initializeNDArray/initializeNDArray.js rename to test/initializeNDArray/initializeNDArray.js diff --git a/test/initializeNDArray/initializeNDArray.test.js b/test/initializeNDArray/initializeNDArray.test.js new file mode 100644 index 000000000..52de243ff --- /dev/null +++ b/test/initializeNDArray/initializeNDArray.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const initializeNDArray = require('./initializeNDArray.js'); + + + test('initializeNDArray is a Function', () => { + expect(initializeNDArray).toBeInstanceOf(Function); +}); + diff --git a/test3/intersection/intersection.js b/test/intersection/intersection.js similarity index 100% rename from test3/intersection/intersection.js rename to test/intersection/intersection.js diff --git a/test/intersection/intersection.test.js b/test/intersection/intersection.test.js new file mode 100644 index 000000000..e94b8df5e --- /dev/null +++ b/test/intersection/intersection.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const intersection = require('./intersection.js'); + + + test('intersection is a Function', () => { + expect(intersection).toBeInstanceOf(Function); +}); + t.deepEqual(intersection([1, 2, 3], [4, 3, 2]), [2, 3], "Returns a list of elements that exist in both arrays"); + diff --git a/test3/intersectionBy/intersectionBy.js b/test/intersectionBy/intersectionBy.js similarity index 100% rename from test3/intersectionBy/intersectionBy.js rename to test/intersectionBy/intersectionBy.js diff --git a/test/intersectionBy/intersectionBy.test.js b/test/intersectionBy/intersectionBy.test.js new file mode 100644 index 000000000..f6efdbfae --- /dev/null +++ b/test/intersectionBy/intersectionBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const intersectionBy = require('./intersectionBy.js'); + + + test('intersectionBy is a Function', () => { + expect(intersectionBy).toBeInstanceOf(Function); +}); + t.deepEqual(intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor), [2.1], 'Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both'); + + diff --git a/test3/intersectionWith/intersectionWith.js b/test/intersectionWith/intersectionWith.js similarity index 100% rename from test3/intersectionWith/intersectionWith.js rename to test/intersectionWith/intersectionWith.js diff --git a/test/intersectionWith/intersectionWith.test.js b/test/intersectionWith/intersectionWith.test.js new file mode 100644 index 000000000..28f704a38 --- /dev/null +++ b/test/intersectionWith/intersectionWith.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const intersectionWith = require('./intersectionWith.js'); + + + test('intersectionWith is a Function', () => { + expect(intersectionWith).toBeInstanceOf(Function); +}); + t.deepEqual(intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)), [1.5, 3, 0], 'Returns a list of elements that exist in both arrays, using a provided comparator function'); + + diff --git a/test3/invertKeyValues/invertKeyValues.js b/test/invertKeyValues/invertKeyValues.js similarity index 96% rename from test3/invertKeyValues/invertKeyValues.js rename to test/invertKeyValues/invertKeyValues.js index 59c52315a..7712379e2 100644 --- a/test3/invertKeyValues/invertKeyValues.js +++ b/test/invertKeyValues/invertKeyValues.js @@ -4,5 +4,5 @@ const val = fn ? fn(obj[key]) : obj[key]; acc[val] = acc[val] || []; acc[val].push(key); return acc; -}, {}); +}, { module.exports = invertKeyValues; \ No newline at end of file diff --git a/test/invertKeyValues/invertKeyValues.test.js b/test/invertKeyValues/invertKeyValues.test.js new file mode 100644 index 000000000..2619e5814 --- /dev/null +++ b/test/invertKeyValues/invertKeyValues.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const invertKeyValues = require('./invertKeyValues.js'); + + + test('invertKeyValues is a Function', () => { + expect(invertKeyValues).toBeInstanceOf(Function); +}); + t.deepEqual(invertKeyValues({ a: 1, b: 2, c: 1 }), { 1: [ 'a', 'c' ], 2: [ 'b' ] }, "invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] }"); + t.deepEqual(invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value), { group1: [ 'a', 'c' ], group2: [ 'b' ] }, "invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] }"); + diff --git a/test3/is/is.js b/test/is/is.js similarity index 100% rename from test3/is/is.js rename to test/is/is.js diff --git a/test/is/is.test.js b/test/is/is.test.js new file mode 100644 index 000000000..e1fafc039 --- /dev/null +++ b/test/is/is.test.js @@ -0,0 +1,25 @@ +const expect = require('expect'); +const is = require('./is.js'); + + + test('is is a Function', () => { + expect(is).toBeInstanceOf(Function); +}); + t.true(is(Array, [1]), `Works for arrays with data`); + t.true(is(Array, []), `Works for empty arrays`); + t.false(is(Array, {}), `Works for arrays, not objects`); + t.true(is(Object, {}), `Works for objects`); + t.true(is(Map, new Map()), `Works for maps`); + t.true(is(RegExp, /./g), `Works for regular expressions`); + t.true(is(Set, new Set()), `Works for sets`); + t.true(is(WeakMap, new WeakMap()), `Works for weak maps`); + t.true(is(WeakSet, new WeakSet()), `Works for weak sets`); + t.true(is(String, ''), `Works for strings - returns true for primitive`); + t.true(is(String, new String('')), `Works for strings - returns true when using constructor`); + t.true(is(Number, 1), `Works for numbers - returns true for primitive`); + t.true(is(Number, new Number('10')), `Works for numbers - returns true when using constructor`); + t.true(is(Boolean, false), `Works for booleans - returns true for primitive`); + t.true(is(Boolean, new Boolean(false)), `Works for booleans - returns true when using constructor`); + t.true(is(Function, () => null), `Works for functions`); + + diff --git a/test3/isAbsoluteURL/isAbsoluteURL.js b/test/isAbsoluteURL/isAbsoluteURL.js similarity index 100% rename from test3/isAbsoluteURL/isAbsoluteURL.js rename to test/isAbsoluteURL/isAbsoluteURL.js diff --git a/test/isAbsoluteURL/isAbsoluteURL.test.js b/test/isAbsoluteURL/isAbsoluteURL.test.js new file mode 100644 index 000000000..81dfb2539 --- /dev/null +++ b/test/isAbsoluteURL/isAbsoluteURL.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const isAbsoluteURL = require('./isAbsoluteURL.js'); + + + test('isAbsoluteURL is a Function', () => { + expect(isAbsoluteURL).toBeInstanceOf(Function); +}); + t.equal(isAbsoluteURL('https: + t.equal(isAbsoluteURL('ftp: + t.equal(isAbsoluteURL('/foo/bar'), false, "Given string is not an absolute URL"); + diff --git a/test3/isAnagram/isAnagram.js b/test/isAnagram/isAnagram.js similarity index 100% rename from test3/isAnagram/isAnagram.js rename to test/isAnagram/isAnagram.js diff --git a/test3/isAnagram/isAnagram.test.js b/test/isAnagram/isAnagram.test.js similarity index 56% rename from test3/isAnagram/isAnagram.test.js rename to test/isAnagram/isAnagram.test.js index 0508183a8..426050546 100644 --- a/test3/isAnagram/isAnagram.test.js +++ b/test/isAnagram/isAnagram.test.js @@ -1,12 +1,21 @@ const expect = require('expect'); const isAnagram = require('./isAnagram.js'); -test('Testing isAnagram', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isAnagram === 'function').toBeTruthy(); + + test('isAnagram is a Function', () => { + expect(isAnagram).toBeInstanceOf(Function); +}); + test('Checks valid anagram', () => { expect(isAnagram('iceman', 'cinema')).toBeTruthy(); +}); + test('Works with spaces', () => { expect(isAnagram('rail safety', 'fairy tales')).toBeTruthy(); +}); + test('Ignores case', () => { expect(isAnagram('roast beef', 'eat for BSE')).toBeTruthy(); +}); + test('Ignores special characters', () => { expect(isAnagram('Regera Dowdy', 'E. G. Deadworry')).toBeTruthy(); }); + + diff --git a/test3/isArmstrongNumber/isArmstrongNumber.js b/test/isArmstrongNumber/isArmstrongNumber.js similarity index 100% rename from test3/isArmstrongNumber/isArmstrongNumber.js rename to test/isArmstrongNumber/isArmstrongNumber.js diff --git a/test/isArmstrongNumber/isArmstrongNumber.test.js b/test/isArmstrongNumber/isArmstrongNumber.test.js new file mode 100644 index 000000000..a62809e2a --- /dev/null +++ b/test/isArmstrongNumber/isArmstrongNumber.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isArmstrongNumber = require('./isArmstrongNumber.js'); + + + test('isArmstrongNumber is a Function', () => { + expect(isArmstrongNumber).toBeInstanceOf(Function); +}); + diff --git a/test3/isArray/isArray.js b/test/isArray/isArray.js similarity index 100% rename from test3/isArray/isArray.js rename to test/isArray/isArray.js diff --git a/test/isArray/isArray.test.js b/test/isArray/isArray.test.js new file mode 100644 index 000000000..a14d72e1f --- /dev/null +++ b/test/isArray/isArray.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const isArray = require('./isArray.js'); + + + test('isArray is a Function', () => { + expect(isArray).toBeInstanceOf(Function); +}); + t.equal(isArray([1]), true, "passed value is an array"); + t.equal(isArray('array'), false, "passed value is not an array"); + diff --git a/test3/isArrayBuffer/isArrayBuffer.js b/test/isArrayBuffer/isArrayBuffer.js similarity index 100% rename from test3/isArrayBuffer/isArrayBuffer.js rename to test/isArrayBuffer/isArrayBuffer.js diff --git a/test/isArrayBuffer/isArrayBuffer.test.js b/test/isArrayBuffer/isArrayBuffer.test.js new file mode 100644 index 000000000..54471ef95 --- /dev/null +++ b/test/isArrayBuffer/isArrayBuffer.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isArrayBuffer = require('./isArrayBuffer.js'); + + + test('isArrayBuffer is a Function', () => { + expect(isArrayBuffer).toBeInstanceOf(Function); +}); + diff --git a/test3/isArrayLike/isArrayLike.js b/test/isArrayLike/isArrayLike.js similarity index 100% rename from test3/isArrayLike/isArrayLike.js rename to test/isArrayLike/isArrayLike.js diff --git a/test/isArrayLike/isArrayLike.test.js b/test/isArrayLike/isArrayLike.test.js new file mode 100644 index 000000000..253efd87d --- /dev/null +++ b/test/isArrayLike/isArrayLike.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const isArrayLike = require('./isArrayLike.js'); + + + test('isArrayLike is a Function', () => { + expect(isArrayLike).toBeInstanceOf(Function); +}); + t.equal(isArrayLike('abc'), true, 'Returns true for a string'); + t.equal(isArrayLike([1,2,3]), true, 'Returns true for an array'); + t.equal(isArrayLike(null), false, 'Returns false for null'); + + diff --git a/test3/isBoolean/isBoolean.js b/test/isBoolean/isBoolean.js similarity index 100% rename from test3/isBoolean/isBoolean.js rename to test/isBoolean/isBoolean.js diff --git a/test/isBoolean/isBoolean.test.js b/test/isBoolean/isBoolean.test.js new file mode 100644 index 000000000..68b737800 --- /dev/null +++ b/test/isBoolean/isBoolean.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const isBoolean = require('./isBoolean.js'); + + + test('isBoolean is a Function', () => { + expect(isBoolean).toBeInstanceOf(Function); +}); + t.equal(isBoolean(null), false, "passed value is not a boolean"); + t.equal(isBoolean(false), true, "passed value is not a boolean"); + diff --git a/test3/isBrowser/isBrowser.js b/test/isBrowser/isBrowser.js similarity index 100% rename from test3/isBrowser/isBrowser.js rename to test/isBrowser/isBrowser.js diff --git a/test/isBrowser/isBrowser.test.js b/test/isBrowser/isBrowser.test.js new file mode 100644 index 000000000..7296ed250 --- /dev/null +++ b/test/isBrowser/isBrowser.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isBrowser = require('./isBrowser.js'); + + + test('isBrowser is a Function', () => { + expect(isBrowser).toBeInstanceOf(Function); +}); + diff --git a/test3/isBrowserTabFocused/isBrowserTabFocused.js b/test/isBrowserTabFocused/isBrowserTabFocused.js similarity index 100% rename from test3/isBrowserTabFocused/isBrowserTabFocused.js rename to test/isBrowserTabFocused/isBrowserTabFocused.js diff --git a/test/isBrowserTabFocused/isBrowserTabFocused.test.js b/test/isBrowserTabFocused/isBrowserTabFocused.test.js new file mode 100644 index 000000000..3ec43b2db --- /dev/null +++ b/test/isBrowserTabFocused/isBrowserTabFocused.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isBrowserTabFocused = require('./isBrowserTabFocused.js'); + + + test('isBrowserTabFocused is a Function', () => { + expect(isBrowserTabFocused).toBeInstanceOf(Function); +}); + diff --git a/test3/isDivisible/isDivisible.js b/test/isDivisible/isDivisible.js similarity index 100% rename from test3/isDivisible/isDivisible.js rename to test/isDivisible/isDivisible.js diff --git a/test/isDivisible/isDivisible.test.js b/test/isDivisible/isDivisible.test.js new file mode 100644 index 000000000..741dd3f1d --- /dev/null +++ b/test/isDivisible/isDivisible.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const isDivisible = require('./isDivisible.js'); + + + test('isDivisible is a Function', () => { + expect(isDivisible).toBeInstanceOf(Function); +}); + t.equal(isDivisible(6, 3), true, 'The number 6 is divisible by 3'); + diff --git a/test3/isEmpty/isEmpty.js b/test/isEmpty/isEmpty.js similarity index 100% rename from test3/isEmpty/isEmpty.js rename to test/isEmpty/isEmpty.js diff --git a/test/isEmpty/isEmpty.test.js b/test/isEmpty/isEmpty.test.js new file mode 100644 index 000000000..21e96f65d --- /dev/null +++ b/test/isEmpty/isEmpty.test.js @@ -0,0 +1,19 @@ +const expect = require('expect'); +const isEmpty = require('./isEmpty.js'); + + + test('isEmpty is a Function', () => { + expect(isEmpty).toBeInstanceOf(Function); +}); + t.equal(isEmpty(new Map()), true, 'Returns true for empty Map'); + t.equal(isEmpty(new Set()), true, 'Returns true for empty Set'); + t.equal(isEmpty([]), true, 'Returns true for empty array'); + t.equal(isEmpty({}), true, 'Returns true for empty object'); + t.equal(isEmpty(''), true, 'Returns true for empty string'); + t.equal(isEmpty([1, 2]), false, 'Returns false for non-empty array'); + t.equal(isEmpty({ a: 1, b: 2 }), false, 'Returns false for non-empty object'); + t.equal(isEmpty('text'), false, 'Returns false for non-empty string'); + t.equal(isEmpty(123), true, 'Returns true - type is not considered a collection'); + t.equal(isEmpty(true), true, 'Returns true - type is not considered a collection'); + + diff --git a/test3/isEven/isEven.js b/test/isEven/isEven.js similarity index 100% rename from test3/isEven/isEven.js rename to test/isEven/isEven.js diff --git a/test/isEven/isEven.test.js b/test/isEven/isEven.test.js new file mode 100644 index 000000000..5065b80c8 --- /dev/null +++ b/test/isEven/isEven.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const isEven = require('./isEven.js'); + + + test('isEven is a Function', () => { + expect(isEven).toBeInstanceOf(Function); +}); + t.equal(isEven(4), true, '4 is even number'); + test('5 is not an even number', () => { + expect(isEven(5), false).toBeFalsy(); +}); + diff --git a/test3/isFunction/isFunction.js b/test/isFunction/isFunction.js similarity index 100% rename from test3/isFunction/isFunction.js rename to test/isFunction/isFunction.js diff --git a/test/isFunction/isFunction.test.js b/test/isFunction/isFunction.test.js new file mode 100644 index 000000000..030d4b73f --- /dev/null +++ b/test/isFunction/isFunction.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const isFunction = require('./isFunction.js'); + + + test('isFunction is a Function', () => { + expect(isFunction).toBeInstanceOf(Function); +}); + t.equal(isFunction(x => x), true, "passed value is a function"); + t.equal(isFunction('x'), false, "passed value is not a function"); + diff --git a/test3/isLowerCase/isLowerCase.js b/test/isLowerCase/isLowerCase.js similarity index 100% rename from test3/isLowerCase/isLowerCase.js rename to test/isLowerCase/isLowerCase.js diff --git a/test/isLowerCase/isLowerCase.test.js b/test/isLowerCase/isLowerCase.test.js new file mode 100644 index 000000000..90f795f50 --- /dev/null +++ b/test/isLowerCase/isLowerCase.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const isLowerCase = require('./isLowerCase.js'); + + + test('isLowerCase is a Function', () => { + expect(isLowerCase).toBeInstanceOf(Function); +}); + t.equal(isLowerCase('abc'), true, "passed string is a lowercase"); + t.equal(isLowerCase('a3@$'), true, "passed string is a lowercase"); + t.equal(isLowerCase('A3@$'), false, "passed value is not a lowercase"); + diff --git a/test3/isMap/isMap.js b/test/isMap/isMap.js similarity index 100% rename from test3/isMap/isMap.js rename to test/isMap/isMap.js diff --git a/test/isMap/isMap.test.js b/test/isMap/isMap.test.js new file mode 100644 index 000000000..3be014cbb --- /dev/null +++ b/test/isMap/isMap.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isMap = require('./isMap.js'); + + + test('isMap is a Function', () => { + expect(isMap).toBeInstanceOf(Function); +}); + diff --git a/test3/isNil/isNil.js b/test/isNil/isNil.js similarity index 100% rename from test3/isNil/isNil.js rename to test/isNil/isNil.js diff --git a/test/isNil/isNil.test.js b/test/isNil/isNil.test.js new file mode 100644 index 000000000..3ee0892a0 --- /dev/null +++ b/test/isNil/isNil.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const isNil = require('./isNil.js'); + + + test('isNil is a Function', () => { + expect(isNil).toBeInstanceOf(Function); +}); + t.equal(isNil(null), true, 'Returns true for null'); + t.equal(isNil(undefined), true, 'Returns true for undefined'); + t.equal(isNil(''), false, 'Returns false for an empty string'); + + diff --git a/test3/isNull/isNull.js b/test/isNull/isNull.js similarity index 100% rename from test3/isNull/isNull.js rename to test/isNull/isNull.js diff --git a/test/isNull/isNull.test.js b/test/isNull/isNull.test.js new file mode 100644 index 000000000..84ffdc594 --- /dev/null +++ b/test/isNull/isNull.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const isNull = require('./isNull.js'); + + + test('isNull is a Function', () => { + expect(isNull).toBeInstanceOf(Function); +}); + t.equal(isNull(null), true, "passed argument is a null"); + t.equal(isNull(NaN), false, "passed argument is a null"); + diff --git a/test3/isNumber/isNumber.js b/test/isNumber/isNumber.js similarity index 100% rename from test3/isNumber/isNumber.js rename to test/isNumber/isNumber.js diff --git a/test/isNumber/isNumber.test.js b/test/isNumber/isNumber.test.js new file mode 100644 index 000000000..2211dd343 --- /dev/null +++ b/test/isNumber/isNumber.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const isNumber = require('./isNumber.js'); + + + test('isNumber is a Function', () => { + expect(isNumber).toBeInstanceOf(Function); +}); + t.equal(isNumber(1), true, "passed argument is a number"); + t.equal(isNumber('1'), false, "passed argument is not a number"); + diff --git a/test3/isObject/isObject.js b/test/isObject/isObject.js similarity index 100% rename from test3/isObject/isObject.js rename to test/isObject/isObject.js diff --git a/test/isObject/isObject.test.js b/test/isObject/isObject.test.js new file mode 100644 index 000000000..a4f79d110 --- /dev/null +++ b/test/isObject/isObject.test.js @@ -0,0 +1,22 @@ +const expect = require('expect'); +const isObject = require('./isObject.js'); + + + test('isObject is a Function', () => { + expect(isObject).toBeInstanceOf(Function); +}); + + test('isObject([1, 2, 3, 4]) is a object', () => { + expect(isObject([1, 2, 3, 4])).toBeTruthy(); +}); + test('isObject([]) is a object', () => { + expect(isObject([])).toBeTruthy(); +}); + test('isObject({ a:1 }) is a object', () => { + expect(isObject({ a:1 })).toBeTruthy(); +}); + test('isObject(true) is not a object', () => { + expect(isObject(true)).toBeFalsy(); +}); + + diff --git a/test3/isObjectLike/isObjectLike.js b/test/isObjectLike/isObjectLike.js similarity index 100% rename from test3/isObjectLike/isObjectLike.js rename to test/isObjectLike/isObjectLike.js diff --git a/test/isObjectLike/isObjectLike.test.js b/test/isObjectLike/isObjectLike.test.js new file mode 100644 index 000000000..1bf9fe014 --- /dev/null +++ b/test/isObjectLike/isObjectLike.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const isObjectLike = require('./isObjectLike.js'); + + + test('isObjectLike is a Function', () => { + expect(isObjectLike).toBeInstanceOf(Function); +}); + t.equal(isObjectLike({}), true, 'Returns true for an object'); + t.equal(isObjectLike([1, 2, 3]), true, 'Returns true for an array'); + t.equal(isObjectLike(x => x), false, 'Returns false for a function'); + t.equal(isObjectLike(null), false, 'Returns false for null'); + + diff --git a/test3/isPlainObject/isPlainObject.js b/test/isPlainObject/isPlainObject.js similarity index 100% rename from test3/isPlainObject/isPlainObject.js rename to test/isPlainObject/isPlainObject.js diff --git a/test/isPlainObject/isPlainObject.test.js b/test/isPlainObject/isPlainObject.test.js new file mode 100644 index 000000000..985a1f704 --- /dev/null +++ b/test/isPlainObject/isPlainObject.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const isPlainObject = require('./isPlainObject.js'); + + + test('isPlainObject is a Function', () => { + expect(isPlainObject).toBeInstanceOf(Function); +}); + t.equal(isPlainObject({ a: 1 }), true, 'Returns true for a plain object'); + t.equal(isPlainObject(new Map()), false, 'Returns false for a Map (example of non-plain object)'); + + diff --git a/test4/isPrime/isPrime.js b/test/isPrime/isPrime.js similarity index 100% rename from test4/isPrime/isPrime.js rename to test/isPrime/isPrime.js diff --git a/test/isPrime/isPrime.test.js b/test/isPrime/isPrime.test.js new file mode 100644 index 000000000..ded341837 --- /dev/null +++ b/test/isPrime/isPrime.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const isPrime = require('./isPrime.js'); + + + test('isPrime is a Function', () => { + expect(isPrime).toBeInstanceOf(Function); +}); + t.equal(isPrime(11), true, "passed number is a prime"); + diff --git a/test4/isPrimitive/isPrimitive.js b/test/isPrimitive/isPrimitive.js similarity index 100% rename from test4/isPrimitive/isPrimitive.js rename to test/isPrimitive/isPrimitive.js diff --git a/test/isPrimitive/isPrimitive.test.js b/test/isPrimitive/isPrimitive.test.js new file mode 100644 index 000000000..edd290d1a --- /dev/null +++ b/test/isPrimitive/isPrimitive.test.js @@ -0,0 +1,25 @@ +const expect = require('expect'); +const isPrimitive = require('./isPrimitive.js'); + + + test('isPrimitive is a Function', () => { + expect(isPrimitive).toBeInstanceOf(Function); +}); + t.true(isPrimitive(null), "isPrimitive(null) is primitive"); + t.true(isPrimitive(undefined), "isPrimitive(undefined) is primitive"); + t.true(isPrimitive('string'), "isPrimitive(string) is primitive"); + t.true(isPrimitive(true), "isPrimitive(true) is primitive"); + t.true(isPrimitive(50), "isPrimitive(50) is primitive"); + t.true(isPrimitive('Hello'), "isPrimitive('Hello') is primitive"); + t.true(isPrimitive(false), "isPrimitive(false) is primitive"); + t.true(isPrimitive(Symbol()), "isPrimitive(Symbol()) is primitive"); + t.false(isPrimitive([1, 2, 3]), "isPrimitive([1, 2, 3]) is not primitive"); + t.false(isPrimitive({ a: 123 }), "isPrimitive({ a: 123 }) is not primitive"); + + let start = new Date().getTime(); + isPrimitive({ a: 123 + let end = new Date().getTime(); + test('isPrimitive({ a: 123 }) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + diff --git a/test4/isPromiseLike/isPromiseLike.js b/test/isPromiseLike/isPromiseLike.js similarity index 100% rename from test4/isPromiseLike/isPromiseLike.js rename to test/isPromiseLike/isPromiseLike.js diff --git a/test/isPromiseLike/isPromiseLike.test.js b/test/isPromiseLike/isPromiseLike.test.js new file mode 100644 index 000000000..a87ceb480 --- /dev/null +++ b/test/isPromiseLike/isPromiseLike.test.js @@ -0,0 +1,16 @@ +const expect = require('expect'); +const isPromiseLike = require('./isPromiseLike.js'); + + + test('isPromiseLike is a Function', () => { + expect(isPromiseLike).toBeInstanceOf(Function); +}); + t.equal(isPromiseLike({ + then: function() { + return ''; + } + }), true, 'Returns true for a promise-like object'); + t.equal(isPromiseLike(null), false, 'Returns false for null'); + t.equal(isPromiseLike({}), false, 'Returns false for an empty object'); + + diff --git a/test4/isRegExp/isRegExp.js b/test/isRegExp/isRegExp.js similarity index 100% rename from test4/isRegExp/isRegExp.js rename to test/isRegExp/isRegExp.js diff --git a/test/isRegExp/isRegExp.test.js b/test/isRegExp/isRegExp.test.js new file mode 100644 index 000000000..ef99fcdd0 --- /dev/null +++ b/test/isRegExp/isRegExp.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isRegExp = require('./isRegExp.js'); + + + test('isRegExp is a Function', () => { + expect(isRegExp).toBeInstanceOf(Function); +}); + diff --git a/test4/isSet/isSet.js b/test/isSet/isSet.js similarity index 100% rename from test4/isSet/isSet.js rename to test/isSet/isSet.js diff --git a/test/isSet/isSet.test.js b/test/isSet/isSet.test.js new file mode 100644 index 000000000..e5e4c3630 --- /dev/null +++ b/test/isSet/isSet.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isSet = require('./isSet.js'); + + + test('isSet is a Function', () => { + expect(isSet).toBeInstanceOf(Function); +}); + diff --git a/test4/isSimilar/isSimilar.js b/test/isSimilar/isSimilar.js similarity index 100% rename from test4/isSimilar/isSimilar.js rename to test/isSimilar/isSimilar.js diff --git a/test/isSimilar/isSimilar.test.js b/test/isSimilar/isSimilar.test.js new file mode 100644 index 000000000..f349dc7c9 --- /dev/null +++ b/test/isSimilar/isSimilar.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isSimilar = require('./isSimilar.js'); + + + test('isSimilar is a Function', () => { + expect(isSimilar).toBeInstanceOf(Function); +}); + diff --git a/test4/isSorted/isSorted.js b/test/isSorted/isSorted.js similarity index 100% rename from test4/isSorted/isSorted.js rename to test/isSorted/isSorted.js diff --git a/test/isSorted/isSorted.test.js b/test/isSorted/isSorted.test.js new file mode 100644 index 000000000..06c7f459b --- /dev/null +++ b/test/isSorted/isSorted.test.js @@ -0,0 +1,20 @@ +const expect = require('expect'); +const isSorted = require('./isSorted.js'); + + + test('isSorted is a Function', () => { + expect(isSorted).toBeInstanceOf(Function); +}); + t.equal(isSorted([0, 1, 2]), 1, 'Array is sorted in ascending order'); + t.equal(isSorted([0, 1, 2, 2]), 1, 'Array is sorted in ascending order'); + t.equal(isSorted([-4, -3, -2]), 1, 'Array is sorted in ascending order'); + t.equal(isSorted([0, 0, 1, 2]), 1, 'Array is sorted in ascending order'); + t.equal(isSorted([2, 1, 0]), -1, 'Array is sorted in descending order'); + t.equal(isSorted([2, 2, 1, 0]), -1, 'Array is sorted in descending order'); + t.equal(isSorted([-2, -3, -4]), -1, 'Array is sorted in descending order'); + t.equal(isSorted([2, 1, 0, 0]), -1, 'Array is sorted in descending order'); + t.equal(isSorted([]), undefined, 'Array is empty'); + t.equal(isSorted([1]), 0, 'Array is not sorted, direction changed in array'); + t.equal(isSorted([1, 2, 1]), 0, 'Array is not sorted, direction changed in array'); + + diff --git a/test4/isString/isString.js b/test/isString/isString.js similarity index 100% rename from test4/isString/isString.js rename to test/isString/isString.js diff --git a/test/isString/isString.test.js b/test/isString/isString.test.js new file mode 100644 index 000000000..ce50d62c7 --- /dev/null +++ b/test/isString/isString.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const isString = require('./isString.js'); + + + test('isString is a Function', () => { + expect(isString).toBeInstanceOf(Function); +}); + t.equal(isString('foo'), true, 'foo is a string'); + t.equal(isString('10'), true, '"10" is a string'); + t.equal(isString(''), true, 'Empty string is a string'); + t.equal(isString(10), false, '10 is not a string'); + t.equal(isString(true), false, 'true is not string'); + diff --git a/test4/isSymbol/isSymbol.js b/test/isSymbol/isSymbol.js similarity index 100% rename from test4/isSymbol/isSymbol.js rename to test/isSymbol/isSymbol.js diff --git a/test/isSymbol/isSymbol.test.js b/test/isSymbol/isSymbol.test.js new file mode 100644 index 000000000..e779b9500 --- /dev/null +++ b/test/isSymbol/isSymbol.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const isSymbol = require('./isSymbol.js'); + + + test('isSymbol is a Function', () => { + expect(isSymbol).toBeInstanceOf(Function); +}); + t.equal(isSymbol(Symbol('x')), true, "Checks if the given argument is a symbol"); + diff --git a/test4/isTravisCI/isTravisCI.js b/test/isTravisCI/isTravisCI.js similarity index 100% rename from test4/isTravisCI/isTravisCI.js rename to test/isTravisCI/isTravisCI.js diff --git a/test/isTravisCI/isTravisCI.test.js b/test/isTravisCI/isTravisCI.test.js new file mode 100644 index 000000000..787d4845f --- /dev/null +++ b/test/isTravisCI/isTravisCI.test.js @@ -0,0 +1,17 @@ +const expect = require('expect'); +const isTravisCI = require('./isTravisCI.js'); + + + test('isTravisCI is a Function', () => { + expect(isTravisCI).toBeInstanceOf(Function); +}); + if(isTravisCI()) + test('Running on Travis, correctly evaluates', () => { + expect(isTravisCI()).toBeTruthy(); +}); + else + test('Not running on Travis, correctly evaluates', () => { + expect(isTravisCI()).toBeFalsy(); +}); + + diff --git a/test4/isTypedArray/isTypedArray.js b/test/isTypedArray/isTypedArray.js similarity index 100% rename from test4/isTypedArray/isTypedArray.js rename to test/isTypedArray/isTypedArray.js diff --git a/test/isTypedArray/isTypedArray.test.js b/test/isTypedArray/isTypedArray.test.js new file mode 100644 index 000000000..cf37182b7 --- /dev/null +++ b/test/isTypedArray/isTypedArray.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isTypedArray = require('./isTypedArray.js'); + + + test('isTypedArray is a Function', () => { + expect(isTypedArray).toBeInstanceOf(Function); +}); + diff --git a/test4/isUndefined/isUndefined.js b/test/isUndefined/isUndefined.js similarity index 100% rename from test4/isUndefined/isUndefined.js rename to test/isUndefined/isUndefined.js diff --git a/test/isUndefined/isUndefined.test.js b/test/isUndefined/isUndefined.test.js new file mode 100644 index 000000000..01b7b9095 --- /dev/null +++ b/test/isUndefined/isUndefined.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const isUndefined = require('./isUndefined.js'); + + + test('isUndefined is a Function', () => { + expect(isUndefined).toBeInstanceOf(Function); +}); + test('Returns true for undefined', () => { + expect(isUndefined(undefined)).toBeTruthy(); +}); + + diff --git a/test4/isUpperCase/isUpperCase.js b/test/isUpperCase/isUpperCase.js similarity index 100% rename from test4/isUpperCase/isUpperCase.js rename to test/isUpperCase/isUpperCase.js diff --git a/test/isUpperCase/isUpperCase.test.js b/test/isUpperCase/isUpperCase.test.js new file mode 100644 index 000000000..a50c7aa2a --- /dev/null +++ b/test/isUpperCase/isUpperCase.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const isUpperCase = require('./isUpperCase.js'); + + + test('isUpperCase is a Function', () => { + expect(isUpperCase).toBeInstanceOf(Function); +}); + t.equal(isUpperCase('ABC'), true, 'ABC is all upper case'); + t.equal(isUpperCase('abc'), false, 'abc is not all upper case'); + t.equal(isUpperCase('A3@$'), true, 'A3@$ is all uppercase'); + diff --git a/test4/isValidJSON/isValidJSON.js b/test/isValidJSON/isValidJSON.js similarity index 100% rename from test4/isValidJSON/isValidJSON.js rename to test/isValidJSON/isValidJSON.js diff --git a/test/isValidJSON/isValidJSON.test.js b/test/isValidJSON/isValidJSON.test.js new file mode 100644 index 000000000..8ab0fd2fa --- /dev/null +++ b/test/isValidJSON/isValidJSON.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const isValidJSON = require('./isValidJSON.js'); + + + test('isValidJSON is a Function', () => { + expect(isValidJSON).toBeInstanceOf(Function); +}); + t.equal(isValidJSON('{"name":"Adam","age":20}'), true, '{"name":"Adam","age":20} is a valid JSON'); + t.equal(isValidJSON('{"name":"Adam",age:"20"}'), false, '{"name":"Adam",age:"20"} is not a valid JSON'); + t.equal(isValidJSON(null), true, 'null is a valid JSON'); + diff --git a/test4/isWeakMap/isWeakMap.js b/test/isWeakMap/isWeakMap.js similarity index 100% rename from test4/isWeakMap/isWeakMap.js rename to test/isWeakMap/isWeakMap.js diff --git a/test/isWeakMap/isWeakMap.test.js b/test/isWeakMap/isWeakMap.test.js new file mode 100644 index 000000000..6ffa40525 --- /dev/null +++ b/test/isWeakMap/isWeakMap.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isWeakMap = require('./isWeakMap.js'); + + + test('isWeakMap is a Function', () => { + expect(isWeakMap).toBeInstanceOf(Function); +}); + diff --git a/test4/isWeakSet/isWeakSet.js b/test/isWeakSet/isWeakSet.js similarity index 100% rename from test4/isWeakSet/isWeakSet.js rename to test/isWeakSet/isWeakSet.js diff --git a/test/isWeakSet/isWeakSet.test.js b/test/isWeakSet/isWeakSet.test.js new file mode 100644 index 000000000..f071c38b3 --- /dev/null +++ b/test/isWeakSet/isWeakSet.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const isWeakSet = require('./isWeakSet.js'); + + + test('isWeakSet is a Function', () => { + expect(isWeakSet).toBeInstanceOf(Function); +}); + diff --git a/test4/join/join.js b/test/join/join.js similarity index 100% rename from test4/join/join.js rename to test/join/join.js diff --git a/test/join/join.test.js b/test/join/join.test.js new file mode 100644 index 000000000..4380658a2 --- /dev/null +++ b/test/join/join.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const join = require('./join.js'); + + + test('join is a Function', () => { + expect(join).toBeInstanceOf(Function); +}); + t.deepEqual(join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'), "pen,pineapple,apple&pen", "Joins all elements of an array into a string and returns this string"); + t.deepEqual(join(['pen', 'pineapple', 'apple', 'pen'], ','), "pen,pineapple,apple,pen", "Joins all elements of an array into a string and returns this string"); + t.deepEqual(join(['pen', 'pineapple', 'apple', 'pen']), "pen,pineapple,apple,pen", "Joins all elements of an array into a string and returns this string"); + diff --git a/test4/last/last.js b/test/last/last.js similarity index 100% rename from test4/last/last.js rename to test/last/last.js diff --git a/test/last/last.test.js b/test/last/last.test.js new file mode 100644 index 000000000..f2d4081a1 --- /dev/null +++ b/test/last/last.test.js @@ -0,0 +1,24 @@ +const expect = require('expect'); +const last = require('./last.js'); + + + test('last is a Function', () => { + expect(last).toBeInstanceOf(Function); +}); + test('last({ a: 1234}) returns undefined', () => { + expect(last({ a: 1234}) === undefined).toBeTruthy(); +}); + t.equal(last([1, 2, 3]), 3, "last([1, 2, 3]) returns 3"); + t.equal(last({ 0: false}), undefined, 'last({ 0: false}) returns undefined'); + t.equal(last('String'), 'g', 'last(String) returns g'); + t.throws(() => last(null), 'last(null) throws an Error'); + t.throws(() => last(undefined), 'last(undefined) throws an Error'); + t.throws(() => last(), 'last() throws an Error'); + + let start = new Date().getTime(); + last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]); + let end = new Date().getTime(); + test('last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + diff --git a/test4/lcm/lcm.js b/test/lcm/lcm.js similarity index 100% rename from test4/lcm/lcm.js rename to test/lcm/lcm.js diff --git a/test/lcm/lcm.test.js b/test/lcm/lcm.test.js new file mode 100644 index 000000000..cf85e5970 --- /dev/null +++ b/test/lcm/lcm.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const lcm = require('./lcm.js'); + + + test('lcm is a Function', () => { + expect(lcm).toBeInstanceOf(Function); +}); + t.equal(lcm(12, 7), 84, "Returns the least common multiple of two or more numbers."); + t.equal(lcm(...[1, 3, 4, 5]), 60, "Returns the least common multiple of two or more numbers."); + diff --git a/test4/levenshteinDistance/levenshteinDistance.js b/test/levenshteinDistance/levenshteinDistance.js similarity index 100% rename from test4/levenshteinDistance/levenshteinDistance.js rename to test/levenshteinDistance/levenshteinDistance.js diff --git a/test/levenshteinDistance/levenshteinDistance.test.js b/test/levenshteinDistance/levenshteinDistance.test.js new file mode 100644 index 000000000..44ae20d78 --- /dev/null +++ b/test/levenshteinDistance/levenshteinDistance.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const levenshteinDistance = require('./levenshteinDistance.js'); + + + test('levenshteinDistance is a Function', () => { + expect(levenshteinDistance).toBeInstanceOf(Function); +}); + diff --git a/test4/longestItem/longestItem.js b/test/longestItem/longestItem.js similarity index 100% rename from test4/longestItem/longestItem.js rename to test/longestItem/longestItem.js diff --git a/test/longestItem/longestItem.test.js b/test/longestItem/longestItem.test.js new file mode 100644 index 000000000..7d2b0b6e2 --- /dev/null +++ b/test/longestItem/longestItem.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const longestItem = require('./longestItem.js'); + + + test('longestItem is a Function', () => { + expect(longestItem).toBeInstanceOf(Function); +}); + t.deepEqual(longestItem('this', 'is', 'a', 'testcase'), 'testcase', "Returns the longest object"); + diff --git a/test4/lowercaseKeys/lowercaseKeys.js b/test/lowercaseKeys/lowercaseKeys.js similarity index 94% rename from test4/lowercaseKeys/lowercaseKeys.js rename to test/lowercaseKeys/lowercaseKeys.js index 3c5901fe4..e78c5fba2 100644 --- a/test4/lowercaseKeys/lowercaseKeys.js +++ b/test/lowercaseKeys/lowercaseKeys.js @@ -2,5 +2,5 @@ const lowercaseKeys = obj => Object.keys(obj).reduce((acc, key) => { acc[key.toLowerCase()] = obj[key]; return acc; -}, {}); +}, { module.exports = lowercaseKeys; \ No newline at end of file diff --git a/test/lowercaseKeys/lowercaseKeys.test.js b/test/lowercaseKeys/lowercaseKeys.test.js new file mode 100644 index 000000000..eb0c9bd02 --- /dev/null +++ b/test/lowercaseKeys/lowercaseKeys.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const lowercaseKeys = require('./lowercaseKeys.js'); + + + test('lowercaseKeys is a Function', () => { + expect(lowercaseKeys).toBeInstanceOf(Function); +}); + const myObj = { Name: 'Adam', sUrnAME: 'Smith' }; + const myObjLower = lowercaseKeys(myObj); + t.deepEqual(myObjLower, {name: 'Adam', surname: 'Smith'}, 'Lowercases object keys'); + t.deepEqual(myObj, { Name: 'Adam', sUrnAME: 'Smith' }, 'Does not mutate original object'); + + diff --git a/test4/luhnCheck/luhnCheck.js b/test/luhnCheck/luhnCheck.js similarity index 100% rename from test4/luhnCheck/luhnCheck.js rename to test/luhnCheck/luhnCheck.js diff --git a/test/luhnCheck/luhnCheck.test.js b/test/luhnCheck/luhnCheck.test.js new file mode 100644 index 000000000..7c1647865 --- /dev/null +++ b/test/luhnCheck/luhnCheck.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const luhnCheck = require('./luhnCheck.js'); + + + test('luhnCheck is a Function', () => { + expect(luhnCheck).toBeInstanceOf(Function); +}); + t.equal(luhnCheck(6011329933655299), false, "validates identification number"); + t.equal(luhnCheck('4485275742308327'), true, "validates identification number"); + t.equal(luhnCheck(123456789), false, "validates identification number"); + diff --git a/test4/mapKeys/mapKeys.js b/test/mapKeys/mapKeys.js similarity index 94% rename from test4/mapKeys/mapKeys.js rename to test/mapKeys/mapKeys.js index 524a636c3..1600ca90e 100644 --- a/test4/mapKeys/mapKeys.js +++ b/test/mapKeys/mapKeys.js @@ -2,5 +2,5 @@ const mapKeys = (obj, fn) => Object.keys(obj).reduce((acc, k) => { acc[fn(obj[k], k, obj)] = obj[k]; return acc; -}, {}); +}, { module.exports = mapKeys; \ No newline at end of file diff --git a/test/mapKeys/mapKeys.test.js b/test/mapKeys/mapKeys.test.js new file mode 100644 index 000000000..312dadee9 --- /dev/null +++ b/test/mapKeys/mapKeys.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const mapKeys = require('./mapKeys.js'); + + + test('mapKeys is a Function', () => { + expect(mapKeys).toBeInstanceOf(Function); +}); + t.deepEqual(mapKeys({ a: 1, b: 2 }, (val, key) => key + val), { a1: 1, b2: 2 }, 'Maps keys'); + + diff --git a/test4/mapObject/mapObject.js b/test/mapObject/mapObject.js similarity index 100% rename from test4/mapObject/mapObject.js rename to test/mapObject/mapObject.js diff --git a/test/mapObject/mapObject.test.js b/test/mapObject/mapObject.test.js new file mode 100644 index 000000000..2c3b5a01d --- /dev/null +++ b/test/mapObject/mapObject.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const mapObject = require('./mapObject.js'); + + + test('mapObject is a Function', () => { + expect(mapObject).toBeInstanceOf(Function); +}); + t.deepEqual(mapObject([1, 2, 3], a => a * a), { 1: 1, 2: 4, 3: 9 }, "mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 }"); + t.deepEqual(mapObject([1, 2, 3, 4], (a, b) => b - a), { 1: -1, 2: -1, 3: -1, 4: -1 }, 'mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 }'); + t.deepEqual(mapObject([1, 2, 3, 4], (a, b) => a - b), { 1: 1, 2: 1, 3: 1, 4: 1 }, 'mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 }'); + + diff --git a/test4/mapValues/mapValues.js b/test/mapValues/mapValues.js similarity index 94% rename from test4/mapValues/mapValues.js rename to test/mapValues/mapValues.js index abec7632d..34955dbd4 100644 --- a/test4/mapValues/mapValues.js +++ b/test/mapValues/mapValues.js @@ -2,5 +2,5 @@ const mapValues = (obj, fn) => Object.keys(obj).reduce((acc, k) => { acc[k] = fn(obj[k], k, obj); return acc; -}, {}); +}, { module.exports = mapValues; \ No newline at end of file diff --git a/test/mapValues/mapValues.test.js b/test/mapValues/mapValues.test.js new file mode 100644 index 000000000..75ab17b96 --- /dev/null +++ b/test/mapValues/mapValues.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const mapValues = require('./mapValues.js'); + + + test('mapValues is a Function', () => { + expect(mapValues).toBeInstanceOf(Function); +}); + const users = { + fred: { user: 'fred', age: 40 }, + pebbles: { user: 'pebbles', age: 1 } + }; + t.deepEqual(mapValues(users, u => u.age), { fred: 40, pebbles: 1 }, 'Maps values'); + + diff --git a/test4/mask/mask.js b/test/mask/mask.js similarity index 100% rename from test4/mask/mask.js rename to test/mask/mask.js diff --git a/test/mask/mask.test.js b/test/mask/mask.test.js new file mode 100644 index 000000000..ca1fab4ab --- /dev/null +++ b/test/mask/mask.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const mask = require('./mask.js'); + + + test('mask is a Function', () => { + expect(mask).toBeInstanceOf(Function); +}); + t.equal(mask(1234567890), '******7890', "Replaces all but the last num of characters with the specified mask character"); + t.equal(mask(1234567890, 3), '*******890', "Replaces all but the last num of characters with the specified mask character"); + t.equal(mask(1234567890, -4, '$'), '$$$$567890', "Replaces all but the last num of characters with the specified mask character"); + diff --git a/test4/matches/matches.js b/test/matches/matches.js similarity index 100% rename from test4/matches/matches.js rename to test/matches/matches.js diff --git a/test/matches/matches.test.js b/test/matches/matches.test.js new file mode 100644 index 000000000..e0e33998d --- /dev/null +++ b/test/matches/matches.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const matches = require('./matches.js'); + + + test('matches is a Function', () => { + expect(matches).toBeInstanceOf(Function); +}); + test('Matches returns true for two similar objects', () => { + expect(matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true })).toBeTruthy(); +}); + test('Matches returns false for two non-similar objects', () => { + expect(matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true })).toBeFalsy(); +}); + + diff --git a/test4/matchesWith/matchesWith.js b/test/matchesWith/matchesWith.js similarity index 100% rename from test4/matchesWith/matchesWith.js rename to test/matchesWith/matchesWith.js diff --git a/test/matchesWith/matchesWith.test.js b/test/matchesWith/matchesWith.test.js new file mode 100644 index 000000000..d463b7817 --- /dev/null +++ b/test/matchesWith/matchesWith.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const matchesWith = require('./matchesWith.js'); + + + test('matchesWith is a Function', () => { + expect(matchesWith).toBeInstanceOf(Function); +}); + const isGreeting = val => /^h(?:i|ello)$/.test(val); + t.true(matchesWith( + { greeting: 'hello' }, + { greeting: 'hi' }, + (oV, sV) => isGreeting(oV) && isGreeting(sV) + ), 'Returns true for two objects with similar values, based on the provided function'); + + diff --git a/test4/maxBy/maxBy.js b/test/maxBy/maxBy.js similarity index 100% rename from test4/maxBy/maxBy.js rename to test/maxBy/maxBy.js diff --git a/test/maxBy/maxBy.test.js b/test/maxBy/maxBy.test.js new file mode 100644 index 000000000..b9866da4b --- /dev/null +++ b/test/maxBy/maxBy.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const maxBy = require('./maxBy.js'); + + + test('maxBy is a Function', () => { + expect(maxBy).toBeInstanceOf(Function); +}); + test('Produces the right result with a function', () => { + expect(maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 8).toBe() +}); + test('Produces the right result with a property name', () => { + expect(maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 8).toBe() +}); + + diff --git a/test4/maxN/maxN.js b/test/maxN/maxN.js similarity index 100% rename from test4/maxN/maxN.js rename to test/maxN/maxN.js diff --git a/test/maxN/maxN.test.js b/test/maxN/maxN.test.js new file mode 100644 index 000000000..aaad1b7c3 --- /dev/null +++ b/test/maxN/maxN.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const maxN = require('./maxN.js'); + + + test('maxN is a Function', () => { + expect(maxN).toBeInstanceOf(Function); +}); + t.deepEqual(maxN([1, 2, 3]), [3], "Returns the n maximum elements from the provided array"); + t.deepEqual(maxN([1, 2, 3], 2), [3, 2], "Returns the n maximum elements from the provided array"); + diff --git a/test4/median/median.js b/test/median/median.js similarity index 100% rename from test4/median/median.js rename to test/median/median.js diff --git a/test/median/median.test.js b/test/median/median.test.js new file mode 100644 index 000000000..da38d46cc --- /dev/null +++ b/test/median/median.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const median = require('./median.js'); + + + test('median is a Function', () => { + expect(median).toBeInstanceOf(Function); +}); + t.equal(median([5, 6, 50, 1, -5]), 5, "Returns the median of an array of numbers"); + t.equal(median([1, 2, 3]), 2, "Returns the median of an array of numbers"); + diff --git a/test4/memoize/memoize.js b/test/memoize/memoize.js similarity index 100% rename from test4/memoize/memoize.js rename to test/memoize/memoize.js diff --git a/test/memoize/memoize.test.js b/test/memoize/memoize.test.js new file mode 100644 index 000000000..f646ed27a --- /dev/null +++ b/test/memoize/memoize.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const memoize = require('./memoize.js'); + + + test('memoize is a Function', () => { + expect(memoize).toBeInstanceOf(Function); +}); + const f = x => x * x; + const square = memoize(f); + t.equal(square(2), 4, 'Function works properly'); + t.equal(square(3), 9, 'Function works properly'); + t.deepEqual(Array.from(square.cache), [[2,4],[3,9]], 'Cache stores values'); + + diff --git a/test4/merge/merge.js b/test/merge/merge.js similarity index 100% rename from test4/merge/merge.js rename to test/merge/merge.js diff --git a/test/merge/merge.test.js b/test/merge/merge.test.js new file mode 100644 index 000000000..337c466ca --- /dev/null +++ b/test/merge/merge.test.js @@ -0,0 +1,19 @@ +const expect = require('expect'); +const merge = require('./merge.js'); + + + test('merge is a Function', () => { + expect(merge).toBeInstanceOf(Function); +}); + const object = { + a: [{ x: 2 }, { y: 4 }], + b: 1 + }; + const other = { + a: { z: 3 }, + b: [2, 3], + c: 'foo' + }; + t.deepEqual(merge(object, other), { a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ], c: 'foo' }, 'Merges two objects'); + + diff --git a/test4/minBy/minBy.js b/test/minBy/minBy.js similarity index 100% rename from test4/minBy/minBy.js rename to test/minBy/minBy.js diff --git a/test/minBy/minBy.test.js b/test/minBy/minBy.test.js new file mode 100644 index 000000000..dfd8ba57a --- /dev/null +++ b/test/minBy/minBy.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const minBy = require('./minBy.js'); + + + test('minBy is a Function', () => { + expect(minBy).toBeInstanceOf(Function); +}); + test('Produces the right result with a function', () => { + expect(minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 2).toBe() +}); + test('Produces the right result with a property name', () => { + expect(minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 2).toBe() +}); + + diff --git a/test4/minN/minN.js b/test/minN/minN.js similarity index 100% rename from test4/minN/minN.js rename to test/minN/minN.js diff --git a/test/minN/minN.test.js b/test/minN/minN.test.js new file mode 100644 index 000000000..5f171662d --- /dev/null +++ b/test/minN/minN.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const minN = require('./minN.js'); + + + test('minN is a Function', () => { + expect(minN).toBeInstanceOf(Function); +}); + t.deepEqual(minN([1, 2, 3]), [1], "Returns the n minimum elements from the provided array"); + t.deepEqual(minN([1, 2, 3], 2), [1, 2], "Returns the n minimum elements from the provided array"); + diff --git a/test4/mostPerformant/mostPerformant.js b/test/mostPerformant/mostPerformant.js similarity index 98% rename from test4/mostPerformant/mostPerformant.js rename to test/mostPerformant/mostPerformant.js index ae084a5cf..f1764e058 100644 --- a/test4/mostPerformant/mostPerformant.js +++ b/test/mostPerformant/mostPerformant.js @@ -3,7 +3,7 @@ const times = fns.map(fn => { const before = performance.now(); for (let i = 0; i < iterations; i++) fn(); return performance.now() - before; -}); + return times.indexOf(Math.min(...times)); }; module.exports = mostPerformant; \ No newline at end of file diff --git a/test/mostPerformant/mostPerformant.test.js b/test/mostPerformant/mostPerformant.test.js new file mode 100644 index 000000000..cffb718a6 --- /dev/null +++ b/test/mostPerformant/mostPerformant.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const mostPerformant = require('./mostPerformant.js'); + + + test('mostPerformant is a Function', () => { + expect(mostPerformant).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test4/negate/negate.js b/test/negate/negate.js similarity index 100% rename from test4/negate/negate.js rename to test/negate/negate.js diff --git a/test/negate/negate.test.js b/test/negate/negate.test.js new file mode 100644 index 000000000..1787751a9 --- /dev/null +++ b/test/negate/negate.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const negate = require('./negate.js'); + + + test('negate is a Function', () => { + expect(negate).toBeInstanceOf(Function); +}); + t.deepEqual([1, 2, 3, 4, 5, 6].filter(negate(n => n % 2 === 0)), [1, 3, 5], "Negates a predicate function"); + + diff --git a/test4/nest/nest.js b/test/nest/nest.js similarity index 100% rename from test4/nest/nest.js rename to test/nest/nest.js diff --git a/test/nest/nest.test.js b/test/nest/nest.test.js new file mode 100644 index 000000000..65649a3c8 --- /dev/null +++ b/test/nest/nest.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const nest = require('./nest.js'); + + + test('nest is a Function', () => { + expect(nest).toBeInstanceOf(Function); +}); + diff --git a/test4/nodeListToArray/nodeListToArray.js b/test/nodeListToArray/nodeListToArray.js similarity index 100% rename from test4/nodeListToArray/nodeListToArray.js rename to test/nodeListToArray/nodeListToArray.js diff --git a/test/nodeListToArray/nodeListToArray.test.js b/test/nodeListToArray/nodeListToArray.test.js new file mode 100644 index 000000000..175ce6cc7 --- /dev/null +++ b/test/nodeListToArray/nodeListToArray.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const nodeListToArray = require('./nodeListToArray.js'); + + + test('nodeListToArray is a Function', () => { + expect(nodeListToArray).toBeInstanceOf(Function); +}); + diff --git a/test4/none/none.js b/test/none/none.js similarity index 100% rename from test4/none/none.js rename to test/none/none.js diff --git a/test/none/none.test.js b/test/none/none.test.js new file mode 100644 index 000000000..89a701c87 --- /dev/null +++ b/test/none/none.test.js @@ -0,0 +1,21 @@ +const expect = require('expect'); +const none = require('./none.js'); + + + test('none is a Function', () => { + expect(none).toBeInstanceOf(Function); +}); + test('Returns true for arrays with no truthy values', () => { + expect(none([0,undefined,NaN,null,''])).toBeTruthy(); +}); + test('Returns false for arrays with at least one truthy value', () => { + expect(none([0,1])).toBeFalsy(); +}); + test('Returns true with a predicate function', () => { + expect(none([4,1,0,3], x => x < 0)).toBeTruthy(); +}); + test('Returns false with predicate function', () => { + expect(none([0,1,2], x => x === 1)).toBeFalsy(); +}); + + diff --git a/test4/nthArg/nthArg.js b/test/nthArg/nthArg.js similarity index 100% rename from test4/nthArg/nthArg.js rename to test/nthArg/nthArg.js diff --git a/test/nthArg/nthArg.test.js b/test/nthArg/nthArg.test.js new file mode 100644 index 000000000..edbce4300 --- /dev/null +++ b/test/nthArg/nthArg.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const nthArg = require('./nthArg.js'); + + + test('nthArg is a Function', () => { + expect(nthArg).toBeInstanceOf(Function); +}); + const third = nthArg(2); + t.equal(third(1, 2, 3), 3, 'Returns the nth argument'); + t.equal(third(1, 2), undefined, 'Returns undefined if arguments too few'); + const last = nthArg(-1); + t.equal(last(1, 2, 3, 4, 5), 5, 'Works for negative values'); + + diff --git a/test4/nthElement/nthElement.js b/test/nthElement/nthElement.js similarity index 100% rename from test4/nthElement/nthElement.js rename to test/nthElement/nthElement.js diff --git a/test/nthElement/nthElement.test.js b/test/nthElement/nthElement.test.js new file mode 100644 index 000000000..4a0f701b5 --- /dev/null +++ b/test/nthElement/nthElement.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const nthElement = require('./nthElement.js'); + + + test('nthElement is a Function', () => { + expect(nthElement).toBeInstanceOf(Function); +}); + t.equal(nthElement(['a', 'b', 'c'], 1), 'b', "Returns the nth element of an array."); + t.equal(nthElement(['a', 'b', 'c'], -3), 'a', "Returns the nth element of an array."); + diff --git a/test4/objectFromPairs/objectFromPairs.js b/test/objectFromPairs/objectFromPairs.js similarity index 85% rename from test4/objectFromPairs/objectFromPairs.js rename to test/objectFromPairs/objectFromPairs.js index fa1f3fe47..ba14b229f 100644 --- a/test4/objectFromPairs/objectFromPairs.js +++ b/test/objectFromPairs/objectFromPairs.js @@ -1,2 +1,2 @@ -const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {}); +const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), { module.exports = objectFromPairs; \ No newline at end of file diff --git a/test/objectFromPairs/objectFromPairs.test.js b/test/objectFromPairs/objectFromPairs.test.js new file mode 100644 index 000000000..f158cd137 --- /dev/null +++ b/test/objectFromPairs/objectFromPairs.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const objectFromPairs = require('./objectFromPairs.js'); + + + test('objectFromPairs is a Function', () => { + expect(objectFromPairs).toBeInstanceOf(Function); +}); + t.deepEqual(objectFromPairs([['a', 1], ['b', 2]]), {a: 1, b: 2}, "Creates an object from the given key-value pairs."); + diff --git a/test4/objectToPairs/objectToPairs.js b/test/objectToPairs/objectToPairs.js similarity index 100% rename from test4/objectToPairs/objectToPairs.js rename to test/objectToPairs/objectToPairs.js diff --git a/test/objectToPairs/objectToPairs.test.js b/test/objectToPairs/objectToPairs.test.js new file mode 100644 index 000000000..cc7b858d5 --- /dev/null +++ b/test/objectToPairs/objectToPairs.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const objectToPairs = require('./objectToPairs.js'); + + + test('objectToPairs is a Function', () => { + expect(objectToPairs).toBeInstanceOf(Function); +}); + t.deepEqual(objectToPairs({ a: 1, b: 2 }), [['a',1],['b',2]], "Creates an array of key-value pair arrays from an object."); + diff --git a/test4/observeMutations/observeMutations.js b/test/observeMutations/observeMutations.js similarity index 100% rename from test4/observeMutations/observeMutations.js rename to test/observeMutations/observeMutations.js diff --git a/test/observeMutations/observeMutations.test.js b/test/observeMutations/observeMutations.test.js new file mode 100644 index 000000000..9de9fd425 --- /dev/null +++ b/test/observeMutations/observeMutations.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const observeMutations = require('./observeMutations.js'); + + + test('observeMutations is a Function', () => { + expect(observeMutations).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test4/off/off.js b/test/off/off.js similarity index 100% rename from test4/off/off.js rename to test/off/off.js diff --git a/test/off/off.test.js b/test/off/off.test.js new file mode 100644 index 000000000..ab48b3167 --- /dev/null +++ b/test/off/off.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const off = require('./off.js'); + + + test('off is a Function', () => { + expect(off).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test4/offset/offset.js b/test/offset/offset.js similarity index 100% rename from test4/offset/offset.js rename to test/offset/offset.js diff --git a/test/offset/offset.test.js b/test/offset/offset.test.js new file mode 100644 index 000000000..cf2622bf1 --- /dev/null +++ b/test/offset/offset.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const offset = require('./offset.js'); + + + test('offset is a Function', () => { + expect(offset).toBeInstanceOf(Function); +}); + t.deepEqual(offset([1, 2, 3, 4, 5], 0), [1, 2, 3, 4, 5], 'Offset of 0 returns the same array.'); + t.deepEqual(offset([1, 2, 3, 4, 5], 2), [3, 4, 5, 1, 2], 'Offset > 0 returns the offsetted array.'); + t.deepEqual(offset([1, 2, 3, 4, 5], -2), [4, 5, 1, 2, 3], 'Offset < 0 returns the reverse offsetted array.'); + t.deepEqual(offset([1, 2, 3, 4, 5], 6),[1, 2, 3, 4, 5], 'Offset greater than the length of the array returns the same array.'); + t.deepEqual(offset([1, 2, 3, 4, 5], -6), [1, 2, 3, 4, 5], 'Offset less than the negative length of the array returns the same array.'); + t.deepEqual(offset([], 3), [], 'Offsetting empty array returns an empty array.'); + + diff --git a/test4/omit/omit.js b/test/omit/omit.js similarity index 62% rename from test4/omit/omit.js rename to test/omit/omit.js index ffdbcbd82..d86c40009 100644 --- a/test4/omit/omit.js +++ b/test/omit/omit.js @@ -1,5 +1,5 @@ const omit = (obj, arr) => Object.keys(obj) .filter(k => !arr.includes(k)) -.reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); +.reduce((acc, key) => ((acc[key] = obj[key]), acc), { module.exports = omit; \ No newline at end of file diff --git a/test/omit/omit.test.js b/test/omit/omit.test.js new file mode 100644 index 000000000..3629dfc96 --- /dev/null +++ b/test/omit/omit.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const omit = require('./omit.js'); + + + test('omit is a Function', () => { + expect(omit).toBeInstanceOf(Function); +}); + t.deepEqual(omit({ a: 1, b: '2', c: 3 }, ['b']), { 'a': 1, 'c': 3 }, 'Omits the key-value pairs corresponding to the given keys from an object'); + + diff --git a/test5/omitBy/omitBy.js b/test/omitBy/omitBy.js similarity index 63% rename from test5/omitBy/omitBy.js rename to test/omitBy/omitBy.js index 5937a3d8a..ae8328ef9 100644 --- a/test5/omitBy/omitBy.js +++ b/test/omitBy/omitBy.js @@ -1,5 +1,5 @@ const omitBy = (obj, fn) => Object.keys(obj) .filter(k => !fn(obj[k], k)) -.reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); +.reduce((acc, key) => ((acc[key] = obj[key]), acc), { module.exports = omitBy; \ No newline at end of file diff --git a/test/omitBy/omitBy.test.js b/test/omitBy/omitBy.test.js new file mode 100644 index 000000000..586bbd6b9 --- /dev/null +++ b/test/omitBy/omitBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const omitBy = require('./omitBy.js'); + + + test('omitBy is a Function', () => { + expect(omitBy).toBeInstanceOf(Function); +}); + t.deepEqual(omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'), { b: '2' }, 'Creates an object composed of the properties the given function returns falsey for'); + + diff --git a/test5/on/on.js b/test/on/on.js similarity index 100% rename from test5/on/on.js rename to test/on/on.js diff --git a/test/on/on.test.js b/test/on/on.test.js new file mode 100644 index 000000000..8496fd977 --- /dev/null +++ b/test/on/on.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const on = require('./on.js'); + + + test('on is a Function', () => { + expect(on).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test5/onUserInputChange/onUserInputChange.js b/test/onUserInputChange/onUserInputChange.js similarity index 99% rename from test5/onUserInputChange/onUserInputChange.js rename to test/onUserInputChange/onUserInputChange.js index 5cb956112..aea7639a8 100644 --- a/test5/onUserInputChange/onUserInputChange.js +++ b/test/onUserInputChange/onUserInputChange.js @@ -10,6 +10,6 @@ lastTime = now; document.addEventListener('touchstart', () => { if (type === 'touch') return; (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); -}); + }; module.exports = onUserInputChange; \ No newline at end of file diff --git a/test/onUserInputChange/onUserInputChange.test.js b/test/onUserInputChange/onUserInputChange.test.js new file mode 100644 index 000000000..a31a50a88 --- /dev/null +++ b/test/onUserInputChange/onUserInputChange.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const onUserInputChange = require('./onUserInputChange.js'); + + + test('onUserInputChange is a Function', () => { + expect(onUserInputChange).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test5/once/once.js b/test/once/once.js similarity index 100% rename from test5/once/once.js rename to test/once/once.js diff --git a/test/once/once.test.js b/test/once/once.test.js new file mode 100644 index 000000000..c8ea9c9e9 --- /dev/null +++ b/test/once/once.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const once = require('./once.js'); + + + test('once is a Function', () => { + expect(once).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test5/orderBy/orderBy.js b/test/orderBy/orderBy.js similarity index 100% rename from test5/orderBy/orderBy.js rename to test/orderBy/orderBy.js diff --git a/test/orderBy/orderBy.test.js b/test/orderBy/orderBy.test.js new file mode 100644 index 000000000..82cc69fe2 --- /dev/null +++ b/test/orderBy/orderBy.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const orderBy = require('./orderBy.js'); + + + test('orderBy is a Function', () => { + expect(orderBy).toBeInstanceOf(Function); +}); + const users = [{ name: 'fred', age: 48 }, { name: 'barney', age: 36 }, { name: 'fred', age: 40 }]; + t.deepEqual(orderBy(users, ['name', 'age'], ['asc', 'desc']), [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}], "Returns a sorted array of objects ordered by properties and orders."); + t.deepEqual(orderBy(users, ['name', 'age']), [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}], "Returns a sorted array of objects ordered by properties and orders."); + diff --git a/test5/over/over.js b/test/over/over.js similarity index 100% rename from test5/over/over.js rename to test/over/over.js diff --git a/test/over/over.test.js b/test/over/over.test.js new file mode 100644 index 000000000..8ed724cfb --- /dev/null +++ b/test/over/over.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const over = require('./over.js'); + + + test('over is a Function', () => { + expect(over).toBeInstanceOf(Function); +}); + const minMax = over(Math.min, Math.max); + t.deepEqual(minMax(1, 2, 3, 4, 5), [1,5], 'Applies given functions over multiple arguments'); + + diff --git a/test5/overArgs/overArgs.js b/test/overArgs/overArgs.js similarity index 100% rename from test5/overArgs/overArgs.js rename to test/overArgs/overArgs.js diff --git a/test/overArgs/overArgs.test.js b/test/overArgs/overArgs.test.js new file mode 100644 index 000000000..19cce2cfa --- /dev/null +++ b/test/overArgs/overArgs.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const overArgs = require('./overArgs.js'); + + + test('overArgs is a Function', () => { + expect(overArgs).toBeInstanceOf(Function); +}); + const square = n => n * n; + const double = n => n * 2; + const fn = overArgs((x, y) => [x, y], [square, double]); + t.deepEqual(fn(9, 3), [81, 6], 'Invokes the provided function with its arguments transformed'); + + diff --git a/test5/pad/pad.js b/test/pad/pad.js similarity index 100% rename from test5/pad/pad.js rename to test/pad/pad.js diff --git a/test/pad/pad.test.js b/test/pad/pad.test.js new file mode 100644 index 000000000..f01524b50 --- /dev/null +++ b/test/pad/pad.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const pad = require('./pad.js'); + + + test('pad is a Function', () => { + expect(pad).toBeInstanceOf(Function); +}); + t.equal(pad('cat',8), ' cat ', 'cat is padded on both sides'); + t.equal(pad('cat',8).length, 8, 'length of string is 8'); + t.equal(pad(String(42), 6, '0'), '004200', 'pads 42 with "0"'); + t.equal(pad('foobar', 3), 'foobar', 'does not truncates if string exceeds length'); + + diff --git a/test5/palindrome/palindrome.js b/test/palindrome/palindrome.js similarity index 100% rename from test5/palindrome/palindrome.js rename to test/palindrome/palindrome.js diff --git a/test/palindrome/palindrome.test.js b/test/palindrome/palindrome.test.js new file mode 100644 index 000000000..559ea76b4 --- /dev/null +++ b/test/palindrome/palindrome.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const palindrome = require('./palindrome.js'); + + + test('palindrome is a Function', () => { + expect(palindrome).toBeInstanceOf(Function); +}); + t.equal(palindrome('taco cat'), true, "Given string is a palindrome"); + t.equal(palindrome('foobar'), false, "Given string is not a palindrome"); + diff --git a/test5/parseCookie/parseCookie.js b/test/parseCookie/parseCookie.js similarity index 96% rename from test5/parseCookie/parseCookie.js rename to test/parseCookie/parseCookie.js index 9e620bfe0..4a36c778c 100644 --- a/test5/parseCookie/parseCookie.js +++ b/test/parseCookie/parseCookie.js @@ -5,5 +5,5 @@ str .reduce((acc, v) => { acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); return acc; -}, {}); +}, { module.exports = parseCookie; \ No newline at end of file diff --git a/test/parseCookie/parseCookie.test.js b/test/parseCookie/parseCookie.test.js new file mode 100644 index 000000000..b1c64e056 --- /dev/null +++ b/test/parseCookie/parseCookie.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const parseCookie = require('./parseCookie.js'); + + + test('parseCookie is a Function', () => { + expect(parseCookie).toBeInstanceOf(Function); +}); + t.deepEqual(parseCookie('foo=bar; equation=E%3Dmc%5E2'), { foo: 'bar', equation: 'E=mc^2' }, 'Parses the cookie'); + + diff --git a/test5/partial/partial.js b/test/partial/partial.js similarity index 100% rename from test5/partial/partial.js rename to test/partial/partial.js diff --git a/test/partial/partial.test.js b/test/partial/partial.test.js new file mode 100644 index 000000000..d9dc5dbf5 --- /dev/null +++ b/test/partial/partial.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const partial = require('./partial.js'); + + + test('partial is a Function', () => { + expect(partial).toBeInstanceOf(Function); +}); + function greet(greeting, name) { + return greeting + ' ' + name + '!'; + } + const greetHello = partial(greet, 'Hello'); + t.equal(greetHello('John'), 'Hello John!', 'Prepends arguments'); + + diff --git a/test5/partialRight/partialRight.js b/test/partialRight/partialRight.js similarity index 100% rename from test5/partialRight/partialRight.js rename to test/partialRight/partialRight.js diff --git a/test/partialRight/partialRight.test.js b/test/partialRight/partialRight.test.js new file mode 100644 index 000000000..d5e29fe1a --- /dev/null +++ b/test/partialRight/partialRight.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const partialRight = require('./partialRight.js'); + + + test('partialRight is a Function', () => { + expect(partialRight).toBeInstanceOf(Function); +}); + function greet(greeting, name) { + return greeting + ' ' + name + '!'; + } + const greetJohn = partialRight(greet, 'John'); + t.equal(greetJohn('Hello'), 'Hello John!', 'Appends arguments'); + + diff --git a/test5/partition/partition.js b/test/partition/partition.js similarity index 100% rename from test5/partition/partition.js rename to test/partition/partition.js diff --git a/test/partition/partition.test.js b/test/partition/partition.test.js new file mode 100644 index 000000000..958a9786d --- /dev/null +++ b/test/partition/partition.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const partition = require('./partition.js'); + + + test('partition is a Function', () => { + expect(partition).toBeInstanceOf(Function); +}); + const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }]; + t.deepEqual(partition(users, o => o.active), [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]], "Groups the elements into two arrays, depending on the provided function's truthiness for each element."); + diff --git a/test5/percentile/percentile.js b/test/percentile/percentile.js similarity index 100% rename from test5/percentile/percentile.js rename to test/percentile/percentile.js diff --git a/test/percentile/percentile.test.js b/test/percentile/percentile.test.js new file mode 100644 index 000000000..b3288143c --- /dev/null +++ b/test/percentile/percentile.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const percentile = require('./percentile.js'); + + + test('percentile is a Function', () => { + expect(percentile).toBeInstanceOf(Function); +}); + t.equal(percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6), 55, "Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value."); + diff --git a/test5/permutations/permutations.js b/test/permutations/permutations.js similarity index 100% rename from test5/permutations/permutations.js rename to test/permutations/permutations.js diff --git a/test/permutations/permutations.test.js b/test/permutations/permutations.test.js new file mode 100644 index 000000000..3b1ffac73 --- /dev/null +++ b/test/permutations/permutations.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const permutations = require('./permutations.js'); + + + test('permutations is a Function', () => { + expect(permutations).toBeInstanceOf(Function); +}); + t.deepEqual(permutations([1, 33, 5]), [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ], 'Generates all permutations of an array'); + + diff --git a/test5/pick/pick.js b/test/pick/pick.js similarity index 88% rename from test5/pick/pick.js rename to test/pick/pick.js index 28e8caac7..305fc06af 100644 --- a/test5/pick/pick.js +++ b/test/pick/pick.js @@ -1,3 +1,3 @@ const pick = (obj, arr) => -arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); +arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), { module.exports = pick; \ No newline at end of file diff --git a/test/pick/pick.test.js b/test/pick/pick.test.js new file mode 100644 index 000000000..418f48d2d --- /dev/null +++ b/test/pick/pick.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const pick = require('./pick.js'); + + + test('pick is a Function', () => { + expect(pick).toBeInstanceOf(Function); +}); + t.deepEqual(pick({ a: 1, b: '2', c: 3 }, ['a', 'c']), { 'a': 1, 'c': 3 }, "Picks the key-value pairs corresponding to the given keys from an object."); + diff --git a/test5/pickBy/pickBy.js b/test/pickBy/pickBy.js similarity index 62% rename from test5/pickBy/pickBy.js rename to test/pickBy/pickBy.js index fa2f4701f..7d10b8139 100644 --- a/test5/pickBy/pickBy.js +++ b/test/pickBy/pickBy.js @@ -1,5 +1,5 @@ const pickBy = (obj, fn) => Object.keys(obj) .filter(k => fn(obj[k], k)) -.reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); +.reduce((acc, key) => ((acc[key] = obj[key]), acc), { module.exports = pickBy; \ No newline at end of file diff --git a/test/pickBy/pickBy.test.js b/test/pickBy/pickBy.test.js new file mode 100644 index 000000000..d0e5d9b19 --- /dev/null +++ b/test/pickBy/pickBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const pickBy = require('./pickBy.js'); + + + test('pickBy is a Function', () => { + expect(pickBy).toBeInstanceOf(Function); +}); + t.deepEqual(pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'), { 'a': 1, 'c': 3 }, 'Creates an object composed of the properties the given function returns truthy for.'); + + diff --git a/test5/pipeAsyncFunctions/pipeAsyncFunctions.js b/test/pipeAsyncFunctions/pipeAsyncFunctions.js similarity index 100% rename from test5/pipeAsyncFunctions/pipeAsyncFunctions.js rename to test/pipeAsyncFunctions/pipeAsyncFunctions.js diff --git a/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js b/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js new file mode 100644 index 000000000..b70731c9c --- /dev/null +++ b/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js @@ -0,0 +1,19 @@ +const expect = require('expect'); +const pipeAsyncFunctions = require('./pipeAsyncFunctions.js'); + + + test('pipeAsyncFunctions is a Function', () => { + expect(pipeAsyncFunctions).toBeInstanceOf(Function); +}); + t.equal( + await pipeAsyncFunctions( + (x) => x + 1, + (x) => new Promise((resolve) => setTimeout(() => resolve(x + 2), 0)), + (x) => x + 3, + async (x) => await x + 4, + ) + (5), + 15, + 'pipeAsyncFunctions result should be 15' + ); + diff --git a/test5/pipeFunctions/pipeFunctions.js b/test/pipeFunctions/pipeFunctions.js similarity index 100% rename from test5/pipeFunctions/pipeFunctions.js rename to test/pipeFunctions/pipeFunctions.js diff --git a/test/pipeFunctions/pipeFunctions.test.js b/test/pipeFunctions/pipeFunctions.test.js new file mode 100644 index 000000000..ddf1a3c0d --- /dev/null +++ b/test/pipeFunctions/pipeFunctions.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const pipeFunctions = require('./pipeFunctions.js'); + + + test('pipeFunctions is a Function', () => { + expect(pipeFunctions).toBeInstanceOf(Function); +}); + const add5 = x => x + 5; + const multiply = (x, y) => x * y; + const multiplyAndAdd5 = pipeFunctions(multiply, add5); + t.equal(multiplyAndAdd5(5, 2), 15, 'Performs left-to-right function composition'); + + diff --git a/test5/pluralize/pluralize.js b/test/pluralize/pluralize.js similarity index 100% rename from test5/pluralize/pluralize.js rename to test/pluralize/pluralize.js diff --git a/test/pluralize/pluralize.test.js b/test/pluralize/pluralize.test.js new file mode 100644 index 000000000..7f2147e2d --- /dev/null +++ b/test/pluralize/pluralize.test.js @@ -0,0 +1,19 @@ +const expect = require('expect'); +const pluralize = require('./pluralize.js'); + + + test('pluralize is a Function', () => { + expect(pluralize).toBeInstanceOf(Function); +}); + t.equal(pluralize(0, 'apple'), 'apples', 'Produces the plural of the word'); + t.equal(pluralize(1, 'apple'), 'apple', 'Produces the singular of the word'); + t.equal(pluralize(2, 'apple'), 'apples', 'Produces the plural of the word'); + t.equal(pluralize(2, 'person', 'people'), 'people', 'Prodices the defined plural of the word'); + const PLURALS = { + person: 'people', + radius: 'radii' + }; + const autoPluralize = pluralize(PLURALS); + t.equal(autoPluralize(2, 'person'), 'people', 'Works with a dictionary'); + + diff --git a/test5/powerset/powerset.js b/test/powerset/powerset.js similarity index 100% rename from test5/powerset/powerset.js rename to test/powerset/powerset.js diff --git a/test/powerset/powerset.test.js b/test/powerset/powerset.test.js new file mode 100644 index 000000000..355d18110 --- /dev/null +++ b/test/powerset/powerset.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const powerset = require('./powerset.js'); + + + test('powerset is a Function', () => { + expect(powerset).toBeInstanceOf(Function); +}); + t.deepEqual(powerset([1, 2]), [[], [1], [2], [2,1]], "Returns the powerset of a given array of numbers."); + diff --git a/test5/prefix/prefix.js b/test/prefix/prefix.js similarity index 100% rename from test5/prefix/prefix.js rename to test/prefix/prefix.js diff --git a/test/prefix/prefix.test.js b/test/prefix/prefix.test.js new file mode 100644 index 000000000..0949f258c --- /dev/null +++ b/test/prefix/prefix.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const prefix = require('./prefix.js'); + + + test('prefix is a Function', () => { + expect(prefix).toBeInstanceOf(Function); +}); + diff --git a/test5/prettyBytes/prettyBytes.js b/test/prettyBytes/prettyBytes.js similarity index 100% rename from test5/prettyBytes/prettyBytes.js rename to test/prettyBytes/prettyBytes.js diff --git a/test/prettyBytes/prettyBytes.test.js b/test/prettyBytes/prettyBytes.test.js new file mode 100644 index 000000000..44e629b2d --- /dev/null +++ b/test/prettyBytes/prettyBytes.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const prettyBytes = require('./prettyBytes.js'); + + + test('prettyBytes is a Function', () => { + expect(prettyBytes).toBeInstanceOf(Function); +}); + t.equal(prettyBytes(1000), '1 KB', "Converts a number in bytes to a human-readable string."); + t.equal(prettyBytes(-27145424323.5821, 5), '-27.145 GB', "Converts a number in bytes to a human-readable string."); + t.equal(prettyBytes(123456789, 3, false), '123MB', "Converts a number in bytes to a human-readable string."); + diff --git a/test5/primes/primes.js b/test/primes/primes.js similarity index 100% rename from test5/primes/primes.js rename to test/primes/primes.js diff --git a/test/primes/primes.test.js b/test/primes/primes.test.js new file mode 100644 index 000000000..bc302c481 --- /dev/null +++ b/test/primes/primes.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const primes = require('./primes.js'); + + + test('primes is a Function', () => { + expect(primes).toBeInstanceOf(Function); +}); + t.deepEqual(primes(10), [2, 3, 5, 7], "Generates primes up to a given number, using the Sieve of Eratosthenes."); + diff --git a/test5/promisify/promisify.js b/test/promisify/promisify.js similarity index 100% rename from test5/promisify/promisify.js rename to test/promisify/promisify.js diff --git a/test/promisify/promisify.test.js b/test/promisify/promisify.test.js new file mode 100644 index 000000000..53b656aeb --- /dev/null +++ b/test/promisify/promisify.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const promisify = require('./promisify.js'); + + + test('promisify is a Function', () => { + expect(promisify).toBeInstanceOf(Function); +}); + const x = promisify(Math.max); + test('Returns a promise', () => { + expect(x() instanceof Promise).toBeTruthy(); +}); + const delay = promisify((d, cb) => setTimeout(cb, d)); + delay(200).then(() => t.pass('Runs the function provided')); + + diff --git a/test5/pull/pull.js b/test/pull/pull.js similarity index 100% rename from test5/pull/pull.js rename to test/pull/pull.js diff --git a/test/pull/pull.test.js b/test/pull/pull.test.js new file mode 100644 index 000000000..c7458e3a2 --- /dev/null +++ b/test/pull/pull.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const pull = require('./pull.js'); + + + test('pull is a Function', () => { + expect(pull).toBeInstanceOf(Function); +}); + let myArray = ['a', 'b', 'c', 'a', 'b', 'c']; + pull(myArray, 'a', 'c'); + t.deepEqual(myArray, ['b','b'], 'Pulls the specified values'); + + diff --git a/test5/pullAtIndex/pullAtIndex.js b/test/pullAtIndex/pullAtIndex.js similarity index 100% rename from test5/pullAtIndex/pullAtIndex.js rename to test/pullAtIndex/pullAtIndex.js diff --git a/test/pullAtIndex/pullAtIndex.test.js b/test/pullAtIndex/pullAtIndex.test.js new file mode 100644 index 000000000..08db4f15d --- /dev/null +++ b/test/pullAtIndex/pullAtIndex.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const pullAtIndex = require('./pullAtIndex.js'); + + + test('pullAtIndex is a Function', () => { + expect(pullAtIndex).toBeInstanceOf(Function); +}); + let myArray = ['a', 'b', 'c', 'd']; + let pulled = pullAtIndex(myArray, [1, 3]); + t.deepEqual(myArray, [ 'a', 'c' ], 'Pulls the given values'); + t.deepEqual(pulled, [ 'b', 'd' ], 'Pulls the given values'); + + diff --git a/test5/pullAtValue/pullAtValue.js b/test/pullAtValue/pullAtValue.js similarity index 100% rename from test5/pullAtValue/pullAtValue.js rename to test/pullAtValue/pullAtValue.js diff --git a/test/pullAtValue/pullAtValue.test.js b/test/pullAtValue/pullAtValue.test.js new file mode 100644 index 000000000..bbf850ca8 --- /dev/null +++ b/test/pullAtValue/pullAtValue.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const pullAtValue = require('./pullAtValue.js'); + + + test('pullAtValue is a Function', () => { + expect(pullAtValue).toBeInstanceOf(Function); +}); + let myArray = ['a', 'b', 'c', 'd']; + let pulled = pullAtValue(myArray, ['b', 'd']); + t.deepEqual(myArray, [ 'a', 'c' ], 'Pulls the specified values'); + t.deepEqual(pulled, [ 'b', 'd' ], 'Pulls the specified values'); + + diff --git a/test5/pullBy/pullBy.js b/test/pullBy/pullBy.js similarity index 100% rename from test5/pullBy/pullBy.js rename to test/pullBy/pullBy.js diff --git a/test/pullBy/pullBy.test.js b/test/pullBy/pullBy.test.js new file mode 100644 index 000000000..f01205590 --- /dev/null +++ b/test/pullBy/pullBy.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const pullBy = require('./pullBy.js'); + + + test('pullBy is a Function', () => { + expect(pullBy).toBeInstanceOf(Function); +}); + var myArray = [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }]; + pullBy(myArray, [{ x: 1 }, { x: 3 }], o => o.x); + t.deepEqual(myArray, [{ x: 2 }], 'Pulls the specified values'); + + diff --git a/test5/quickSort/quickSort.js b/test/quickSort/quickSort.js similarity index 100% rename from test5/quickSort/quickSort.js rename to test/quickSort/quickSort.js diff --git a/test/quickSort/quickSort.test.js b/test/quickSort/quickSort.test.js new file mode 100644 index 000000000..693eb3da0 --- /dev/null +++ b/test/quickSort/quickSort.test.js @@ -0,0 +1,24 @@ +const expect = require('expect'); +const quickSort = require('./quickSort.js'); + + + test('quickSort is a Function', () => { + expect(quickSort).toBeInstanceOf(Function); +}); + t.deepEqual(quickSort([5, 6, 4, 3, 1, 2]), [1, 2, 3, 4, 5, 6], 'quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6]'); + t.deepEqual(quickSort([-1, 0, -2]), [-2, -1, 0], 'quickSort([-1, 0, -2]) returns [-2, -1, 0]'); + t.throws(() => quickSort(), 'quickSort() throws an error'); + t.throws(() => quickSort(123), 'quickSort(123) throws an error'); + t.throws(() => quickSort({ 234: string}), 'quickSort({ 234: string}) throws an error'); + t.throws(() => quickSort(null), 'quickSort(null) throws an error'); + t.throws(() => quickSort(undefined), 'quickSort(undefined) throws an error'); + + let start = new Date().getTime(); + quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]); + let end = new Date().getTime(); + test('quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + + diff --git a/test5/radsToDegrees/radsToDegrees.js b/test/radsToDegrees/radsToDegrees.js similarity index 100% rename from test5/radsToDegrees/radsToDegrees.js rename to test/radsToDegrees/radsToDegrees.js diff --git a/test/radsToDegrees/radsToDegrees.test.js b/test/radsToDegrees/radsToDegrees.test.js new file mode 100644 index 000000000..2a65a6c78 --- /dev/null +++ b/test/radsToDegrees/radsToDegrees.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const radsToDegrees = require('./radsToDegrees.js'); + + + test('radsToDegrees is a Function', () => { + expect(radsToDegrees).toBeInstanceOf(Function); +}); + t.equal(radsToDegrees(Math.PI / 2), 90, 'Returns the appropriate value'); + + diff --git a/test5/randomHexColorCode/randomHexColorCode.js b/test/randomHexColorCode/randomHexColorCode.js similarity index 100% rename from test5/randomHexColorCode/randomHexColorCode.js rename to test/randomHexColorCode/randomHexColorCode.js diff --git a/test/randomHexColorCode/randomHexColorCode.test.js b/test/randomHexColorCode/randomHexColorCode.test.js new file mode 100644 index 000000000..8d75773ab --- /dev/null +++ b/test/randomHexColorCode/randomHexColorCode.test.js @@ -0,0 +1,16 @@ +const expect = require('expect'); +const randomHexColorCode = require('./randomHexColorCode.js'); + + + test('randomHexColorCode is a Function', () => { + expect(randomHexColorCode).toBeInstanceOf(Function); +}); + t.equal(randomHexColorCode().length, 7); + test('The color code starts with "#"', () => { + expect(randomHexColorCode().startsWith('#')).toBeTruthy(); +}); + test('The color code contains only valid hex-digits', () => { + expect(randomHexColorCode().slice(1).match(/[^0123456789abcdef]/i) === null).toBeTruthy(); +}); + + diff --git a/test5/randomIntArrayInRange/randomIntArrayInRange.js b/test/randomIntArrayInRange/randomIntArrayInRange.js similarity index 100% rename from test5/randomIntArrayInRange/randomIntArrayInRange.js rename to test/randomIntArrayInRange/randomIntArrayInRange.js diff --git a/test5/randomIntArrayInRange/randomIntArrayInRange.test.js b/test/randomIntArrayInRange/randomIntArrayInRange.test.js similarity index 54% rename from test5/randomIntArrayInRange/randomIntArrayInRange.test.js rename to test/randomIntArrayInRange/randomIntArrayInRange.test.js index cff9657e5..40b0635ef 100644 --- a/test5/randomIntArrayInRange/randomIntArrayInRange.test.js +++ b/test/randomIntArrayInRange/randomIntArrayInRange.test.js @@ -1,14 +1,19 @@ const expect = require('expect'); const randomIntArrayInRange = require('./randomIntArrayInRange.js'); -test('Testing randomIntArrayInRange', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof randomIntArrayInRange === 'function').toBeTruthy(); + + test('randomIntArrayInRange is a Function', () => { + expect(randomIntArrayInRange).toBeInstanceOf(Function); +}); const lowerLimit = Math.floor(Math.random() * 20); const upperLimit = Math.floor(lowerLimit + Math.random() * 10); const arr = randomIntArrayInRange(lowerLimit,upperLimit, 10); + test('The returned array contains only integers', () => { expect(arr.every(x => typeof x === 'number')).toBeTruthy(); - expect(arr.length).toBe(10); +}); + t.equal(arr.length, 10, 'The returned array has the proper length'); + test('The returned array\'s values lie between provided lowerLimit and upperLimit (both inclusive).', () => { expect(arr.every(x => (x >= lowerLimit) && (x <= upperLimit))).toBeTruthy(); }); + + diff --git a/test5/randomIntegerInRange/randomIntegerInRange.js b/test/randomIntegerInRange/randomIntegerInRange.js similarity index 100% rename from test5/randomIntegerInRange/randomIntegerInRange.js rename to test/randomIntegerInRange/randomIntegerInRange.js diff --git a/test5/randomIntegerInRange/randomIntegerInRange.test.js b/test/randomIntegerInRange/randomIntegerInRange.test.js similarity index 62% rename from test5/randomIntegerInRange/randomIntegerInRange.test.js rename to test/randomIntegerInRange/randomIntegerInRange.test.js index 04ebd1d4f..0394b74e8 100644 --- a/test5/randomIntegerInRange/randomIntegerInRange.test.js +++ b/test/randomIntegerInRange/randomIntegerInRange.test.js @@ -1,13 +1,18 @@ const expect = require('expect'); const randomIntegerInRange = require('./randomIntegerInRange.js'); -test('Testing randomIntegerInRange', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof randomIntegerInRange === 'function').toBeTruthy(); + + test('randomIntegerInRange is a Function', () => { + expect(randomIntegerInRange).toBeInstanceOf(Function); +}); const lowerLimit = Math.floor(Math.random() * 20); const upperLimit = Math.floor(lowerLimit + Math.random() * 10); + test('The returned value is an integer', () => { expect(Number.isInteger(randomIntegerInRange(lowerLimit,upperLimit))).toBeTruthy(); +}); const numberForTest = randomIntegerInRange(lowerLimit,upperLimit); + test('The returned value lies between provided lowerLimit and upperLimit (both inclusive).', () => { expect((numberForTest >= lowerLimit) && (numberForTest <= upperLimit)).toBeTruthy(); }); + + diff --git a/test5/randomNumberInRange/randomNumberInRange.js b/test/randomNumberInRange/randomNumberInRange.js similarity index 100% rename from test5/randomNumberInRange/randomNumberInRange.js rename to test/randomNumberInRange/randomNumberInRange.js diff --git a/test5/randomNumberInRange/randomNumberInRange.test.js b/test/randomNumberInRange/randomNumberInRange.test.js similarity index 63% rename from test5/randomNumberInRange/randomNumberInRange.test.js rename to test/randomNumberInRange/randomNumberInRange.test.js index 646322ce8..24b7419c0 100644 --- a/test5/randomNumberInRange/randomNumberInRange.test.js +++ b/test/randomNumberInRange/randomNumberInRange.test.js @@ -1,13 +1,18 @@ const expect = require('expect'); const randomNumberInRange = require('./randomNumberInRange.js'); -test('Testing randomNumberInRange', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof randomNumberInRange === 'function').toBeTruthy(); + + test('randomNumberInRange is a Function', () => { + expect(randomNumberInRange).toBeInstanceOf(Function); +}); const lowerLimit = Math.floor(Math.random() * 20); const upperLimit = Math.floor(lowerLimit + Math.random() * 10); + test('The returned value is a number', () => { expect(typeof randomNumberInRange(lowerLimit,upperLimit) === 'number').toBeTruthy(); +}); const numberForTest = randomNumberInRange(lowerLimit,upperLimit); + test('The returned value lies between provided lowerLimit and upperLimit (both inclusive).', () => { expect((numberForTest >= lowerLimit) && (numberForTest <= upperLimit)).toBeTruthy(); }); + + diff --git a/test5/readFileLines/readFileLines.js b/test/readFileLines/readFileLines.js similarity index 100% rename from test5/readFileLines/readFileLines.js rename to test/readFileLines/readFileLines.js diff --git a/test/readFileLines/readFileLines.test.js b/test/readFileLines/readFileLines.test.js new file mode 100644 index 000000000..1590f08c0 --- /dev/null +++ b/test/readFileLines/readFileLines.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const readFileLines = require('./readFileLines.js'); + + + test('readFileLines is a Function', () => { + expect(readFileLines).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test5/rearg/rearg.js b/test/rearg/rearg.js similarity index 100% rename from test5/rearg/rearg.js rename to test/rearg/rearg.js diff --git a/test/rearg/rearg.test.js b/test/rearg/rearg.test.js new file mode 100644 index 000000000..a15e44b93 --- /dev/null +++ b/test/rearg/rearg.test.js @@ -0,0 +1,16 @@ +const expect = require('expect'); +const rearg = require('./rearg.js'); + + + test('rearg is a Function', () => { + expect(rearg).toBeInstanceOf(Function); +}); + var rearged = rearg( + function(a, b, c) { + return [a, b, c]; + }, + [2, 0, 1] + ); + t.deepEqual(rearged('b', 'c', 'a'), ['a', 'b', 'c'], 'Reorders arguments in invoked function'); + + diff --git a/test5/recordAnimationFrames/recordAnimationFrames.js b/test/recordAnimationFrames/recordAnimationFrames.js similarity index 98% rename from test5/recordAnimationFrames/recordAnimationFrames.js rename to test/recordAnimationFrames/recordAnimationFrames.js index 7e7ca9004..4408e0d77 100644 --- a/test5/recordAnimationFrames/recordAnimationFrames.js +++ b/test/recordAnimationFrames/recordAnimationFrames.js @@ -13,7 +13,7 @@ const run = () => { raf = requestAnimationFrame(() => { callback(); if (running) run(); -}); + }; if (autoStart) start(); return { start, stop }; diff --git a/test/recordAnimationFrames/recordAnimationFrames.test.js b/test/recordAnimationFrames/recordAnimationFrames.test.js new file mode 100644 index 000000000..5c6af20dc --- /dev/null +++ b/test/recordAnimationFrames/recordAnimationFrames.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const recordAnimationFrames = require('./recordAnimationFrames.js'); + + + test('recordAnimationFrames is a Function', () => { + expect(recordAnimationFrames).toBeInstanceOf(Function); +}); + diff --git a/test5/redirect/redirect.js b/test/redirect/redirect.js similarity index 100% rename from test5/redirect/redirect.js rename to test/redirect/redirect.js diff --git a/test/redirect/redirect.test.js b/test/redirect/redirect.test.js new file mode 100644 index 000000000..680d23ec5 --- /dev/null +++ b/test/redirect/redirect.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const redirect = require('./redirect.js'); + + + test('redirect is a Function', () => { + expect(redirect).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test5/reduceSuccessive/reduceSuccessive.js b/test/reduceSuccessive/reduceSuccessive.js similarity index 100% rename from test5/reduceSuccessive/reduceSuccessive.js rename to test/reduceSuccessive/reduceSuccessive.js diff --git a/test/reduceSuccessive/reduceSuccessive.test.js b/test/reduceSuccessive/reduceSuccessive.test.js new file mode 100644 index 000000000..d78e659d6 --- /dev/null +++ b/test/reduceSuccessive/reduceSuccessive.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const reduceSuccessive = require('./reduceSuccessive.js'); + + + test('reduceSuccessive is a Function', () => { + expect(reduceSuccessive).toBeInstanceOf(Function); +}); + t.deepEqual(reduceSuccessive([1, 2, 3, 4, 5, 6], (acc, val) => acc + val, 0), [0, 1, 3, 6, 10, 15, 21], 'Returns the array of successively reduced values'); + + diff --git a/test5/reduceWhich/reduceWhich.js b/test/reduceWhich/reduceWhich.js similarity index 100% rename from test5/reduceWhich/reduceWhich.js rename to test/reduceWhich/reduceWhich.js diff --git a/test/reduceWhich/reduceWhich.test.js b/test/reduceWhich/reduceWhich.test.js new file mode 100644 index 000000000..4d6929507 --- /dev/null +++ b/test/reduceWhich/reduceWhich.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const reduceWhich = require('./reduceWhich.js'); + + + test('reduceWhich is a Function', () => { + expect(reduceWhich).toBeInstanceOf(Function); +}); + t.equal(reduceWhich([1, 3, 2]), 1, 'Returns the minimum of an array'); + t.equal(reduceWhich([1, 3, 2], (a, b) => b - a), 3, 'Returns the maximum of an array'); + t.deepEqual(reduceWhich( + [{ name: 'Tom', age: 12 }, { name: 'Jack', age: 18 }, { name: 'Lucy', age: 9 }], + (a, b) => a.age - b.age +), {name: "Lucy", age: 9}, 'Returns the object with the minimum specified value in an array'); + + diff --git a/test5/reducedFilter/reducedFilter.js b/test/reducedFilter/reducedFilter.js similarity index 100% rename from test5/reducedFilter/reducedFilter.js rename to test/reducedFilter/reducedFilter.js diff --git a/test/reducedFilter/reducedFilter.test.js b/test/reducedFilter/reducedFilter.test.js new file mode 100644 index 000000000..5fce9e4cb --- /dev/null +++ b/test/reducedFilter/reducedFilter.test.js @@ -0,0 +1,21 @@ +const expect = require('expect'); +const reducedFilter = require('./reducedFilter.js'); + + + test('reducedFilter is a Function', () => { + expect(reducedFilter).toBeInstanceOf(Function); +}); + const data = [ + { + id: 1, + name: 'john', + age: 24 + }, + { + id: 2, + name: 'mike', + age: 50 + } + ]; + t.deepEqual(reducedFilter(data, ['id', 'name'], item => item.age > 24), [{ id: 2, name: 'mike'}], "Filter an array of objects based on a condition while also filtering out unspecified keys."); + diff --git a/test5/reject/reject.js b/test/reject/reject.js similarity index 100% rename from test5/reject/reject.js rename to test/reject/reject.js diff --git a/test/reject/reject.test.js b/test/reject/reject.test.js new file mode 100644 index 000000000..270e9b8f5 --- /dev/null +++ b/test/reject/reject.test.js @@ -0,0 +1,24 @@ +const expect = require('expect'); +const reject = require('./reject.js'); + + + test('reject is a Function', () => { + expect(reject).toBeInstanceOf(Function); +}); + + const noEvens = reject( + (x) => x % 2 === 0, + [1, 2, 3, 4, 5] + ); + + t.deepEqual(noEvens, [1, 3, 5]); + + const fourLettersOrLess = reject( + (word) => word.length > 4, + ['Apple', 'Pear', 'Kiwi', 'Banana'] + ); + + t.deepEqual(fourLettersOrLess, ['Pear', 'Kiwi']); + + + diff --git a/test5/remove/remove.js b/test/remove/remove.js similarity index 100% rename from test5/remove/remove.js rename to test/remove/remove.js diff --git a/test/remove/remove.test.js b/test/remove/remove.test.js new file mode 100644 index 000000000..bae377e4e --- /dev/null +++ b/test/remove/remove.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const remove = require('./remove.js'); + + + test('remove is a Function', () => { + expect(remove).toBeInstanceOf(Function); +}); + t.deepEqual(remove([1, 2, 3, 4], n => n % 2 === 0), [2, 4], "Removes elements from an array for which the given function returns false"); + + diff --git a/test5/removeNonASCII/removeNonASCII.js b/test/removeNonASCII/removeNonASCII.js similarity index 100% rename from test5/removeNonASCII/removeNonASCII.js rename to test/removeNonASCII/removeNonASCII.js diff --git a/test/removeNonASCII/removeNonASCII.test.js b/test/removeNonASCII/removeNonASCII.test.js new file mode 100644 index 000000000..a33c12a00 --- /dev/null +++ b/test/removeNonASCII/removeNonASCII.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const removeNonASCII = require('./removeNonASCII.js'); + + + test('removeNonASCII is a Function', () => { + expect(removeNonASCII).toBeInstanceOf(Function); +}); + t.equal(removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'), 'lorem-ipsum', 'Removes non-ASCII characters'); + + diff --git a/test5/removeVowels/removeVowels.js b/test/removeVowels/removeVowels.js similarity index 100% rename from test5/removeVowels/removeVowels.js rename to test/removeVowels/removeVowels.js diff --git a/test/removeVowels/removeVowels.test.js b/test/removeVowels/removeVowels.test.js new file mode 100644 index 000000000..36afe09c2 --- /dev/null +++ b/test/removeVowels/removeVowels.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const removeVowels = require('./removeVowels.js'); + + + test('removeVowels is a Function', () => { + expect(removeVowels).toBeInstanceOf(Function); +}); + diff --git a/test5/renameKeys/renameKeys.js b/test/renameKeys/renameKeys.js similarity index 100% rename from test5/renameKeys/renameKeys.js rename to test/renameKeys/renameKeys.js diff --git a/test/renameKeys/renameKeys.test.js b/test/renameKeys/renameKeys.test.js new file mode 100644 index 000000000..de0438f0c --- /dev/null +++ b/test/renameKeys/renameKeys.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const renameKeys = require('./renameKeys.js'); + + + test('renameKeys is a Function', () => { + expect(renameKeys).toBeInstanceOf(Function); +}); + + const obj = { name: 'Bobo', job: 'Front-End Master', shoeSize: 100 }; + const renamedObj = renameKeys({ name: 'firstName', job: 'passion' }, obj); + + t.deepEqual(renamedObj, { firstName: 'Bobo', passion: 'Front-End Master', shoeSize: 100 + + + diff --git a/test5/reverseString/reverseString.js b/test/reverseString/reverseString.js similarity index 100% rename from test5/reverseString/reverseString.js rename to test/reverseString/reverseString.js diff --git a/test/reverseString/reverseString.test.js b/test/reverseString/reverseString.test.js new file mode 100644 index 000000000..176f122c1 --- /dev/null +++ b/test/reverseString/reverseString.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const reverseString = require('./reverseString.js'); + + + test('reverseString is a Function', () => { + expect(reverseString).toBeInstanceOf(Function); +}); + t.equal(reverseString('foobar'), 'raboof', "Reverses a string."); + diff --git a/test5/round/round.js b/test/round/round.js similarity index 100% rename from test5/round/round.js rename to test/round/round.js diff --git a/test/round/round.test.js b/test/round/round.test.js new file mode 100644 index 000000000..8d9cc9318 --- /dev/null +++ b/test/round/round.test.js @@ -0,0 +1,35 @@ +const expect = require('expect'); +const round = require('./round.js'); + + + test('round is a Function', () => { + expect(round).toBeInstanceOf(Function); +}); + t.equal(round(1.005, 2), 1.01, "round(1.005, 2) returns 1.01"); + t.equal(round(123.3423345345345345344, 11), 123.34233453453, "round(123.3423345345345345344, 11) returns 123.34233453453"); + t.equal(round(3.342, 11), 3.342, "round(3.342, 11) returns 3.342"); + t.equal(round(1.005), 1, "round(1.005) returns 1"); + test('round([1.005, 2]) returns NaN', () => { + expect(isNaN(round([1.005, 2]))).toBeTruthy(); +}); + test('round(string) returns NaN', () => { + expect(isNaN(round('string'))).toBeTruthy(); +}); + test('round() returns NaN', () => { + expect(isNaN(round())).toBeTruthy(); +}); + test('round(132, 413, 4134) returns NaN', () => { + expect(isNaN(round(132, 413, 4134))).toBeTruthy(); +}); + test('round({a: 132}, 413) returns NaN', () => { + expect(isNaN(round({a: 132}, 413))).toBeTruthy(); +}); + + let start = new Date().getTime(); + round(123.3423345345345345344, 11); + let end = new Date().getTime(); + test('round(123.3423345345345345344, 11) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + diff --git a/test6/runAsync/runAsync.js b/test/runAsync/runAsync.js similarity index 98% rename from test6/runAsync/runAsync.js rename to test/runAsync/runAsync.js index e049e49f0..046dc1b35 100644 --- a/test6/runAsync/runAsync.js +++ b/test/runAsync/runAsync.js @@ -11,6 +11,6 @@ res(data), worker.terminate(); worker.onerror = err => { rej(err), worker.terminate(); }; -}); + }; module.exports = runAsync; \ No newline at end of file diff --git a/test/runAsync/runAsync.test.js b/test/runAsync/runAsync.test.js new file mode 100644 index 000000000..7606a8cfb --- /dev/null +++ b/test/runAsync/runAsync.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const runAsync = require('./runAsync.js'); + + + test('runAsync is a Function', () => { + expect(runAsync).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test6/runPromisesInSeries/runPromisesInSeries.js b/test/runPromisesInSeries/runPromisesInSeries.js similarity index 100% rename from test6/runPromisesInSeries/runPromisesInSeries.js rename to test/runPromisesInSeries/runPromisesInSeries.js diff --git a/test/runPromisesInSeries/runPromisesInSeries.test.js b/test/runPromisesInSeries/runPromisesInSeries.test.js new file mode 100644 index 000000000..646172e0e --- /dev/null +++ b/test/runPromisesInSeries/runPromisesInSeries.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const runPromisesInSeries = require('./runPromisesInSeries.js'); + + + test('runPromisesInSeries is a Function', () => { + expect(runPromisesInSeries).toBeInstanceOf(Function); +}); + const delay = d => new Promise(r => setTimeout(r, d)); + runPromisesInSeries([() => delay(100), () => delay(200).then(() => t.pass('Runs promises in series'))]); + + diff --git a/test6/sample/sample.js b/test/sample/sample.js similarity index 100% rename from test6/sample/sample.js rename to test/sample/sample.js diff --git a/test/sample/sample.test.js b/test/sample/sample.test.js new file mode 100644 index 000000000..caf8ccd45 --- /dev/null +++ b/test/sample/sample.test.js @@ -0,0 +1,15 @@ +const expect = require('expect'); +const sample = require('./sample.js'); + + + test('sample is a Function', () => { + expect(sample).toBeInstanceOf(Function); +}); + const arr = [3,7,9,11]; + test('Returns a random element from the array', () => { + expect(arr.includes(sample(arr))).toBeTruthy(); +}); + t.equal(sample([1]), 1, 'Works for single-element arrays'); + t.equal(sample([]), undefined, 'Returns undefined for empty array'); + + diff --git a/test6/sampleSize/sampleSize.js b/test/sampleSize/sampleSize.js similarity index 100% rename from test6/sampleSize/sampleSize.js rename to test/sampleSize/sampleSize.js diff --git a/test/sampleSize/sampleSize.test.js b/test/sampleSize/sampleSize.test.js new file mode 100644 index 000000000..f56f1b5cb --- /dev/null +++ b/test/sampleSize/sampleSize.test.js @@ -0,0 +1,17 @@ +const expect = require('expect'); +const sampleSize = require('./sampleSize.js'); + + + test('sampleSize is a Function', () => { + expect(sampleSize).toBeInstanceOf(Function); +}); + const arr = [3,7,9,11]; + t.equal(sampleSize(arr).length, 1, 'Returns a single element without n specified'); + test('Returns a random sample of specified size from an array', () => { + expect(sampleSize(arr, 2).every(x => arr.includes(x))).toBeTruthy(); +}); + t.equal(sampleSize(arr, 5).length, 4, 'Returns all elements in an array if n >= length'); + t.deepEqual(sampleSize([], 2), [], 'Returns an empty array if original array is empty'); + t.deepEqual(sampleSize(arr, 0), [], 'Returns an empty array if n = 0'); + + diff --git a/test6/scrollToTop/scrollToTop.js b/test/scrollToTop/scrollToTop.js similarity index 100% rename from test6/scrollToTop/scrollToTop.js rename to test/scrollToTop/scrollToTop.js diff --git a/test/scrollToTop/scrollToTop.test.js b/test/scrollToTop/scrollToTop.test.js new file mode 100644 index 000000000..37afc3739 --- /dev/null +++ b/test/scrollToTop/scrollToTop.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const scrollToTop = require('./scrollToTop.js'); + + + test('scrollToTop is a Function', () => { + expect(scrollToTop).toBeInstanceOf(Function); +}); + t.pass('Tested on 09/02/2018 by @chalarangelo'); + + diff --git a/test6/sdbm/sdbm.js b/test/sdbm/sdbm.js similarity index 100% rename from test6/sdbm/sdbm.js rename to test/sdbm/sdbm.js diff --git a/test/sdbm/sdbm.test.js b/test/sdbm/sdbm.test.js new file mode 100644 index 000000000..718fd716a --- /dev/null +++ b/test/sdbm/sdbm.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const sdbm = require('./sdbm.js'); + + + test('sdbm is a Function', () => { + expect(sdbm).toBeInstanceOf(Function); +}); + t.equal(sdbm('name'), -3521204949, "Hashes the input string into a whole number."); + diff --git a/test6/serializeCookie/serializeCookie.js b/test/serializeCookie/serializeCookie.js similarity index 100% rename from test6/serializeCookie/serializeCookie.js rename to test/serializeCookie/serializeCookie.js diff --git a/test/serializeCookie/serializeCookie.test.js b/test/serializeCookie/serializeCookie.test.js new file mode 100644 index 000000000..13e6d57ef --- /dev/null +++ b/test/serializeCookie/serializeCookie.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const serializeCookie = require('./serializeCookie.js'); + + + test('serializeCookie is a Function', () => { + expect(serializeCookie).toBeInstanceOf(Function); +}); + t.equal(serializeCookie('foo', 'bar'), 'foo=bar', 'Serializes the cookie'); + + diff --git a/test6/setStyle/setStyle.js b/test/setStyle/setStyle.js similarity index 100% rename from test6/setStyle/setStyle.js rename to test/setStyle/setStyle.js diff --git a/test/setStyle/setStyle.test.js b/test/setStyle/setStyle.test.js new file mode 100644 index 000000000..5dfb5ba7f --- /dev/null +++ b/test/setStyle/setStyle.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const setStyle = require('./setStyle.js'); + + + test('setStyle is a Function', () => { + expect(setStyle).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test6/shallowClone/shallowClone.js b/test/shallowClone/shallowClone.js similarity index 100% rename from test6/shallowClone/shallowClone.js rename to test/shallowClone/shallowClone.js diff --git a/test/shallowClone/shallowClone.test.js b/test/shallowClone/shallowClone.test.js new file mode 100644 index 000000000..5d0caaee8 --- /dev/null +++ b/test/shallowClone/shallowClone.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const shallowClone = require('./shallowClone.js'); + + + test('shallowClone is a Function', () => { + expect(shallowClone).toBeInstanceOf(Function); +}); + const a = { foo: 'bar', obj: { a: 1, b: 2 } }; + const b = shallowClone(a); + t.notEqual(a, b, 'Shallow cloning works'); + t.equal(a.obj, b.obj, 'Does not clone deeply'); + + diff --git a/test6/show/show.js b/test/show/show.js similarity index 100% rename from test6/show/show.js rename to test/show/show.js diff --git a/test/show/show.test.js b/test/show/show.test.js new file mode 100644 index 000000000..ae9f97f2e --- /dev/null +++ b/test/show/show.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const show = require('./show.js'); + + + test('show is a Function', () => { + expect(show).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test6/shuffle/shuffle.js b/test/shuffle/shuffle.js similarity index 100% rename from test6/shuffle/shuffle.js rename to test/shuffle/shuffle.js diff --git a/test/shuffle/shuffle.test.js b/test/shuffle/shuffle.test.js new file mode 100644 index 000000000..7fa46495a --- /dev/null +++ b/test/shuffle/shuffle.test.js @@ -0,0 +1,16 @@ +const expect = require('expect'); +const shuffle = require('./shuffle.js'); + + + test('shuffle is a Function', () => { + expect(shuffle).toBeInstanceOf(Function); +}); + const arr = [1,2,3,4,5,6]; + t.notEqual(shuffle(arr), arr, 'Shuffles the array'); + test('New array contains all original elements', () => { + expect(shuffle(arr).every(x => arr.includes(x))).toBeTruthy(); +}); + t.deepEqual(shuffle([]),[],'Works for empty arrays'); + t.deepEqual(shuffle([1]),[1],'Works for single-element arrays'); + + diff --git a/test6/similarity/similarity.js b/test/similarity/similarity.js similarity index 100% rename from test6/similarity/similarity.js rename to test/similarity/similarity.js diff --git a/test/similarity/similarity.test.js b/test/similarity/similarity.test.js new file mode 100644 index 000000000..480cba7b3 --- /dev/null +++ b/test/similarity/similarity.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const similarity = require('./similarity.js'); + + + test('similarity is a Function', () => { + expect(similarity).toBeInstanceOf(Function); +}); + t.deepEqual(similarity([1, 2, 3], [1, 2, 4]), [1, 2], "Returns an array of elements that appear in both arrays."); + diff --git a/test6/size/size.js b/test/size/size.js similarity index 100% rename from test6/size/size.js rename to test/size/size.js diff --git a/test/size/size.test.js b/test/size/size.test.js new file mode 100644 index 000000000..f47849756 --- /dev/null +++ b/test/size/size.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const size = require('./size.js'); + + + test('size is a Function', () => { + expect(size).toBeInstanceOf(Function); +}); + t.equal(size([1, 2, 3, 4, 5]), 5, "Get size of arrays, objects or strings."); + t.equal(size({ one: 1, two: 2, three: 3 }), 3, "Get size of arrays, objects or strings."); + diff --git a/test6/sleep/sleep.js b/test/sleep/sleep.js similarity index 100% rename from test6/sleep/sleep.js rename to test/sleep/sleep.js diff --git a/test/sleep/sleep.test.js b/test/sleep/sleep.test.js new file mode 100644 index 000000000..af6aca5da --- /dev/null +++ b/test/sleep/sleep.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const sleep = require('./sleep.js'); + + + test('sleep is a Function', () => { + expect(sleep).toBeInstanceOf(Function); +}); + async function sleepyWork() { + await sleep(1000); + t.pass('Works as expected'); + } + + diff --git a/test6/smoothScroll/smoothScroll.js b/test/smoothScroll/smoothScroll.js similarity index 97% rename from test6/smoothScroll/smoothScroll.js rename to test/smoothScroll/smoothScroll.js index 6d4ff2a1c..925223bef 100644 --- a/test6/smoothScroll/smoothScroll.js +++ b/test/smoothScroll/smoothScroll.js @@ -1,5 +1,5 @@ const smoothScroll = element => document.querySelector(element).scrollIntoView({ behavior: 'smooth' -}); + module.exports = smoothScroll; \ No newline at end of file diff --git a/test/smoothScroll/smoothScroll.test.js b/test/smoothScroll/smoothScroll.test.js new file mode 100644 index 000000000..86f93a396 --- /dev/null +++ b/test/smoothScroll/smoothScroll.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const smoothScroll = require('./smoothScroll.js'); + + + test('smoothScroll is a Function', () => { + expect(smoothScroll).toBeInstanceOf(Function); +}); + diff --git a/test6/solveRPN/solveRPN.js b/test/solveRPN/solveRPN.js similarity index 99% rename from test6/solveRPN/solveRPN.js rename to test/solveRPN/solveRPN.js index ac84c4a3d..a144db5ab 100644 --- a/test6/solveRPN/solveRPN.js +++ b/test/solveRPN/solveRPN.js @@ -22,7 +22,7 @@ stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a))); } else { throw `${symbol} is not a recognized symbol`; } -}); + if (stack.length === 1) return stack.pop(); else throw `${rpn} is not a proper RPN. Please check it and try again`; }; diff --git a/test/solveRPN/solveRPN.test.js b/test/solveRPN/solveRPN.test.js new file mode 100644 index 000000000..ce1e02dc1 --- /dev/null +++ b/test/solveRPN/solveRPN.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const solveRPN = require('./solveRPN.js'); + + + test('solveRPN is a Function', () => { + expect(solveRPN).toBeInstanceOf(Function); +}); + diff --git a/test6/sortCharactersInString/sortCharactersInString.js b/test/sortCharactersInString/sortCharactersInString.js similarity index 100% rename from test6/sortCharactersInString/sortCharactersInString.js rename to test/sortCharactersInString/sortCharactersInString.js diff --git a/test/sortCharactersInString/sortCharactersInString.test.js b/test/sortCharactersInString/sortCharactersInString.test.js new file mode 100644 index 000000000..92a055f4d --- /dev/null +++ b/test/sortCharactersInString/sortCharactersInString.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const sortCharactersInString = require('./sortCharactersInString.js'); + + + test('sortCharactersInString is a Function', () => { + expect(sortCharactersInString).toBeInstanceOf(Function); +}); + t.equal(sortCharactersInString('cabbage'), 'aabbceg', "Alphabetically sorts the characters in a string."); + diff --git a/test6/sortedIndex/sortedIndex.js b/test/sortedIndex/sortedIndex.js similarity index 100% rename from test6/sortedIndex/sortedIndex.js rename to test/sortedIndex/sortedIndex.js diff --git a/test/sortedIndex/sortedIndex.test.js b/test/sortedIndex/sortedIndex.test.js new file mode 100644 index 000000000..903b2534f --- /dev/null +++ b/test/sortedIndex/sortedIndex.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const sortedIndex = require('./sortedIndex.js'); + + + test('sortedIndex is a Function', () => { + expect(sortedIndex).toBeInstanceOf(Function); +}); + t.equal(sortedIndex([5, 3, 2, 1], 4), 1, "Returns the lowest index at which value should be inserted into array in order to maintain its sort order."); + t.equal(sortedIndex([30, 50], 40), 1, "Returns the lowest index at which value should be inserted into array in order to maintain its sort order."); + diff --git a/test6/sortedIndexBy/sortedIndexBy.js b/test/sortedIndexBy/sortedIndexBy.js similarity index 100% rename from test6/sortedIndexBy/sortedIndexBy.js rename to test/sortedIndexBy/sortedIndexBy.js diff --git a/test/sortedIndexBy/sortedIndexBy.test.js b/test/sortedIndexBy/sortedIndexBy.test.js new file mode 100644 index 000000000..49d9d7d60 --- /dev/null +++ b/test/sortedIndexBy/sortedIndexBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const sortedIndexBy = require('./sortedIndexBy.js'); + + + test('sortedIndexBy is a Function', () => { + expect(sortedIndexBy).toBeInstanceOf(Function); +}); + t.equal(sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x), 0, 'Returns the lowest index to insert the element without messing up the list order'); + + diff --git a/test6/sortedLastIndex/sortedLastIndex.js b/test/sortedLastIndex/sortedLastIndex.js similarity index 100% rename from test6/sortedLastIndex/sortedLastIndex.js rename to test/sortedLastIndex/sortedLastIndex.js diff --git a/test/sortedLastIndex/sortedLastIndex.test.js b/test/sortedLastIndex/sortedLastIndex.test.js new file mode 100644 index 000000000..4a502f50e --- /dev/null +++ b/test/sortedLastIndex/sortedLastIndex.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const sortedLastIndex = require('./sortedLastIndex.js'); + + + test('sortedLastIndex is a Function', () => { + expect(sortedLastIndex).toBeInstanceOf(Function); +}); + t.equal(sortedLastIndex([10, 20, 30, 30, 40], 30), 4, 'Returns the highest index to insert the element without messing up the list order'); + + diff --git a/test6/sortedLastIndexBy/sortedLastIndexBy.js b/test/sortedLastIndexBy/sortedLastIndexBy.js similarity index 100% rename from test6/sortedLastIndexBy/sortedLastIndexBy.js rename to test/sortedLastIndexBy/sortedLastIndexBy.js diff --git a/test/sortedLastIndexBy/sortedLastIndexBy.test.js b/test/sortedLastIndexBy/sortedLastIndexBy.test.js new file mode 100644 index 000000000..228e00249 --- /dev/null +++ b/test/sortedLastIndexBy/sortedLastIndexBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const sortedLastIndexBy = require('./sortedLastIndexBy.js'); + + + test('sortedLastIndexBy is a Function', () => { + expect(sortedLastIndexBy).toBeInstanceOf(Function); +}); + t.equal(sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x), 1, 'Returns the highest index to insert the element without messing up the list order'); + + diff --git a/test6/speechSynthesis/speechSynthesis.js b/test/speechSynthesis/speechSynthesis.js similarity index 100% rename from test6/speechSynthesis/speechSynthesis.js rename to test/speechSynthesis/speechSynthesis.js diff --git a/test/speechSynthesis/speechSynthesis.test.js b/test/speechSynthesis/speechSynthesis.test.js new file mode 100644 index 000000000..90425aaff --- /dev/null +++ b/test/speechSynthesis/speechSynthesis.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const speechSynthesis = require('./speechSynthesis.js'); + + + test('speechSynthesis is a Function', () => { + expect(speechSynthesis).toBeInstanceOf(Function); +}); + diff --git a/test6/splitLines/splitLines.js b/test/splitLines/splitLines.js similarity index 100% rename from test6/splitLines/splitLines.js rename to test/splitLines/splitLines.js diff --git a/test/splitLines/splitLines.test.js b/test/splitLines/splitLines.test.js new file mode 100644 index 000000000..fcbc7d46a --- /dev/null +++ b/test/splitLines/splitLines.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const splitLines = require('./splitLines.js'); + + + test('splitLines is a Function', () => { + expect(splitLines).toBeInstanceOf(Function); +}); + t.deepEqual(splitLines('This\nis a\nmultiline\nstring.\n'), ['This', 'is a', 'multiline', 'string.' , ''], "Splits a multiline string into an array of lines."); + diff --git a/test6/spreadOver/spreadOver.js b/test/spreadOver/spreadOver.js similarity index 100% rename from test6/spreadOver/spreadOver.js rename to test/spreadOver/spreadOver.js diff --git a/test/spreadOver/spreadOver.test.js b/test/spreadOver/spreadOver.test.js new file mode 100644 index 000000000..df422d8c2 --- /dev/null +++ b/test/spreadOver/spreadOver.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const spreadOver = require('./spreadOver.js'); + + + test('spreadOver is a Function', () => { + expect(spreadOver).toBeInstanceOf(Function); +}); + const arrayMax = spreadOver(Math.max); + t.equal(arrayMax([1, 2, 3]), 3, "Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function."); + diff --git a/test6/stableSort/stableSort.js b/test/stableSort/stableSort.js similarity index 100% rename from test6/stableSort/stableSort.js rename to test/stableSort/stableSort.js diff --git a/test/stableSort/stableSort.test.js b/test/stableSort/stableSort.test.js new file mode 100644 index 000000000..2f54e14ee --- /dev/null +++ b/test/stableSort/stableSort.test.js @@ -0,0 +1,13 @@ +const expect = require('expect'); +const stableSort = require('./stableSort.js'); + + + test('stableSort is a Function', () => { + expect(stableSort).toBeInstanceOf(Function); +}); + + const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + const compare = () => 0; + t.deepEqual(stableSort(arr, compare), arr, 'Array is properly sorted'); + + diff --git a/test6/standardDeviation/standardDeviation.js b/test/standardDeviation/standardDeviation.js similarity index 100% rename from test6/standardDeviation/standardDeviation.js rename to test/standardDeviation/standardDeviation.js diff --git a/test/standardDeviation/standardDeviation.test.js b/test/standardDeviation/standardDeviation.test.js new file mode 100644 index 000000000..9ddfb23d0 --- /dev/null +++ b/test/standardDeviation/standardDeviation.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const standardDeviation = require('./standardDeviation.js'); + + + test('standardDeviation is a Function', () => { + expect(standardDeviation).toBeInstanceOf(Function); +}); + t.equal(standardDeviation([10, 2, 38, 23, 38, 23, 21]), 13.284434142114991, "Returns the standard deviation of an array of numbers"); + t.equal(standardDeviation([10, 2, 38, 23, 38, 23, 21], true), 12.29899614287479, "Returns the standard deviation of an array of numbers"); + diff --git a/test6/stringPermutations/stringPermutations.js b/test/stringPermutations/stringPermutations.js similarity index 100% rename from test6/stringPermutations/stringPermutations.js rename to test/stringPermutations/stringPermutations.js diff --git a/test/stringPermutations/stringPermutations.test.js b/test/stringPermutations/stringPermutations.test.js new file mode 100644 index 000000000..a99fb7b23 --- /dev/null +++ b/test/stringPermutations/stringPermutations.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const stringPermutations = require('./stringPermutations.js'); + + + test('stringPermutations is a Function', () => { + expect(stringPermutations).toBeInstanceOf(Function); +}); + t.deepEqual(stringPermutations('abc'), ['abc','acb','bac','bca','cab','cba'], "Generates all stringPermutations of a string"); + t.deepEqual(stringPermutations('a'), ['a'], "Works for single-letter strings"); + t.deepEqual(stringPermutations(''), [''], "Works for empty strings"); + + diff --git a/test6/stripHTMLTags/stripHTMLTags.js b/test/stripHTMLTags/stripHTMLTags.js similarity index 100% rename from test6/stripHTMLTags/stripHTMLTags.js rename to test/stripHTMLTags/stripHTMLTags.js diff --git a/test/stripHTMLTags/stripHTMLTags.test.js b/test/stripHTMLTags/stripHTMLTags.test.js new file mode 100644 index 000000000..225f18573 --- /dev/null +++ b/test/stripHTMLTags/stripHTMLTags.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const stripHTMLTags = require('./stripHTMLTags.js'); + + + test('stripHTMLTags is a Function', () => { + expect(stripHTMLTags).toBeInstanceOf(Function); +}); + test('Removes HTML tags', () => { + expect(stripHTMLTags('

lorem ipsum


'), 'lorem ipsum').toBe() +}); + + diff --git a/test6/sum/sum.js b/test/sum/sum.js similarity index 100% rename from test6/sum/sum.js rename to test/sum/sum.js diff --git a/test/sum/sum.test.js b/test/sum/sum.test.js new file mode 100644 index 000000000..ed21ad02f --- /dev/null +++ b/test/sum/sum.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const sum = require('./sum.js'); + + + test('sum is a Function', () => { + expect(sum).toBeInstanceOf(Function); +}); + t.equal(sum(...[1, 2, 3, 4]), 10, "Returns the sum of two or more numbers/arrays."); + diff --git a/test6/sumBy/sumBy.js b/test/sumBy/sumBy.js similarity index 100% rename from test6/sumBy/sumBy.js rename to test/sumBy/sumBy.js diff --git a/test/sumBy/sumBy.test.js b/test/sumBy/sumBy.test.js new file mode 100644 index 000000000..a8786d296 --- /dev/null +++ b/test/sumBy/sumBy.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const sumBy = require('./sumBy.js'); + + + test('sumBy is a Function', () => { + expect(sumBy).toBeInstanceOf(Function); +}); + diff --git a/test6/sumPower/sumPower.js b/test/sumPower/sumPower.js similarity index 100% rename from test6/sumPower/sumPower.js rename to test/sumPower/sumPower.js diff --git a/test/sumPower/sumPower.test.js b/test/sumPower/sumPower.test.js new file mode 100644 index 000000000..17f5a1433 --- /dev/null +++ b/test/sumPower/sumPower.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const sumPower = require('./sumPower.js'); + + + test('sumPower is a Function', () => { + expect(sumPower).toBeInstanceOf(Function); +}); + t.equal(sumPower(10), 385, "Returns the sum of the powers of all the numbers from start to end"); + t.equal(sumPower(10, 3), 3025, "Returns the sum of the powers of all the numbers from start to end"); + t.equal(sumPower(10, 3, 5), 2925, "Returns the sum of the powers of all the numbers from start to end"); + diff --git a/test6/symmetricDifference/symmetricDifference.js b/test/symmetricDifference/symmetricDifference.js similarity index 100% rename from test6/symmetricDifference/symmetricDifference.js rename to test/symmetricDifference/symmetricDifference.js diff --git a/test/symmetricDifference/symmetricDifference.test.js b/test/symmetricDifference/symmetricDifference.test.js new file mode 100644 index 000000000..4874b7544 --- /dev/null +++ b/test/symmetricDifference/symmetricDifference.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const symmetricDifference = require('./symmetricDifference.js'); + + + test('symmetricDifference is a Function', () => { + expect(symmetricDifference).toBeInstanceOf(Function); +}); + t.deepEqual(symmetricDifference([1, 2, 3], [1, 2, 4]), [3, 4], "Returns the symmetric difference between two arrays."); + diff --git a/test6/symmetricDifferenceBy/symmetricDifferenceBy.js b/test/symmetricDifferenceBy/symmetricDifferenceBy.js similarity index 100% rename from test6/symmetricDifferenceBy/symmetricDifferenceBy.js rename to test/symmetricDifferenceBy/symmetricDifferenceBy.js diff --git a/test/symmetricDifferenceBy/symmetricDifferenceBy.test.js b/test/symmetricDifferenceBy/symmetricDifferenceBy.test.js new file mode 100644 index 000000000..43e69f13c --- /dev/null +++ b/test/symmetricDifferenceBy/symmetricDifferenceBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const symmetricDifferenceBy = require('./symmetricDifferenceBy.js'); + + + test('symmetricDifferenceBy is a Function', () => { + expect(symmetricDifferenceBy).toBeInstanceOf(Function); +}); + t.deepEqual(symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor), [ 1.2, 3.4 ], 'Returns the symmetric difference between two arrays, after applying the provided function to each array element of both'); + + diff --git a/test6/symmetricDifferenceWith/symmetricDifferenceWith.js b/test/symmetricDifferenceWith/symmetricDifferenceWith.js similarity index 100% rename from test6/symmetricDifferenceWith/symmetricDifferenceWith.js rename to test/symmetricDifferenceWith/symmetricDifferenceWith.js diff --git a/test/symmetricDifferenceWith/symmetricDifferenceWith.test.js b/test/symmetricDifferenceWith/symmetricDifferenceWith.test.js new file mode 100644 index 000000000..33f65acae --- /dev/null +++ b/test/symmetricDifferenceWith/symmetricDifferenceWith.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const symmetricDifferenceWith = require('./symmetricDifferenceWith.js'); + + + test('symmetricDifferenceWith is a Function', () => { + expect(symmetricDifferenceWith).toBeInstanceOf(Function); +}); + t.deepEqual(symmetricDifferenceWith( + [1, 1.2, 1.5, 3, 0], + [1.9, 3, 0, 3.9], + (a, b) => Math.round(a) === Math.round(b) +), [1, 1.2, 3.9], 'Returns the symmetric difference between two arrays, using a provided function as a comparator'); + + diff --git a/test6/tail/tail.js b/test/tail/tail.js similarity index 100% rename from test6/tail/tail.js rename to test/tail/tail.js diff --git a/test/tail/tail.test.js b/test/tail/tail.test.js new file mode 100644 index 000000000..df77407cf --- /dev/null +++ b/test/tail/tail.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const tail = require('./tail.js'); + + + test('tail is a Function', () => { + expect(tail).toBeInstanceOf(Function); +}); + t.deepEqual(tail([1, 2, 3]), [2, 3], "Returns tail"); + t.deepEqual(tail([1]), [1], "Returns tail"); + diff --git a/test6/take/take.js b/test/take/take.js similarity index 100% rename from test6/take/take.js rename to test/take/take.js diff --git a/test/take/take.test.js b/test/take/take.test.js new file mode 100644 index 000000000..2a71a1476 --- /dev/null +++ b/test/take/take.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const take = require('./take.js'); + + + test('take is a Function', () => { + expect(take).toBeInstanceOf(Function); +}); + t.deepEqual(take([1, 2, 3], 5), [1, 2, 3], "Returns an array with n elements removed from the beginning."); + t.deepEqual(take([1, 2, 3], 0), [], "Returns an array with n elements removed from the beginning."); + + diff --git a/test6/takeRight/takeRight.js b/test/takeRight/takeRight.js similarity index 100% rename from test6/takeRight/takeRight.js rename to test/takeRight/takeRight.js diff --git a/test/takeRight/takeRight.test.js b/test/takeRight/takeRight.test.js new file mode 100644 index 000000000..ae144bb02 --- /dev/null +++ b/test/takeRight/takeRight.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const takeRight = require('./takeRight.js'); + + + test('takeRight is a Function', () => { + expect(takeRight).toBeInstanceOf(Function); +}); + t.deepEqual(takeRight([1, 2, 3], 2), [2, 3], "Returns an array with n elements removed from the end"); + t.deepEqual(takeRight([1, 2, 3]), [3], "Returns an array with n elements removed from the end"); + diff --git a/test6/takeRightWhile/takeRightWhile.js b/test/takeRightWhile/takeRightWhile.js similarity index 100% rename from test6/takeRightWhile/takeRightWhile.js rename to test/takeRightWhile/takeRightWhile.js diff --git a/test/takeRightWhile/takeRightWhile.test.js b/test/takeRightWhile/takeRightWhile.test.js new file mode 100644 index 000000000..d300b3651 --- /dev/null +++ b/test/takeRightWhile/takeRightWhile.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const takeRightWhile = require('./takeRightWhile.js'); + + + test('takeRightWhile is a Function', () => { + expect(takeRightWhile).toBeInstanceOf(Function); +}); + t.deepEqual(takeRightWhile([1, 2, 3, 4], n => n < 3), [3, 4], 'Removes elements until the function returns true'); + + diff --git a/test6/takeWhile/takeWhile.js b/test/takeWhile/takeWhile.js similarity index 100% rename from test6/takeWhile/takeWhile.js rename to test/takeWhile/takeWhile.js diff --git a/test/takeWhile/takeWhile.test.js b/test/takeWhile/takeWhile.test.js new file mode 100644 index 000000000..a8949edf4 --- /dev/null +++ b/test/takeWhile/takeWhile.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const takeWhile = require('./takeWhile.js'); + + + test('takeWhile is a Function', () => { + expect(takeWhile).toBeInstanceOf(Function); +}); + t.deepEqual(takeWhile([1, 2, 3, 4], n => n >= 3), [1, 2], 'Removes elements until the function returns true'); + + diff --git a/test/testlog b/test/testlog new file mode 100644 index 000000000..790dd2119 --- /dev/null +++ b/test/testlog @@ -0,0 +1,2054 @@ +Test log for: Sun Jun 17 2018 21:26:15 GMT+0000 (Coordinated Universal Time) + +> 30-seconds-of-code@0.0.3 test /home/travis/build/Chalarangelo/30-seconds-of-code +> tape test/**/*.test.js | tap-spec + + + Testing JSONToDate + + ✔ JSONToDate is a Function + + Testing JSONToFile + + ✔ JSONToFile is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing RGBToHex + + ✔ RGBToHex is a Function + ✔ Converts the values of RGB components to a color code. + + Testing URLJoin + + ✔ URLJoin is a Function + ✔ Returns proper URL + ✔ Returns proper URL + + Testing UUIDGeneratorBrowser + + ✔ UUIDGeneratorBrowser is a Function + ✔ Tested 09/02/2018 by @chalarangelo + + Testing UUIDGeneratorNode + + ✔ UUIDGeneratorNode is a Function + ✔ Contains dashes in the proper places + ✔ Only contains hexadecimal digits + + Testing all + + ✔ all is a Function + ✔ Returns true for arrays with no falsey values + ✔ Returns false for arrays with 0 + ✔ Returns false for arrays with NaN + ✔ Returns false for arrays with undefined + ✔ Returns false for arrays with null + ✔ Returns false for arrays with empty strings + ✔ Returns true with predicate function + ✔ Returns false with a predicate function + + Testing any + + ✔ any is a Function + ✔ Returns true for arrays with at least one truthy value + ✔ Returns false for arrays with no truthy values + ✔ Returns false for arrays with no truthy values + ✔ Returns true with predicate function + ✔ Returns false with a predicate function + + Testing approximatelyEqual + + ✔ approximatelyEqual is a Function + ✔ Works for PI / 2 + ✔ Works for 0.1 + 0.2 === 0.3 + ✔ Works for exactly equal values + ✔ Works for a custom epsilon + + Testing arrayToHtmlList + + ✔ arrayToHtmlList is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing ary + + ✔ ary is a Function + ✔ Discards arguments with index >=n + + Testing atob + + ✔ atob is a Function + ✔ atob("Zm9vYmFy") equals "foobar" + ✔ atob("Z") returns "" + + Testing attempt + + ✔ attempt is a Function + ✔ Returns a value + ✔ Returns an error + + Testing average + + ✔ average is a Function + ✔ average(true) returns 0 + ✔ average(false) returns 1 + ✔ average(9, 1) returns 5 + ✔ average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 + ✔ average(1, 2, 3) returns 2 + ✔ average(null) returns 0 + ✔ average(1, 2, 3) returns NaN + ✔ average(String) returns NaN + ✔ average({ a: 123}) returns NaN + ✔ average([undefined, 0, string]) returns NaN + ✔ average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + + Testing averageBy + + ✔ averageBy is a Function + ✔ Produces the right result with a function + ✔ Produces the right result with a property name + + Testing bifurcate + + ✔ bifurcate is a Function + ✔ Splits the collection into two groups + + Testing bifurcateBy + + ✔ bifurcateBy is a Function + ✔ Splits the collection into two groups + + Testing binarySearch + + ✔ binarySearch is a Function + ✔ Finds item in array + ✔ Returns -1 when not found + ✔ Works with empty arrays + ✔ Works for one element arrays + + Testing bind + + ✔ bind is a Function + ✔ Binds to an object context + + Testing bindAll + + ✔ bindAll is a Function + ✔ Binds to an object context + + Testing bindKey + + ✔ bindKey is a Function + ✔ Binds function to an object context + + Testing binomialCoefficient + + ✔ binomialCoefficient is a Function + ✔ Returns the appropriate value + ✔ Returns the appropriate value + ✔ Returns the appropriate value + ✔ Returns NaN + ✔ Returns NaN + + Testing bottomVisible + + ✔ bottomVisible is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing btoa + + ✔ btoa is a Function + ✔ btoa("foobar") equals "Zm9vYmFy" + + Testing byteSize + + ✔ byteSize is a Function + ✔ Works for a single letter + ✔ Works for a common string + ✔ Works for emoji + + Testing call + + ✔ call is a Function + ✔ Calls function on given object + + Testing capitalize + + ✔ capitalize is a Function + ✔ Capitalizes the first letter of a string + ✔ Capitalizes the first letter of a string + ✔ Works with characters + ✔ Works with single character words + + Testing capitalizeEveryWord + + ✔ capitalizeEveryWord is a Function + ✔ Capitalizes the first letter of every word in a string + ✔ Works with characters + ✔ Works with one word string + + Testing castArray + + ✔ castArray is a Function + ✔ Works for single values + ✔ Works for arrays with one value + ✔ Works for arrays with multiple value + ✔ Works for strings + ✔ Works for objects + + Testing chainAsync + + ✔ chainAsync is a Function + ✔ Calls all functions in an array + + Testing chunk + + ✔ chunk is a Function + ✔ chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] + ✔ chunk([]) returns [] + ✔ chunk(123) returns [] + ✔ chunk({ a: 123}) returns [] + ✔ chunk(string, 2) returns [ st, ri, ng ] + ✔ chunk() throws an error + ✔ chunk(undefined) throws an error + ✔ chunk(null) throws an error + ✔ chunk(This is a string, 2) takes less than 2s to run + + Testing clampNumber + + ✔ clampNumber is a Function + ✔ Clamps num within the inclusive range specified by the boundary values a and b + + Testing cleanObj + + ✔ cleanObj is a Function + ✔ Removes any properties except the ones specified from a JSON object + + Testing cloneRegExp + + ✔ cloneRegExp is a Function + ✔ Clones regular expressions properly + + Testing coalesce + + ✔ coalesce is a Function + ✔ Returns the first non-null/undefined argument + + Testing coalesceFactory + + ✔ coalesceFactory is a Function + ✔ Returns a customized coalesce function + + Testing collatz + + ✔ collatz is a Function + ✔ When n is even, divide by 2 + ✔ When n is odd, times by 3 and add 1 + ✔ Eventually reaches 1 + + Testing collectInto + + ✔ collectInto is a Function + + Testing colorize + + ✔ colorize is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing compact + + ✔ compact is a Function + ✔ Removes falsey values from an array + + Testing compose + + ✔ compose is a Function + ✔ Performs right-to-left function composition + + Testing composeRight + + ✔ composeRight is a Function + ✔ Performs left-to-right function composition + + Testing converge + + ✔ converge is a Function + ✔ Produces the average of the array + ✔ Produces the strange concatenation + + Testing copyToClipboard + + ✔ copyToClipboard is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing countBy + + ✔ countBy is a Function + ✔ Works for functions + ✔ Works for property names + + Testing countOccurrences + + ✔ countOccurrences is a Function + ✔ Counts the occurrences of a value in an array + + Testing countVowels + + ✔ countVowels is a Function + + Testing counter + + ✔ counter is a Function + + Testing createElement + + ✔ createElement is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing createEventHub + + ✔ createEventHub is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing currentURL + + ✔ currentURL is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing curry + + ✔ curry is a Function + ✔ curries a Math.pow + ✔ curries a Math.min + + Testing debounce + + ✔ debounce is a Function + + Testing decapitalize + + ✔ decapitalize is a Function + ✔ Works with default parameter + ✔ Works with second parameter set to true + + Testing deepClone + + ✔ deepClone is a Function + ✔ Shallow cloning works + ✔ Deep cloning works + ✔ Array shallow cloning works + ✔ Array deep cloning works + + Testing deepFlatten + + ✔ deepFlatten is a Function + ✔ Deep flattens an array + + Testing defaults + + ✔ defaults is a Function + ✔ Assigns default values for undefined properties + + Testing defer + + ✔ defer is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing degreesToRads + + ✔ degreesToRads is a Function + ✔ Returns the appropriate value + + Testing delay + + ✔ delay is a Function + + Testing detectDeviceType + + ✔ detectDeviceType is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing difference + + ✔ difference is a Function + ✔ Returns the difference between two arrays + + Testing differenceBy + + ✔ differenceBy is a Function + ✔ Works using a native function and numbers + ✔ Works with arrow function and objects + + Testing differenceWith + + ✔ differenceWith is a Function + ✔ Filters out all values from an array + + Testing digitize + + ✔ digitize is a Function + ✔ Converts a number to an array of digits + + Testing distance + + ✔ distance is a Function + ✔ Calculates the distance between two points + + Testing drop + + ✔ drop is a Function + ✔ Works without the last argument + ✔ Removes appropriate element count as specified + ✔ Empties array given a count greater than length + + Testing dropRight + + ✔ dropRight is a Function + ✔ Returns a new array with n elements removed from the right + ✔ Returns a new array with n elements removed from the right + ✔ Returns a new array with n elements removed from the right + + Testing dropRightWhile + + ✔ dropRightWhile is a Function + ✔ Removes elements from the end of an array until the passed function returns true. + + Testing dropWhile + + ✔ dropWhile is a Function + ✔ Removes elements in an array until the passed function returns true. + + Testing elementIsVisibleInViewport + + ✔ elementIsVisibleInViewport is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing elo + + ✔ elo is a Function + ✔ Standard 1v1s + ✔ should be equivalent + ✔ 4 player FFA, all same rank + + Testing equals + + ✔ equals is a Function + ✔ { a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' } + ✔ [1,2,3] is equal to [1,2,3] + ✔ { a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] } + ✔ [1,2,3] is not equal to [1,2,4] + ✔ [1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match. + + Testing escapeHTML + + ✔ escapeHTML is a Function + ✔ Escapes a string for use in HTML + + Testing escapeRegExp + + ✔ escapeRegExp is a Function + ✔ Escapes a string to use in a regular expression + + Testing everyNth + + ✔ everyNth is a Function + ✔ Returns every nth element in an array + + Testing extendHex + + ✔ extendHex is a Function + ✔ Extends a 3-digit color code to a 6-digit color code + ✔ Extends a 3-digit color code to a 6-digit color code + + Testing factorial + + ✔ factorial is a Function + ✔ Calculates the factorial of 720 + ✔ Calculates the factorial of 0 + ✔ Calculates the factorial of 1 + ✔ Calculates the factorial of 4 + ✔ Calculates the factorial of 10 + + Testing factors + + ✔ factors is a Function + + Testing fibonacci + + ✔ fibonacci is a Function + ✔ Generates an array, containing the Fibonacci sequence + + Testing fibonacciCountUntilNum + + ✔ fibonacciCountUntilNum is a Function + + Testing fibonacciUntilNum + + ✔ fibonacciUntilNum is a Function + + Testing filterNonUnique + + ✔ filterNonUnique is a Function + ✔ Filters out the non-unique values in an array + + Testing findKey + + ✔ findKey is a Function + ✔ Returns the appropriate key + + Testing findLast + + ✔ findLast is a Function + ✔ Finds last element for which the given function returns true + + Testing findLastIndex + + ✔ findLastIndex is a Function + ✔ Finds last index for which the given function returns true + + Testing findLastKey + + ✔ findLastKey is a Function + ✔ Returns the appropriate key + + Testing flatten + + ✔ flatten is a Function + ✔ Flattens an array + ✔ Flattens an array + + Testing flattenObject + + ✔ flattenObject is a Function + ✔ Flattens an object with the paths for keys + ✔ Works with arrays + + Testing flip + + ✔ flip is a Function + ✔ Flips argument order + + Testing forEachRight + + ✔ forEachRight is a Function + ✔ Iterates over the array in reverse + + Testing forOwn + + ✔ forOwn is a Function + ✔ Iterates over an element's key-value pairs + + Testing forOwnRight + + ✔ forOwnRight is a Function + ✔ Iterates over an element's key-value pairs in reverse + + Testing formatDuration + + ✔ formatDuration is a Function + ✔ Returns the human readable format of the given number of milliseconds + ✔ Returns the human readable format of the given number of milliseconds + + Testing fromCamelCase + + ✔ fromCamelCase is a Function + ✔ Converts a string from camelcase + ✔ Converts a string from camelcase + ✔ Converts a string from camelcase + + Testing functionName + + ✔ functionName is a Function + ✔ Works for native functions + ✔ Works for functions + ✔ Works for arrow functions + + Testing functions + + ✔ functions is a Function + ✔ Returns own methods + ✔ Returns own and inherited methods + + Testing gcd + + ✔ gcd is a Function + ✔ Calculates the greatest common divisor between two or more numbers/arrays + ✔ Calculates the greatest common divisor between two or more numbers/arrays + + Testing geometricProgression + + ✔ geometricProgression is a Function + ✔ Initializes an array containing the numbers in the specified range + ✔ Initializes an array containing the numbers in the specified range + ✔ Initializes an array containing the numbers in the specified range + + Testing get + + ✔ get is a Function + ✔ Retrieve a property indicated by the selector from an object. + + Testing getColonTimeFromDate + + ✔ getColonTimeFromDate is a Function + + Testing getDaysDiffBetweenDates + + ✔ getDaysDiffBetweenDates is a Function + ✔ Returns the difference in days between two dates + + Testing getMeridiemSuffixOfInteger + + ✔ getMeridiemSuffixOfInteger is a Function + + Testing getScrollPosition + + ✔ getScrollPosition is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing getStyle + + ✔ getStyle is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing getType + + ✔ getType is a Function + ✔ Returns the native type of a value + + Testing getURLParameters + + ✔ getURLParameters is a Function + ✔ Returns an object containing the parameters of the current URL + + Testing groupBy + + ✔ groupBy is a Function + ✔ Groups the elements of an array based on the given function + ✔ Groups the elements of an array based on the given function + + Testing hammingDistance + + ✔ hammingDistance is a Function + ✔ retuns hamming disance between 2 values + + Testing hasClass + + ✔ hasClass is a Function + + Testing hasFlags + + ✔ hasFlags is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing hashBrowser + + ✔ hashBrowser is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing hashNode + + ✔ hashNode is a Function + + Testing head + + ✔ head is a Function + ✔ head({ a: 1234}) returns undefined + ✔ head([1, 2, 3]) returns 1 + ✔ head({ 0: false}) returns false + ✔ head(String) returns S + ✔ head(null) throws an Error + ✔ head(undefined) throws an Error + ✔ head() throws an Error + ✔ head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + + Testing hexToRGB + + ✔ hexToRGB is a Function + ✔ Converts a color code to a rgb() or rgba() string + ✔ Converts a color code to a rgb() or rgba() string + ✔ Converts a color code to a rgb() or rgba() string + + Testing hide + + ✔ hide is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing howManyTimes + + ✔ howManyTimes is a Function + + Testing httpDelete + + ✔ httpDelete is a Function + + Testing httpGet + + ✔ httpGet is a Function + + Testing httpPost + + ✔ httpPost is a Function + + Testing httpPut + + ✔ httpPut is a Function + + Testing httpsRedirect + + ✔ httpsRedirect is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing hz + + ✔ hz is a Function + + Testing inRange + + ✔ inRange is a Function + ✔ The given number falls within the given range + ✔ The given number falls within the given range + ✔ The given number does not falls within the given range + ✔ The given number does not falls within the given range + + Testing indexOfAll + + ✔ indexOfAll is a Function + ✔ Returns all indices of val in an array + ✔ Returns all indices of val in an array + + Testing initial + + ✔ initial is a Function + ✔ Returns all the elements of an array except the last one + + Testing initialize2DArray + + ✔ initialize2DArray is a Function + ✔ Initializes a 2D array of given width and height and value + + Testing initializeArrayWithRange + + ✔ initializeArrayWithRange is a Function + ✔ Initializes an array containing the numbers in the specified range + + Testing initializeArrayWithRangeRight + + ✔ initializeArrayWithRangeRight is a Function + + Testing initializeArrayWithValues + + ✔ initializeArrayWithValues is a Function + ✔ Initializes and fills an array with the specified values + + Testing initializeNDArray + + ✔ initializeNDArray is a Function + + Testing intersection + + ✔ intersection is a Function + ✔ Returns a list of elements that exist in both arrays + + Testing intersectionBy + + ✔ intersectionBy is a Function + ✔ Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both + + Testing intersectionWith + + ✔ intersectionWith is a Function + ✔ Returns a list of elements that exist in both arrays, using a provided comparator function + + Testing invertKeyValues + + ✔ invertKeyValues is a Function + ✔ invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] } + ✔ invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] } + + Testing is + + ✔ is is a Function + ✔ Works for arrays with data + ✔ Works for empty arrays + ✔ Works for arrays, not objects + ✔ Works for objects + ✔ Works for maps + ✔ Works for regular expressions + ✔ Works for sets + ✔ Works for weak maps + ✔ Works for weak sets + ✔ Works for strings - returns true for primitive + ✔ Works for strings - returns true when using constructor + ✔ Works for numbers - returns true for primitive + ✔ Works for numbers - returns true when using constructor + ✔ Works for booleans - returns true for primitive + ✔ Works for booleans - returns true when using constructor + ✔ Works for functions + + Testing isAbsoluteURL + + ✔ isAbsoluteURL is a Function + ✔ Given string is an absolute URL + ✔ Given string is an absolute URL + ✔ Given string is not an absolute URL + + Testing isAnagram + + ✔ isAnagram is a Function + ✔ Checks valid anagram + ✔ Works with spaces + ✔ Ignores case + ✔ Ignores special characters + + Testing isArmstrongNumber + + ✔ isArmstrongNumber is a Function + + Testing isArray + + ✔ isArray is a Function + ✔ passed value is an array + ✔ passed value is not an array + + Testing isArrayBuffer + + ✔ isArrayBuffer is a Function + + Testing isArrayLike + + ✔ isArrayLike is a Function + ✔ Returns true for a string + ✔ Returns true for an array + ✔ Returns false for null + + Testing isBoolean + + ✔ isBoolean is a Function + ✔ passed value is not a boolean + ✔ passed value is not a boolean + + Testing isBrowser + + ✔ isBrowser is a Function + + Testing isBrowserTabFocused + + ✔ isBrowserTabFocused is a Function + + Testing isDivisible + + ✔ isDivisible is a Function + ✔ The number 6 is divisible by 3 + + Testing isEmpty + + ✔ isEmpty is a Function + ✔ Returns true for empty Map + ✔ Returns true for empty Set + ✔ Returns true for empty array + ✔ Returns true for empty object + ✔ Returns true for empty string + ✔ Returns false for non-empty array + ✔ Returns false for non-empty object + ✔ Returns false for non-empty string + ✔ Returns true - type is not considered a collection + ✔ Returns true - type is not considered a collection + + Testing isEven + + ✔ isEven is a Function + ✔ 4 is even number + ✔ undefined + + Testing isFunction + + ✔ isFunction is a Function + ✔ passed value is a function + ✔ passed value is not a function + + Testing isLowerCase + + ✔ isLowerCase is a Function + ✔ passed string is a lowercase + ✔ passed string is a lowercase + ✔ passed value is not a lowercase + + Testing isMap + + ✔ isMap is a Function + + Testing isNil + + ✔ isNil is a Function + ✔ Returns true for null + ✔ Returns true for undefined + ✔ Returns false for an empty string + + Testing isNull + + ✔ isNull is a Function + ✔ passed argument is a null + ✔ passed argument is a null + + Testing isNumber + + ✔ isNumber is a Function + ✔ passed argument is a number + ✔ passed argument is not a number + + Testing isObject + + ✔ isObject is a Function + ✔ isObject([1, 2, 3, 4]) is a object + ✔ isObject([]) is a object + ✔ isObject({ a:1 }) is a object + ✔ isObject(true) is not a object + + Testing isObjectLike + + ✔ isObjectLike is a Function + ✔ Returns true for an object + ✔ Returns true for an array + ✔ Returns false for a function + ✔ Returns false for null + + Testing isPlainObject + + ✔ isPlainObject is a Function + ✔ Returns true for a plain object + ✔ Returns false for a Map (example of non-plain object) + + Testing isPrime + + ✔ isPrime is a Function + ✔ passed number is a prime + + Testing isPrimitive + + ✔ isPrimitive is a Function + ✔ isPrimitive(null) is primitive + ✔ isPrimitive(undefined) is primitive + ✔ isPrimitive(string) is primitive + ✔ isPrimitive(true) is primitive + ✔ isPrimitive(50) is primitive + ✔ isPrimitive('Hello') is primitive + ✔ isPrimitive(false) is primitive + ✔ isPrimitive(Symbol()) is primitive + ✔ isPrimitive([1, 2, 3]) is not primitive + ✔ isPrimitive({ a: 123 }) is not primitive + ✔ isPrimitive({ a: 123 }) takes less than 2s to run + + Testing isPromiseLike + + ✔ isPromiseLike is a Function + ✔ Returns true for a promise-like object + ✔ Returns false for null + ✔ Returns false for an empty object + + Testing isRegExp + + ✔ isRegExp is a Function + + Testing isSet + + ✔ isSet is a Function + + Testing isSimilar + + ✔ isSimilar is a Function + + Testing isSorted + + ✔ isSorted is a Function + ✔ Array is sorted in ascending order + ✔ Array is sorted in ascending order + ✔ Array is sorted in ascending order + ✔ Array is sorted in ascending order + ✔ Array is sorted in descending order + ✔ Array is sorted in descending order + ✔ Array is sorted in descending order + ✔ Array is sorted in descending order + ✔ Array is empty + ✔ Array is not sorted, direction changed in array + ✔ Array is not sorted, direction changed in array + + Testing isString + + ✔ isString is a Function + ✔ foo is a string + ✔ "10" is a string + ✔ Empty string is a string + ✔ 10 is not a string + ✔ true is not string + + Testing isSymbol + + ✔ isSymbol is a Function + ✔ Checks if the given argument is a symbol + + Testing isTravisCI + + ✔ isTravisCI is a Function + ✔ Running on Travis, correctly evaluates + + Testing isTypedArray + + ✔ isTypedArray is a Function + + Testing isUndefined + + ✔ isUndefined is a Function + ✔ Returns true for undefined + + Testing isUpperCase + + ✔ isUpperCase is a Function + ✔ ABC is all upper case + ✔ abc is not all upper case + ✔ A3@$ is all uppercase + + Testing isValidJSON + + ✔ isValidJSON is a Function + ✔ {"name":"Adam","age":20} is a valid JSON + ✔ {"name":"Adam",age:"20"} is not a valid JSON + ✔ null is a valid JSON + + Testing isWeakMap + + ✔ isWeakMap is a Function + + Testing isWeakSet + + ✔ isWeakSet is a Function + + Testing join + + ✔ join is a Function + ✔ Joins all elements of an array into a string and returns this string + ✔ Joins all elements of an array into a string and returns this string + ✔ Joins all elements of an array into a string and returns this string + + Testing last + + ✔ last is a Function + ✔ last({ a: 1234}) returns undefined + ✔ last([1, 2, 3]) returns 3 + ✔ last({ 0: false}) returns undefined + ✔ last(String) returns g + ✔ last(null) throws an Error + ✔ last(undefined) throws an Error + ✔ last() throws an Error + ✔ last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + + Testing lcm + + ✔ lcm is a Function + ✔ Returns the least common multiple of two or more numbers. + ✔ Returns the least common multiple of two or more numbers. + + Testing levenshteinDistance + + ✔ levenshteinDistance is a Function + + Testing longestItem + + ✔ longestItem is a Function + ✔ Returns the longest object + + Testing lowercaseKeys + + ✔ lowercaseKeys is a Function + ✔ Lowercases object keys + ✔ Does not mutate original object + + Testing luhnCheck + + ✔ luhnCheck is a Function + ✔ validates identification number + ✔ validates identification number + ✔ validates identification number + + Testing mapKeys + + ✔ mapKeys is a Function + ✔ Maps keys + + Testing mapObject + + ✔ mapObject is a Function + ✔ mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 } + ✔ mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 } + ✔ mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 } + + Testing mapValues + + ✔ mapValues is a Function + ✔ Maps values + + Testing mask + + ✔ mask is a Function + ✔ Replaces all but the last num of characters with the specified mask character + ✔ Replaces all but the last num of characters with the specified mask character + ✔ Replaces all but the last num of characters with the specified mask character + + Testing matches + + ✔ matches is a Function + ✔ Matches returns true for two similar objects + ✔ Matches returns false for two non-similar objects + + Testing matchesWith + + ✔ matchesWith is a Function + ✔ Returns true for two objects with similar values, based on the provided function + + Testing maxBy + + ✔ maxBy is a Function + ✔ Produces the right result with a function + ✔ Produces the right result with a property name + + Testing maxN + + ✔ maxN is a Function + ✔ Returns the n maximum elements from the provided array + ✔ Returns the n maximum elements from the provided array + + Testing median + + ✔ median is a Function + ✔ Returns the median of an array of numbers + ✔ Returns the median of an array of numbers + + Testing memoize + + ✔ memoize is a Function + ✔ Function works properly + ✔ Function works properly + ✔ Cache stores values + + Testing merge + + ✔ merge is a Function + ✔ Merges two objects + + Testing minBy + + ✔ minBy is a Function + ✔ Produces the right result with a function + ✔ Produces the right result with a property name + + Testing minN + + ✔ minN is a Function + ✔ Returns the n minimum elements from the provided array + ✔ Returns the n minimum elements from the provided array + + Testing mostPerformant + + ✔ mostPerformant is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing negate + + ✔ negate is a Function + ✔ Negates a predicate function + + Testing nest + + ✔ nest is a Function + + Testing nodeListToArray + + ✔ nodeListToArray is a Function + + Testing none + + ✔ none is a Function + ✔ Returns true for arrays with no truthy values + ✔ Returns false for arrays with at least one truthy value + ✔ Returns true with a predicate function + ✔ Returns false with predicate function + + Testing nthArg + + ✔ nthArg is a Function + ✔ Returns the nth argument + ✔ Returns undefined if arguments too few + ✔ Works for negative values + + Testing nthElement + + ✔ nthElement is a Function + ✔ Returns the nth element of an array. + ✔ Returns the nth element of an array. + + Testing objectFromPairs + + ✔ objectFromPairs is a Function + ✔ Creates an object from the given key-value pairs. + + Testing objectToPairs + + ✔ objectToPairs is a Function + ✔ Creates an array of key-value pair arrays from an object. + + Testing observeMutations + + ✔ observeMutations is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing off + + ✔ off is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing offset + + ✔ offset is a Function + ✔ Offset of 0 returns the same array. + ✔ Offset > 0 returns the offsetted array. + ✔ Offset < 0 returns the reverse offsetted array. + ✔ Offset greater than the length of the array returns the same array. + ✔ Offset less than the negative length of the array returns the same array. + ✔ Offsetting empty array returns an empty array. + + Testing omit + + ✔ omit is a Function + ✔ Omits the key-value pairs corresponding to the given keys from an object + + Testing omitBy + + ✔ omitBy is a Function + ✔ Creates an object composed of the properties the given function returns falsey for + + Testing on + + ✔ on is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing onUserInputChange + + ✔ onUserInputChange is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing once + + ✔ once is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing orderBy + + ✔ orderBy is a Function + ✔ Returns a sorted array of objects ordered by properties and orders. + ✔ Returns a sorted array of objects ordered by properties and orders. + + Testing over + + ✔ over is a Function + ✔ Applies given functions over multiple arguments + + Testing overArgs + + ✔ overArgs is a Function + ✔ Invokes the provided function with its arguments transformed + + Testing pad + + ✔ pad is a Function + ✔ cat is padded on both sides + ✔ length of string is 8 + ✔ pads 42 with "0" + ✔ does not truncates if string exceeds length + + Testing palindrome + + ✔ palindrome is a Function + ✔ Given string is a palindrome + ✔ Given string is not a palindrome + + Testing parseCookie + + ✔ parseCookie is a Function + ✔ Parses the cookie + + Testing partial + + ✔ partial is a Function + ✔ Prepends arguments + + Testing partialRight + + ✔ partialRight is a Function + ✔ Appends arguments + + Testing partition + + ✔ partition is a Function + ✔ Groups the elements into two arrays, depending on the provided function's truthiness for each element. + + Testing percentile + + ✔ percentile is a Function + ✔ Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. + + Testing permutations + + ✔ permutations is a Function + ✔ Generates all permutations of an array + + Testing pick + + ✔ pick is a Function + ✔ Picks the key-value pairs corresponding to the given keys from an object. + + Testing pickBy + + ✔ pickBy is a Function + ✔ Creates an object composed of the properties the given function returns truthy for. + + Testing pipeAsyncFunctions + + ✔ pipeAsyncFunctions is a Function + ✔ Produces the appropriate hash + ✔ pipeAsyncFunctions result should be 15 + + Testing pipeFunctions + + ✔ pipeFunctions is a Function + ✔ Performs left-to-right function composition + + Testing pluralize + + ✔ pluralize is a Function + ✔ Produces the plural of the word + ✔ Produces the singular of the word + ✔ Produces the plural of the word + ✔ Prodices the defined plural of the word + ✔ Works with a dictionary + + Testing powerset + + ✔ powerset is a Function + ✔ Returns the powerset of a given array of numbers. + + Testing prefix + + ✔ prefix is a Function + + Testing prettyBytes + + ✔ prettyBytes is a Function + ✔ Converts a number in bytes to a human-readable string. + ✔ Converts a number in bytes to a human-readable string. + ✔ Converts a number in bytes to a human-readable string. + + Testing primes + + ✔ primes is a Function + ✔ Generates primes up to a given number, using the Sieve of Eratosthenes. + + Testing promisify + + ✔ promisify is a Function + ✔ Returns a promise + + Testing pull + + ✔ pull is a Function + ✔ Pulls the specified values + + Testing pullAtIndex + + ✔ pullAtIndex is a Function + ✔ Pulls the given values + ✔ Pulls the given values + + Testing pullAtValue + + ✔ pullAtValue is a Function + ✔ Pulls the specified values + ✔ Pulls the specified values + + Testing pullBy + + ✔ pullBy is a Function + ✔ Pulls the specified values + + Testing quickSort + + ✔ quickSort is a Function + ✔ quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] + ✔ quickSort([-1, 0, -2]) returns [-2, -1, 0] + ✔ quickSort() throws an error + ✔ quickSort(123) throws an error + ✔ quickSort({ 234: string}) throws an error + ✔ quickSort(null) throws an error + ✔ quickSort(undefined) throws an error + ✔ quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run + + Testing radsToDegrees + + ✔ radsToDegrees is a Function + ✔ Returns the appropriate value + + Testing randomHexColorCode + + ✔ randomHexColorCode is a Function + ✔ should be equal + ✔ The color code starts with "#" + ✔ The color code contains only valid hex-digits + + Testing randomIntArrayInRange + + ✔ randomIntArrayInRange is a Function + ✔ The returned array contains only integers + ✔ The returned array has the proper length + ✔ The returned array's values lie between provided lowerLimit and upperLimit (both inclusive). + + Testing randomIntegerInRange + + ✔ randomIntegerInRange is a Function + ✔ The returned value is an integer + ✔ The returned value lies between provided lowerLimit and upperLimit (both inclusive). + + Testing randomNumberInRange + + ✔ randomNumberInRange is a Function + ✔ The returned value is a number + ✔ The returned value lies between provided lowerLimit and upperLimit (both inclusive). + + Testing readFileLines + + ✔ readFileLines is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing rearg + + ✔ rearg is a Function + ✔ Reorders arguments in invoked function + + Testing recordAnimationFrames + + ✔ recordAnimationFrames is a Function + + Testing redirect + + ✔ redirect is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing reduceSuccessive + + ✔ reduceSuccessive is a Function + ✔ Returns the array of successively reduced values + + Testing reduceWhich + + ✔ reduceWhich is a Function + ✔ Returns the minimum of an array + ✔ Returns the maximum of an array + ✔ Returns the object with the minimum specified value in an array + + Testing reducedFilter + + ✔ reducedFilter is a Function + ✔ Filter an array of objects based on a condition while also filtering out unspecified keys. + + Testing reject + + ✔ reject is a Function + ✔ should be equivalent + ✔ should be equivalent + + Testing remove + + ✔ remove is a Function + ✔ Removes elements from an array for which the given function returns false + + Testing removeNonASCII + + ✔ removeNonASCII is a Function + ✔ Removes non-ASCII characters + + Testing removeVowels + + ✔ removeVowels is a Function + + Testing renameKeys + + ✔ renameKeys is a Function + ✔ should be equivalent + + Testing reverseString + + ✔ reverseString is a Function + ✔ Reverses a string. + + Testing round + + ✔ round is a Function + ✔ round(1.005, 2) returns 1.01 + ✔ round(123.3423345345345345344, 11) returns 123.34233453453 + ✔ round(3.342, 11) returns 3.342 + ✔ round(1.005) returns 1 + ✔ round([1.005, 2]) returns NaN + ✔ round(string) returns NaN + ✔ round() returns NaN + ✔ round(132, 413, 4134) returns NaN + ✔ round({a: 132}, 413) returns NaN + ✔ round(123.3423345345345345344, 11) takes less than 2s to run + + Testing runAsync + + ✔ runAsync is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing runPromisesInSeries + + ✔ runPromisesInSeries is a Function + + Testing sample + + ✔ sample is a Function + ✔ Returns a random element from the array + ✔ Works for single-element arrays + ✔ Returns undefined for empty array + + Testing sampleSize + + ✔ sampleSize is a Function + ✔ Returns a single element without n specified + ✔ Returns a random sample of specified size from an array + ✔ Returns all elements in an array if n >= length + ✔ Returns an empty array if original array is empty + ✔ Returns an empty array if n = 0 + + Testing scrollToTop + + ✔ scrollToTop is a Function + ✔ Tested on 09/02/2018 by @chalarangelo + + Testing sdbm + + ✔ sdbm is a Function + ✔ Hashes the input string into a whole number. + + Testing serializeCookie + + ✔ serializeCookie is a Function + ✔ Serializes the cookie + + Testing setStyle + + ✔ setStyle is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing shallowClone + + ✔ shallowClone is a Function + ✔ Shallow cloning works + ✔ Does not clone deeply + + Testing show + + ✔ show is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing shuffle + + ✔ shuffle is a Function + ✔ Shuffles the array + ✔ New array contains all original elements + ✔ Works for empty arrays + ✔ Works for single-element arrays + + Testing similarity + + ✔ similarity is a Function + ✔ Returns an array of elements that appear in both arrays. + + Testing size + + ✔ size is a Function + ✔ Get size of arrays, objects or strings. + ✔ Get size of arrays, objects or strings. + + Testing sleep + + ✔ sleep is a Function + + Testing smoothScroll + + ✔ smoothScroll is a Function + + Testing solveRPN + + ✔ solveRPN is a Function + + Testing sortCharactersInString + + ✔ sortCharactersInString is a Function + ✔ Alphabetically sorts the characters in a string. + + Testing sortedIndex + + ✔ sortedIndex is a Function + ✔ Returns the lowest index at which value should be inserted into array in order to maintain its sort order. + ✔ Returns the lowest index at which value should be inserted into array in order to maintain its sort order. + + Testing sortedIndexBy + + ✔ sortedIndexBy is a Function + ✔ Returns the lowest index to insert the element without messing up the list order + + Testing sortedLastIndex + + ✔ sortedLastIndex is a Function + ✔ Returns the highest index to insert the element without messing up the list order + + Testing sortedLastIndexBy + + ✔ sortedLastIndexBy is a Function + ✔ Returns the highest index to insert the element without messing up the list order + + Testing speechSynthesis + + ✔ speechSynthesis is a Function + + Testing splitLines + + ✔ splitLines is a Function + ✔ Splits a multiline string into an array of lines. + + Testing spreadOver + + ✔ spreadOver is a Function + ✔ Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. + + Testing stableSort + + ✔ stableSort is a Function + ✔ Array is properly sorted + + Testing standardDeviation + + ✔ standardDeviation is a Function + ✔ Returns the standard deviation of an array of numbers + ✔ Returns the standard deviation of an array of numbers + + Testing stringPermutations + + ✔ stringPermutations is a Function + ✔ Generates all stringPermutations of a string + ✔ Works for single-letter strings + ✔ Works for empty strings + + Testing stripHTMLTags + + ✔ stripHTMLTags is a Function + ✔ Removes HTML tags + + Testing sum + + ✔ sum is a Function + ✔ Returns the sum of two or more numbers/arrays. + + Testing sumBy + + ✔ sumBy is a Function + + Testing sumPower + + ✔ sumPower is a Function + ✔ Returns the sum of the powers of all the numbers from start to end + ✔ Returns the sum of the powers of all the numbers from start to end + ✔ Returns the sum of the powers of all the numbers from start to end + + Testing symmetricDifference + + ✔ symmetricDifference is a Function + ✔ Returns the symmetric difference between two arrays. + + Testing symmetricDifferenceBy + + ✔ symmetricDifferenceBy is a Function + ✔ Returns the symmetric difference between two arrays, after applying the provided function to each array element of both + + Testing symmetricDifferenceWith + + ✔ symmetricDifferenceWith is a Function + ✔ Returns the symmetric difference between two arrays, using a provided function as a comparator + + Testing tail + + ✔ tail is a Function + ✔ Returns tail + ✔ Returns tail + + Testing take + + ✔ take is a Function + ✔ Returns an array with n elements removed from the beginning. + ✔ Returns an array with n elements removed from the beginning. + + Testing takeRight + + ✔ takeRight is a Function + ✔ Returns an array with n elements removed from the end + ✔ Returns an array with n elements removed from the end + + 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 + + ✔ throttle is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing timeTaken + + ✔ timeTaken is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing times + + ✔ times is a Function + ✔ Runs a function the specified amount of times + + Testing toCamelCase + + ✔ toCamelCase is a Function + ✔ toCamelCase('some_database_field_name') returns someDatabaseFieldName + ✔ toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized + ✔ toCamelCase('some-javascript-property') return someJavascriptProperty + ✔ toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens + ✔ toCamelCase() throws a error + ✔ toCamelCase([]) throws a error + ✔ toCamelCase({}) throws a error + ✔ toCamelCase(123) throws a error + ✔ toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run + + Testing toCurrency + + ✔ toCurrency is a Function + + ✖ currency: Euro | currencyLangFormat: Local + --------------------------------------------- + operator: equal + expected: '€ 123,456.79' + actual: '€123,456.79' + at: Test.test (/home/travis/build/Chalarangelo/30-seconds-of-code/test/toCurrency/toCurrency.test.js:8:5) + stack: |- + + ✔ currency: US Dollar | currencyLangFormat: English (United States) + + ✖ currency: Japanese Yen | currencyLangFormat: Local + ----------------------------------------------------- + operator: equal + expected: 'JP¥ 322,342,436,423' + actual: '¥322,342,436,423' + at: Test.test (/home/travis/build/Chalarangelo/30-seconds-of-code/test/toCurrency/toCurrency.test.js:11:5) + stack: |- + + + Testing toDecimalMark + + ✔ toDecimalMark is a Function + ✔ convert a float-point arithmetic to the Decimal mark form + + Testing toHash + + ✔ toHash is a Function + + Testing toKebabCase + + ✔ toKebabCase is a Function + ✔ toKebabCase('camelCase') returns camel-case + ✔ toKebabCase('some text') returns some-text + ✔ toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens + ✔ toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html + ✔ toKebabCase() return undefined + ✔ toKebabCase([]) throws an error + ✔ toKebabCase({}) throws an error + ✔ toKebabCase(123) throws an error + ✔ toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run + + Testing toOrdinalSuffix + + ✔ toOrdinalSuffix is a Function + ✔ Adds an ordinal suffix to a number + ✔ Adds an ordinal suffix to a number + ✔ Adds an ordinal suffix to a number + ✔ Adds an ordinal suffix to a number + + Testing toSafeInteger + + ✔ toSafeInteger is a Function + ✔ Number(toSafeInteger(3.2)) is a number + ✔ Converts a value to a safe integer + ✔ toSafeInteger('4.2') returns 4 + ✔ toSafeInteger(4.6) returns 5 + ✔ toSafeInteger([]) returns 0 + ✔ isNaN(toSafeInteger([1.5, 3124])) is true + ✔ isNaN(toSafeInteger('string')) is true + ✔ isNaN(toSafeInteger({})) is true + ✔ isNaN(toSafeInteger()) is true + ✔ toSafeInteger(Infinity) returns 9007199254740991 + ✔ toSafeInteger(3.2) takes less than 2s to run + + Testing toSnakeCase + + ✔ toSnakeCase is a Function + ✔ toSnakeCase('camelCase') returns camel_case + ✔ toSnakeCase('some text') returns some_text + ✔ toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens + ✔ toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html + ✔ toSnakeCase() returns undefined + ✔ toSnakeCase([]) throws an error + ✔ toSnakeCase({}) throws an error + ✔ toSnakeCase(123) throws an error + ✔ toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run + + Testing toggleClass + + ✔ toggleClass is a Function + ✔ Tested by @chalarangelo on 16/02/2018 + + Testing tomorrow + + ✔ tomorrow is a Function + ✔ Returns the correct year + ✔ Returns the correct month + ✔ Returns the correct date + + Testing transform + + ✔ transform is a Function + ✔ Transforms an object + + Testing truncateString + + ✔ truncateString is a Function + ✔ Truncates a "boomerang" up to a specified length. + + Testing truthCheckCollection + + ✔ truthCheckCollection is a Function + ✔ second argument is truthy on all elements of a collection + + Testing unary + + ✔ unary is a Function + ✔ Discards arguments after the first one + + Testing uncurry + + ✔ uncurry is a Function + ✔ Works without a provided value for n + ✔ Works without n = 2 + ✔ Works withoutn = 3 + + Testing unescapeHTML + + ✔ unescapeHTML is a Function + ✔ Unescapes escaped HTML characters. + + Testing unflattenObject + + ✔ unflattenObject is a Function + ✔ Unflattens an object with the paths for keys + + Testing unfold + + ✔ unfold is a Function + ✔ Works with a given function, producing an array + + Testing union + + ✔ union is a Function + ✔ union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4] + ✔ union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ] + ✔ union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3] + ✔ union([], []) returns [] + ✔ union() throws an error + ✔ union(true, str) throws an error + ✔ union(false, true) throws an error + ✔ union(123, {}) throws an error + ✔ union([], {}) throws an error + ✔ union(undefined, null) throws an error + ✔ union([1, 2, 3], [4, 3, 2]) takes less than 2s to run + + Testing unionBy + + ✔ unionBy is a Function + ✔ Produces the appropriate results + + Testing unionWith + + ✔ unionWith is a Function + ✔ Produces the appropriate results + + Testing uniqueElements + + ✔ uniqueElements is a Function + ✔ uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5] + ✔ uniqueElements([1, 23, 53]) returns [1, 23, 53] + ✔ uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, ''] + ✔ uniqueElements() returns [] + ✔ uniqueElements(null) returns [] + ✔ uniqueElements(undefined) returns [] + ✔ uniqueElements('strt') returns ['s', 't', 'r'] + ✔ uniqueElements(1, 1, 2543, 534, 5) throws an error + ✔ uniqueElements({}) throws an error + ✔ uniqueElements(true) throws an error + ✔ uniqueElements(false) throws an error + ✔ uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run + + Testing untildify + + ✔ untildify is a Function + ✔ Contains no tildes + ✔ Does not alter the rest of the path + ✔ Does not alter paths without tildes + + Testing unzip + + ✔ unzip is a Function + ✔ unzip([['a', 1, true], ['b', 2, false]]) equals [['a', 'b'], [1, 2], [true, false]] + ✔ unzip([['a', 1, true], ['b', 2]]) equals [['a', 'b'], [1, 2], [true]] + + Testing unzipWith + + ✔ unzipWith is a Function + ✔ unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300] + + Testing validateNumber + + ✔ validateNumber is a Function + ✔ validateNumber(9) returns true + ✔ validateNumber(234asd.slice(0, 2)) returns true + ✔ validateNumber(1232) returns true + ✔ validateNumber(1232 + 13423) returns true + ✔ validateNumber(1232 * 2342 * 123) returns true + ✔ validateNumber(1232.23423536) returns true + ✔ validateNumber(234asd) returns false + ✔ validateNumber(e234d) returns false + ✔ validateNumber(false) returns false + ✔ validateNumber(true) returns false + ✔ validateNumber(null) returns false + ✔ validateNumber(123 * asd) returns false + + Testing when + + ✔ when is a Function + ✔ should be truthy + ✔ should be truthy + + Testing without + + ✔ without is a Function + ✔ without([2, 1, 2, 3], 1, 2) returns [3] + ✔ without([]) returns [] + ✔ without([3, 1, true, '3', true], '3', true) returns [3, 1] + ✔ without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] + ✔ without() throws an error + ✔ without(null) throws an error + ✔ without(undefined) throws an error + ✔ without() throws an error + ✔ without({}) throws an error + + Testing words + + ✔ words is a Function + ✔ words('I love javaScript!!') returns [I, love, javaScript] + ✔ words('python, javaScript & coffee') returns [python, javaScript, coffee] + ✔ words(I love javaScript!!) returns an array + ✔ words() throws a error + ✔ words(null) throws a error + ✔ words(undefined) throws a error + ✔ words({}) throws a error + ✔ words([]) throws a error + ✔ words(1234) throws a error + + Testing xProd + + ✔ xProd is a Function + ✔ xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] + + Testing yesNo + + ✔ yesNo is a Function + ✔ yesNo(Y) returns true + ✔ yesNo(yes) returns true + ✔ yesNo(foo, true) returns true + ✔ yesNo(No) returns false + ✔ yesNo() returns false + ✔ yesNo(null) returns false + ✔ yesNo(undefined) returns false + ✔ yesNo([123, null]) returns false + ✔ yesNo([Yes, No]) returns false + ✔ yesNo({ 2: Yes }) returns false + ✔ yesNo([Yes, No], true) returns true + ✔ yesNo({ 2: Yes }, true) returns true + + Testing zip + + ✔ zip is a Function + ✔ zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]] + ✔ zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]] + ✔ zip([]) returns [] + ✔ zip(123) returns [] + ✔ zip([a, b], [1, 2], [true, false]) returns an Array + ✔ zip([a], [1, 2], [true, false]) returns an Array + ✔ zip(null) throws an error + ✔ zip(undefined) throws an error + + Testing zipObject + + ✔ zipObject is a Function + ✔ zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} + ✔ zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} + ✔ zipObject([a, b, c], string) returns { a: s, b: t, c: r } + ✔ zipObject([a], string) returns { a: s } + ✔ zipObject() throws an error + ✔ zipObject([string], null) throws an error + ✔ zipObject(null, [1]) throws an error + ✔ zipObject(string) throws an error + ✔ zipObject(test, string) throws an error + + Testing zipWith + + ✔ zipWith is a Function + ✔ Sends a GET request + ✔ Sends a POST request + ✔ Runs the function provided + ✔ Runs promises in series + ✔ Works as expecting, passing arguments properly + ✔ Works with multiple promises + + + + Failed Tests: There were 2 failures + + Testing toCurrency + + ✖ currency: Euro | currencyLangFormat: Local + ✖ currency: Japanese Yen | currencyLangFormat: Local + + + total: 1022 + passing: 1020 + failing: 2 + duration: 2.4s + + +undefined \ No newline at end of file diff --git a/test6/throttle/throttle.js b/test/throttle/throttle.js similarity index 100% rename from test6/throttle/throttle.js rename to test/throttle/throttle.js diff --git a/test/throttle/throttle.test.js b/test/throttle/throttle.test.js new file mode 100644 index 000000000..5e3436417 --- /dev/null +++ b/test/throttle/throttle.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const throttle = require('./throttle.js'); + + + test('throttle is a Function', () => { + expect(throttle).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test6/timeTaken/timeTaken.js b/test/timeTaken/timeTaken.js similarity index 100% rename from test6/timeTaken/timeTaken.js rename to test/timeTaken/timeTaken.js diff --git a/test/timeTaken/timeTaken.test.js b/test/timeTaken/timeTaken.test.js new file mode 100644 index 000000000..58755e045 --- /dev/null +++ b/test/timeTaken/timeTaken.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const timeTaken = require('./timeTaken.js'); + + + test('timeTaken is a Function', () => { + expect(timeTaken).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test6/times/times.js b/test/times/times.js similarity index 100% rename from test6/times/times.js rename to test/times/times.js diff --git a/test/times/times.test.js b/test/times/times.test.js new file mode 100644 index 000000000..6197b7cee --- /dev/null +++ b/test/times/times.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const times = require('./times.js'); + + + test('times is a Function', () => { + expect(times).toBeInstanceOf(Function); +}); + var output = ''; + times(5, i => (output += i)); + test('Runs a function the specified amount of times', () => { + expect(output, '01234').toBe() +}); + + diff --git a/test6/toCamelCase/toCamelCase.js b/test/toCamelCase/toCamelCase.js similarity index 100% rename from test6/toCamelCase/toCamelCase.js rename to test/toCamelCase/toCamelCase.js diff --git a/test/toCamelCase/toCamelCase.test.js b/test/toCamelCase/toCamelCase.test.js new file mode 100644 index 000000000..5577464d9 --- /dev/null +++ b/test/toCamelCase/toCamelCase.test.js @@ -0,0 +1,24 @@ +const expect = require('expect'); +const toCamelCase = require('./toCamelCase.js'); + + + test('toCamelCase is a Function', () => { + expect(toCamelCase).toBeInstanceOf(Function); +}); + t.equal(toCamelCase('some_database_field_name'), 'someDatabaseFieldName', "toCamelCase('some_database_field_name') returns someDatabaseFieldName"); + t.equal(toCamelCase('Some label that needs to be camelized'), 'someLabelThatNeedsToBeCamelized', "toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized"); + t.equal(toCamelCase('some-javascript-property'), 'someJavascriptProperty', "toCamelCase('some-javascript-property') return someJavascriptProperty"); + t.equal(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'), 'someMixedStringWithSpacesUnderscoresAndHyphens', "toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens"); + t.throws(() => toCamelCase(), 'toCamelCase() throws a error'); + t.throws(() => toCamelCase([]), 'toCamelCase([]) throws a error'); + t.throws(() => toCamelCase({}), 'toCamelCase({}) throws a error'); + t.throws(() => toCamelCase(123), 'toCamelCase(123) throws a error'); + + let start = new Date().getTime(); + toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'); + let end = new Date().getTime(); + test('toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + diff --git a/test6/toCurrency/toCurrency.js b/test/toCurrency/toCurrency.js similarity index 100% rename from test6/toCurrency/toCurrency.js rename to test/toCurrency/toCurrency.js diff --git a/test/toCurrency/toCurrency.test.js b/test/toCurrency/toCurrency.test.js new file mode 100644 index 000000000..b06368eb9 --- /dev/null +++ b/test/toCurrency/toCurrency.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const toCurrency = require('./toCurrency.js'); + + + test('toCurrency is a Function', () => { + expect(toCurrency).toBeInstanceOf(Function); +}); + t.equal(toCurrency(123456.789, 'EUR'), '€ 123,456.79', 'currency: Euro | currencyLangFormat: Local'); + t.equal(toCurrency(123456.789, 'USD', 'en-us'), '$123,456.79', ' currency: US Dollar | currencyLangFormat: English (United States)'); + t.equal(toCurrency(322342436423.2435, 'JPY'), 'JP¥ 322,342,436,423', 'currency: Japanese Yen | currencyLangFormat: Local'); + + diff --git a/test6/toDecimalMark/toDecimalMark.js b/test/toDecimalMark/toDecimalMark.js similarity index 100% rename from test6/toDecimalMark/toDecimalMark.js rename to test/toDecimalMark/toDecimalMark.js diff --git a/test/toDecimalMark/toDecimalMark.test.js b/test/toDecimalMark/toDecimalMark.test.js new file mode 100644 index 000000000..c35a4ade8 --- /dev/null +++ b/test/toDecimalMark/toDecimalMark.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const toDecimalMark = require('./toDecimalMark.js'); + + + test('toDecimalMark is a Function', () => { + expect(toDecimalMark).toBeInstanceOf(Function); +}); + t.equal(toDecimalMark(12305030388.9087), "12,305,030,388.909", "convert a float-point arithmetic to the Decimal mark form"); + diff --git a/test6/toHash/toHash.js b/test/toHash/toHash.js similarity index 100% rename from test6/toHash/toHash.js rename to test/toHash/toHash.js diff --git a/test/toHash/toHash.test.js b/test/toHash/toHash.test.js new file mode 100644 index 000000000..662177031 --- /dev/null +++ b/test/toHash/toHash.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const toHash = require('./toHash.js'); + + + test('toHash is a Function', () => { + expect(toHash).toBeInstanceOf(Function); +}); + diff --git a/test6/toKebabCase/toKebabCase.js b/test/toKebabCase/toKebabCase.js similarity index 100% rename from test6/toKebabCase/toKebabCase.js rename to test/toKebabCase/toKebabCase.js diff --git a/test/toKebabCase/toKebabCase.test.js b/test/toKebabCase/toKebabCase.test.js new file mode 100644 index 000000000..8773f6228 --- /dev/null +++ b/test/toKebabCase/toKebabCase.test.js @@ -0,0 +1,24 @@ +const expect = require('expect'); +const toKebabCase = require('./toKebabCase.js'); + + + test('toKebabCase is a Function', () => { + expect(toKebabCase).toBeInstanceOf(Function); +}); + t.equal(toKebabCase('camelCase'), 'camel-case', "toKebabCase('camelCase') returns camel-case"); + t.equal(toKebabCase('some text'), 'some-text', "toKebabCase('some text') returns some-text"); + t.equal(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens'), 'some-mixed-string-with-spaces-underscores-and-hyphens', "toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens"); + t.equal(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', "toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html"); + t.equal(toKebabCase(), undefined, 'toKebabCase() return undefined'); + t.throws(() => toKebabCase([]), 'toKebabCase([]) throws an error'); + t.throws(() => toKebabCase({}), 'toKebabCase({}) throws an error'); + t.throws(() => toKebabCase(123), 'toKebabCase(123) throws an error'); + + let start = new Date().getTime(); + toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'); + let end = new Date().getTime(); + test('toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + diff --git a/test6/toOrdinalSuffix/toOrdinalSuffix.js b/test/toOrdinalSuffix/toOrdinalSuffix.js similarity index 100% rename from test6/toOrdinalSuffix/toOrdinalSuffix.js rename to test/toOrdinalSuffix/toOrdinalSuffix.js diff --git a/test/toOrdinalSuffix/toOrdinalSuffix.test.js b/test/toOrdinalSuffix/toOrdinalSuffix.test.js new file mode 100644 index 000000000..6d6fc41eb --- /dev/null +++ b/test/toOrdinalSuffix/toOrdinalSuffix.test.js @@ -0,0 +1,12 @@ +const expect = require('expect'); +const toOrdinalSuffix = require('./toOrdinalSuffix.js'); + + + test('toOrdinalSuffix is a Function', () => { + expect(toOrdinalSuffix).toBeInstanceOf(Function); +}); + t.equal(toOrdinalSuffix('123'), '123rd', 'Adds an ordinal suffix to a number'); + t.equal(toOrdinalSuffix(5), '5th', 'Adds an ordinal suffix to a number'); + t.equal(toOrdinalSuffix(1), '1st', 'Adds an ordinal suffix to a number'); + t.equal(toOrdinalSuffix(0), '0th', 'Adds an ordinal suffix to a number'); + diff --git a/test6/toSafeInteger/toSafeInteger.js b/test/toSafeInteger/toSafeInteger.js similarity index 100% rename from test6/toSafeInteger/toSafeInteger.js rename to test/toSafeInteger/toSafeInteger.js diff --git a/test/toSafeInteger/toSafeInteger.test.js b/test/toSafeInteger/toSafeInteger.test.js new file mode 100644 index 000000000..2676a9b09 --- /dev/null +++ b/test/toSafeInteger/toSafeInteger.test.js @@ -0,0 +1,28 @@ +const expect = require('expect'); +const toSafeInteger = require('./toSafeInteger.js'); + + + test('toSafeInteger is a Function', () => { + expect(toSafeInteger).toBeInstanceOf(Function); +}); + test('Number(toSafeInteger(3.2)) is a number', () => { + expect(Number(toSafeInteger(3.2))).toBeTruthy(); +}); + t.equal(toSafeInteger(3.2), 3, "Converts a value to a safe integer"); + t.equal(toSafeInteger('4.2'), 4, "toSafeInteger('4.2') returns 4"); + t.equal(toSafeInteger(4.6), 5, "toSafeInteger(4.6) returns 5"); + t.equal(toSafeInteger([]), 0, "toSafeInteger([]) returns 0"); + t.true(isNaN(toSafeInteger([1.5, 3124])), "isNaN(toSafeInteger([1.5, 3124])) is true"); + t.true(isNaN(toSafeInteger('string')), "isNaN(toSafeInteger('string')) is true"); + t.true(isNaN(toSafeInteger({})), "isNaN(toSafeInteger({})) is true"); + t.true(isNaN(toSafeInteger()), "isNaN(toSafeInteger()) is true"); + t.equal(toSafeInteger(Infinity), 9007199254740991, "toSafeInteger(Infinity) returns 9007199254740991"); + + let start = new Date().getTime(); + toSafeInteger(3.2); + let end = new Date().getTime(); + test('toSafeInteger(3.2) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + diff --git a/test6/toSnakeCase/toSnakeCase.js b/test/toSnakeCase/toSnakeCase.js similarity index 100% rename from test6/toSnakeCase/toSnakeCase.js rename to test/toSnakeCase/toSnakeCase.js diff --git a/test/toSnakeCase/toSnakeCase.test.js b/test/toSnakeCase/toSnakeCase.test.js new file mode 100644 index 000000000..bf472bbae --- /dev/null +++ b/test/toSnakeCase/toSnakeCase.test.js @@ -0,0 +1,24 @@ +const expect = require('expect'); +const toSnakeCase = require('./toSnakeCase.js'); + + + test('toSnakeCase is a Function', () => { + expect(toSnakeCase).toBeInstanceOf(Function); +}); + t.equal(toSnakeCase('camelCase'), 'camel_case', "toSnakeCase('camelCase') returns camel_case"); + t.equal(toSnakeCase('some text'), 'some_text', "toSnakeCase('some text') returns some_text"); + t.equal(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'), 'some_mixed_string_with_spaces_underscores_and_hyphens', "toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens"); + t.equal(toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', "toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html"); + t.equal(toSnakeCase(), undefined, 'toSnakeCase() returns undefined'); + t.throws(() => toSnakeCase([]), 'toSnakeCase([]) throws an error'); + t.throws(() => toSnakeCase({}), 'toSnakeCase({}) throws an error'); + t.throws(() => toSnakeCase(123), 'toSnakeCase(123) throws an error'); + + let start = new Date().getTime(); + toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'); + let end = new Date().getTime(); + test('toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + diff --git a/test6/toggleClass/toggleClass.js b/test/toggleClass/toggleClass.js similarity index 100% rename from test6/toggleClass/toggleClass.js rename to test/toggleClass/toggleClass.js diff --git a/test/toggleClass/toggleClass.test.js b/test/toggleClass/toggleClass.test.js new file mode 100644 index 000000000..3a4d104ad --- /dev/null +++ b/test/toggleClass/toggleClass.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const toggleClass = require('./toggleClass.js'); + + + test('toggleClass is a Function', () => { + expect(toggleClass).toBeInstanceOf(Function); +}); + t.pass('Tested by @chalarangelo on 16/02/2018'); + + diff --git a/test6/tomorrow/tomorrow.js b/test/tomorrow/tomorrow.js similarity index 100% rename from test6/tomorrow/tomorrow.js rename to test/tomorrow/tomorrow.js diff --git a/test/tomorrow/tomorrow.test.js b/test/tomorrow/tomorrow.test.js new file mode 100644 index 000000000..490e42f42 --- /dev/null +++ b/test/tomorrow/tomorrow.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const tomorrow = require('./tomorrow.js'); + + + test('tomorrow is a Function', () => { + expect(tomorrow).toBeInstanceOf(Function); +}); + const t1 = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1); + const t2 = new Date(tomorrow()); + t.equal(t1.getFullYear(), t2.getFullYear(), 'Returns the correct year'); + t.equal(t1.getMonth(), t2.getMonth(), 'Returns the correct month'); + t.equal(t1.getDate(), t2.getDate(), 'Returns the correct date'); + + diff --git a/test6/transform/transform.js b/test/transform/transform.js similarity index 100% rename from test6/transform/transform.js rename to test/transform/transform.js diff --git a/test/transform/transform.test.js b/test/transform/transform.test.js new file mode 100644 index 000000000..a2407b0c6 --- /dev/null +++ b/test/transform/transform.test.js @@ -0,0 +1,17 @@ +const expect = require('expect'); +const transform = require('./transform.js'); + + + test('transform is a Function', () => { + expect(transform).toBeInstanceOf(Function); +}); + t.deepEqual(transform( + { a: 1, b: 2, c: 1 }, + (r, v, k) => { + (r[v] || (r[v] = [])).push(k); + return r; + }, + {} +), { '1': ['a', 'c'], '2': ['b'] }, 'Transforms an object'); + + diff --git a/test6/truncateString/truncateString.js b/test/truncateString/truncateString.js similarity index 100% rename from test6/truncateString/truncateString.js rename to test/truncateString/truncateString.js diff --git a/test/truncateString/truncateString.test.js b/test/truncateString/truncateString.test.js new file mode 100644 index 000000000..cfebd7f9a --- /dev/null +++ b/test/truncateString/truncateString.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const truncateString = require('./truncateString.js'); + + + test('truncateString is a Function', () => { + expect(truncateString).toBeInstanceOf(Function); +}); + t.equal(truncateString('boomerang', 7), 'boom...', 'Truncates a "boomerang" up to a specified length.'); + diff --git a/test6/truthCheckCollection/truthCheckCollection.js b/test/truthCheckCollection/truthCheckCollection.js similarity index 100% rename from test6/truthCheckCollection/truthCheckCollection.js rename to test/truthCheckCollection/truthCheckCollection.js diff --git a/test/truthCheckCollection/truthCheckCollection.test.js b/test/truthCheckCollection/truthCheckCollection.test.js new file mode 100644 index 000000000..0a78a68b7 --- /dev/null +++ b/test/truthCheckCollection/truthCheckCollection.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const truthCheckCollection = require('./truthCheckCollection.js'); + + + test('truthCheckCollection is a Function', () => { + expect(truthCheckCollection).toBeInstanceOf(Function); +}); + t.equal(truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex'), true, "second argument is truthy on all elements of a collection"); + diff --git a/test6/unary/unary.js b/test/unary/unary.js similarity index 100% rename from test6/unary/unary.js rename to test/unary/unary.js diff --git a/test/unary/unary.test.js b/test/unary/unary.test.js new file mode 100644 index 000000000..c559cbeaa --- /dev/null +++ b/test/unary/unary.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const unary = require('./unary.js'); + + + test('unary is a Function', () => { + expect(unary).toBeInstanceOf(Function); +}); + t.deepEqual(['6', '8', '10'].map(unary(parseInt)), [6, 8, 10], 'Discards arguments after the first one'); + + diff --git a/test6/uncurry/uncurry.js b/test/uncurry/uncurry.js similarity index 100% rename from test6/uncurry/uncurry.js rename to test/uncurry/uncurry.js diff --git a/test/uncurry/uncurry.test.js b/test/uncurry/uncurry.test.js new file mode 100644 index 000000000..57da1c13b --- /dev/null +++ b/test/uncurry/uncurry.test.js @@ -0,0 +1,16 @@ +const expect = require('expect'); +const uncurry = require('./uncurry.js'); + + + test('uncurry is a Function', () => { + expect(uncurry).toBeInstanceOf(Function); +}); + const add = x => y => z => x + y + z; + const add1 = uncurry(add); + const add2 = uncurry(add, 2); + const add3 = uncurry(add, 3); + t.equal(add1(1)(2)(3), 6, 'Works without a provided value for n'); + t.equal(add2(1,2)(3), 6, 'Works without n = 2'); + t.equal(add3(1,2,3), 6, 'Works withoutn = 3'); + + diff --git a/test6/unescapeHTML/unescapeHTML.js b/test/unescapeHTML/unescapeHTML.js similarity index 100% rename from test6/unescapeHTML/unescapeHTML.js rename to test/unescapeHTML/unescapeHTML.js diff --git a/test/unescapeHTML/unescapeHTML.test.js b/test/unescapeHTML/unescapeHTML.test.js new file mode 100644 index 000000000..a45df3621 --- /dev/null +++ b/test/unescapeHTML/unescapeHTML.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const unescapeHTML = require('./unescapeHTML.js'); + + + test('unescapeHTML is a Function', () => { + expect(unescapeHTML).toBeInstanceOf(Function); +}); + t.equal(unescapeHTML('<a href="#">Me & you</a>'), 'Me & you', 'Unescapes escaped HTML characters.'); + diff --git a/test6/unflattenObject/unflattenObject.js b/test/unflattenObject/unflattenObject.js similarity index 97% rename from test6/unflattenObject/unflattenObject.js rename to test/unflattenObject/unflattenObject.js index b0b4f48ba..e5303a886 100644 --- a/test6/unflattenObject/unflattenObject.js +++ b/test/unflattenObject/unflattenObject.js @@ -13,5 +13,5 @@ obj[k] + ); } else acc[k] = obj[k]; return acc; -}, {}); +}, { module.exports = unflattenObject; \ No newline at end of file diff --git a/test/unflattenObject/unflattenObject.test.js b/test/unflattenObject/unflattenObject.test.js new file mode 100644 index 000000000..67b763ff1 --- /dev/null +++ b/test/unflattenObject/unflattenObject.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const unflattenObject = require('./unflattenObject.js'); + + + test('unflattenObject is a Function', () => { + expect(unflattenObject).toBeInstanceOf(Function); +}); + t.deepEqual(unflattenObject({ 'a.b.c': 1, d: 1 }), { a: { b: { c: 1 } }, d: 1 }, 'Unflattens an object with the paths for keys'); + + diff --git a/test6/unfold/unfold.js b/test/unfold/unfold.js similarity index 100% rename from test6/unfold/unfold.js rename to test/unfold/unfold.js diff --git a/test/unfold/unfold.test.js b/test/unfold/unfold.test.js new file mode 100644 index 000000000..1a053f9e4 --- /dev/null +++ b/test/unfold/unfold.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const unfold = require('./unfold.js'); + + + test('unfold is a Function', () => { + expect(unfold).toBeInstanceOf(Function); +}); + var f = n => (n > 50 ? false : [-n, n + 10]); + t.deepEqual(unfold(f, 10), [-10, -20, -30, -40, -50], 'Works with a given function, producing an array'); + + diff --git a/test6/union/union.js b/test/union/union.js similarity index 100% rename from test6/union/union.js rename to test/union/union.js diff --git a/test/union/union.test.js b/test/union/union.test.js new file mode 100644 index 000000000..5e08864a3 --- /dev/null +++ b/test/union/union.test.js @@ -0,0 +1,26 @@ +const expect = require('expect'); +const union = require('./union.js'); + + + test('union is a Function', () => { + expect(union).toBeInstanceOf(Function); +}); + t.deepEqual(union([1, 2, 3], [4, 3, 2]), [1, 2, 3, 4], "union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4]"); + t.deepEqual(union('str', 'asd'), [ 's', 't', 'r', 'a', 'd' ], "union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ]"); + t.deepEqual(union([[], {}], [1, 2, 3]), [[], {}, 1, 2, 3], "union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3]"); + t.deepEqual(union([], []), [], "union([], []) returns []"); + t.throws(() => union(), 'union() throws an error'); + t.throws(() => union(true, 'str'), 'union(true, str) throws an error'); + t.throws(() => union('false', true), 'union(false, true) throws an error'); + t.throws(() => union(123, {}), 'union(123, {}) throws an error'); + t.throws(() => union([], {}), 'union([], {}) throws an error'); + t.throws(() => union(undefined, null), 'union(undefined, null) throws an error'); + + let start = new Date().getTime(); + union([1, 2, 3], [4, 3, 2]); + let end = new Date().getTime(); + test('union([1, 2, 3], [4, 3, 2]) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + diff --git a/test6/unionBy/unionBy.js b/test/unionBy/unionBy.js similarity index 100% rename from test6/unionBy/unionBy.js rename to test/unionBy/unionBy.js diff --git a/test/unionBy/unionBy.test.js b/test/unionBy/unionBy.test.js new file mode 100644 index 000000000..a9010b62e --- /dev/null +++ b/test/unionBy/unionBy.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const unionBy = require('./unionBy.js'); + + + test('unionBy is a Function', () => { + expect(unionBy).toBeInstanceOf(Function); +}); + t.deepEqual(unionBy([2.1], [1.2, 2.3], Math.floor), [2.1, 1.2], 'Produces the appropriate results'); + + diff --git a/test6/unionWith/unionWith.js b/test/unionWith/unionWith.js similarity index 100% rename from test6/unionWith/unionWith.js rename to test/unionWith/unionWith.js diff --git a/test/unionWith/unionWith.test.js b/test/unionWith/unionWith.test.js new file mode 100644 index 000000000..4a299689e --- /dev/null +++ b/test/unionWith/unionWith.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const unionWith = require('./unionWith.js'); + + + test('unionWith is a Function', () => { + expect(unionWith).toBeInstanceOf(Function); +}); + t.deepEqual(unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)), [1, 1.2, 1.5, 3, 0, 3.9], 'Produces the appropriate results'); + + diff --git a/test6/uniqueElements/uniqueElements.js b/test/uniqueElements/uniqueElements.js similarity index 100% rename from test6/uniqueElements/uniqueElements.js rename to test/uniqueElements/uniqueElements.js diff --git a/test/uniqueElements/uniqueElements.test.js b/test/uniqueElements/uniqueElements.test.js new file mode 100644 index 000000000..42f5afff6 --- /dev/null +++ b/test/uniqueElements/uniqueElements.test.js @@ -0,0 +1,30 @@ +const expect = require('expect'); +const uniqueElements = require('./uniqueElements.js'); + + + test('uniqueElements is a Function', () => { + expect(uniqueElements).toBeInstanceOf(Function); +}); + t.deepEqual(uniqueElements([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5]"); + t.deepEqual(uniqueElements([1, 23, 53]), [1, 23, 53], "uniqueElements([1, 23, 53]) returns [1, 23, 53]"); + t.deepEqual(uniqueElements([true, 0, 1, false, false, undefined, null, '']), [true, 0, 1, false, undefined, null, ''], "uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, '']"); + t.deepEqual(uniqueElements(), [], "uniqueElements() returns []"); + t.deepEqual(uniqueElements(null), [], "uniqueElements(null) returns []"); + t.deepEqual(uniqueElements(undefined), [], "uniqueElements(undefined) returns []"); + t.deepEqual(uniqueElements('strt'), ['s', 't', 'r'], "uniqueElements('strt') returns ['s', 't', 'r']"); + t.throws(() => uniqueElements(1, 1, 2543, 534, 5), 'uniqueElements(1, 1, 2543, 534, 5) throws an error'); + t.throws(() => uniqueElements({}), 'uniqueElements({}) throws an error'); + t.throws(() => uniqueElements(true), 'uniqueElements(true) throws an error'); + t.throws(() => uniqueElements(false), 'uniqueElements(false) throws an error'); + + let start = new Date().getTime(); + uniqueElements([true, 0, 1, false, false, undefined, null, '']); + let end = new Date().getTime(); + test('uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run', () => { + expect((end - start) < 2000).toBeTruthy(); +}); + + + + +uniqueElements([1, 2, 2, '1', 4, 4, 4, 5, true]); diff --git a/test6/untildify/untildify.js b/test/untildify/untildify.js similarity index 100% rename from test6/untildify/untildify.js rename to test/untildify/untildify.js diff --git a/test/untildify/untildify.test.js b/test/untildify/untildify.test.js new file mode 100644 index 000000000..80075903b --- /dev/null +++ b/test/untildify/untildify.test.js @@ -0,0 +1,14 @@ +const expect = require('expect'); +const untildify = require('./untildify.js'); + + + test('untildify is a Function', () => { + expect(untildify).toBeInstanceOf(Function); +}); + test('Contains no tildes', () => { + expect(untildify('~/test/dir/file.f').indexOf('~') === -1).toBeTruthy(); +}); + t.equal(untildify('~/test/dir/file.f').slice(-16), '/test/dir/file.f', 'Does not alter the rest of the path'); + t.equal(untildify('test/dir/file.f'), 'test/dir/file.f', 'Does not alter paths without tildes'); + + diff --git a/test6/unzip/unzip.js b/test/unzip/unzip.js similarity index 100% rename from test6/unzip/unzip.js rename to test/unzip/unzip.js diff --git a/test/unzip/unzip.test.js b/test/unzip/unzip.test.js new file mode 100644 index 000000000..16b125928 --- /dev/null +++ b/test/unzip/unzip.test.js @@ -0,0 +1,11 @@ +const expect = require('expect'); +const unzip = require('./unzip.js'); + + + test('unzip is a Function', () => { + expect(unzip).toBeInstanceOf(Function); +}); + t.deepEqual(unzip([['a', 1, true], ['b', 2, false]]), [['a', 'b'], [1, 2], [true, false]], `unzip([['a', 1, true], ['b', 2, false]]) equals [['a', 'b'], [1, 2], [true, false]]`); + t.deepEqual(unzip([['a', 1, true], ['b', 2]]), [['a', 'b'], [1, 2], [true]], `unzip([['a', 1, true], ['b', 2]]) equals [['a', 'b'], [1, 2], [true]]`); + + diff --git a/test6/unzipWith/unzipWith.js b/test/unzipWith/unzipWith.js similarity index 100% rename from test6/unzipWith/unzipWith.js rename to test/unzipWith/unzipWith.js diff --git a/test/unzipWith/unzipWith.test.js b/test/unzipWith/unzipWith.test.js new file mode 100644 index 000000000..d33b5b86f --- /dev/null +++ b/test/unzipWith/unzipWith.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const unzipWith = require('./unzipWith.js'); + + + test('unzipWith is a Function', () => { + expect(unzipWith).toBeInstanceOf(Function); +}); + t.deepEqual(unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)), [3, 30, 300], `unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300]`); + + diff --git a/test6/validateNumber/validateNumber.js b/test/validateNumber/validateNumber.js similarity index 100% rename from test6/validateNumber/validateNumber.js rename to test/validateNumber/validateNumber.js diff --git a/test/validateNumber/validateNumber.test.js b/test/validateNumber/validateNumber.test.js new file mode 100644 index 000000000..3b6d00842 --- /dev/null +++ b/test/validateNumber/validateNumber.test.js @@ -0,0 +1,46 @@ +const expect = require('expect'); +const validateNumber = require('./validateNumber.js'); + + + test('validateNumber is a Function', () => { + expect(validateNumber).toBeInstanceOf(Function); +}); + test('validateNumber(9) returns true', () => { + expect(validateNumber(9)).toBeTruthy(); +}); + test('validateNumber(234asd.slice(0, 2)) returns true', () => { + expect(validateNumber('234asd'.slice(0, 2))).toBeTruthy(); +}); + test('validateNumber(1232) returns true', () => { + expect(validateNumber(1232)).toBeTruthy(); +}); + test('validateNumber(1232 + 13423) returns true', () => { + expect(validateNumber(1232 + 13423)).toBeTruthy(); +}); + test('validateNumber(1232 * 2342 * 123) returns true', () => { + expect(validateNumber(1232 * 2342 * 123)).toBeTruthy(); +}); + test('validateNumber(1232.23423536) returns true', () => { + expect(validateNumber(1232.23423536)).toBeTruthy(); +}); + test('validateNumber(234asd) returns false', () => { + expect(validateNumber('234asd')).toBeFalsy(); +}); + test('validateNumber(e234d) returns false', () => { + expect(validateNumber('e234d')).toBeFalsy(); +}); + test('validateNumber(false) returns false', () => { + expect(validateNumber(false)).toBeFalsy(); +}); + test('validateNumber(true) returns false', () => { + expect(validateNumber(true)).toBeFalsy(); +}); + test('validateNumber(null) returns false', () => { + expect(validateNumber(null)).toBeFalsy(); +}); + test('validateNumber(123 * asd) returns false', () => { + expect(validateNumber(123 * 'asd')).toBeFalsy(); +}); + + + diff --git a/test6/when/when.js b/test/when/when.js similarity index 100% rename from test6/when/when.js rename to test/when/when.js diff --git a/test/when/when.test.js b/test/when/when.test.js new file mode 100644 index 000000000..c736288f8 --- /dev/null +++ b/test/when/when.test.js @@ -0,0 +1,18 @@ +const expect = require('expect'); +const when = require('./when.js'); + + + test('when is a Function', () => { + expect(when).toBeInstanceOf(Function); +}); + + const doubleEvenNumbers = when( + (x) => x % 2 === 0, + (x) => x * 2 + ); + + t.true(doubleEvenNumbers(2) === 4); + t.true(doubleEvenNumbers(1) === 1); + + + diff --git a/test6/without/without.js b/test/without/without.js similarity index 100% rename from test6/without/without.js rename to test/without/without.js diff --git a/test/without/without.test.js b/test/without/without.test.js new file mode 100644 index 000000000..60d7def99 --- /dev/null +++ b/test/without/without.test.js @@ -0,0 +1,19 @@ +const expect = require('expect'); +const without = require('./without.js'); + + + test('without is a Function', () => { + expect(without).toBeInstanceOf(Function); +}); + t.deepEqual(without([2, 1, 2, 3], 1, 2), [3], "without([2, 1, 2, 3], 1, 2) returns [3]"); + t.deepEqual(without([]), [], "without([]) returns []"); + t.deepEqual(without([3, 1, true, '3', true], '3', true), [3, 1], "without([3, 1, true, '3', true], '3', true) returns [3, 1]"); + t.deepEqual(without('string'.split(''), 's', 't', 'g'), ['r', 'i', 'n'], "without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n']"); + t.throws(() => without(), 'without() throws an error'); + t.throws(() => without(null), 'without(null) throws an error'); + t.throws(() => without(undefined), 'without(undefined) throws an error'); + t.throws(() => without(123), 'without() throws an error'); + t.throws(() => without({}), 'without({}) throws an error'); + + + diff --git a/test6/words/words.js b/test/words/words.js similarity index 100% rename from test6/words/words.js rename to test/words/words.js diff --git a/test/words/words.test.js b/test/words/words.test.js new file mode 100644 index 000000000..8df2f68da --- /dev/null +++ b/test/words/words.test.js @@ -0,0 +1,21 @@ +const expect = require('expect'); +const words = require('./words.js'); + + + test('words is a Function', () => { + expect(words).toBeInstanceOf(Function); +}); + t.deepEqual(words('I love javaScript!!'), ["I", "love", "javaScript"], "words('I love javaScript!!') returns [I, love, javaScript]"); + t.deepEqual(words('python, javaScript & coffee'), ["python", "javaScript", "coffee"], "words('python, javaScript & coffee') returns [python, javaScript, coffee]"); + test('words(I love javaScript!!) returns an array', () => { + expect(Array.isArray(words('I love javaScript!!'))).toBeTruthy(); +}); + t.throws(() => words(), 'words() throws a error'); + t.throws(() => words(null), 'words(null) throws a error'); + t.throws(() => words(undefined), 'words(undefined) throws a error'); + t.throws(() => words({}), 'words({}) throws a error'); + t.throws(() => words([]), 'words([]) throws a error'); + t.throws(() => words(1234), 'words(1234) throws a error'); + + + diff --git a/test6/xProd/xProd.js b/test/xProd/xProd.js similarity index 100% rename from test6/xProd/xProd.js rename to test/xProd/xProd.js diff --git a/test/xProd/xProd.test.js b/test/xProd/xProd.test.js new file mode 100644 index 000000000..392dcfd47 --- /dev/null +++ b/test/xProd/xProd.test.js @@ -0,0 +1,10 @@ +const expect = require('expect'); +const xProd = require('./xProd.js'); + + + test('xProd is a Function', () => { + expect(xProd).toBeInstanceOf(Function); +}); + t.deepEqual(xProd([1, 2], ['a', 'b']), [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']], `xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]`); + + diff --git a/test6/yesNo/yesNo.js b/test/yesNo/yesNo.js similarity index 100% rename from test6/yesNo/yesNo.js rename to test/yesNo/yesNo.js diff --git a/test/yesNo/yesNo.test.js b/test/yesNo/yesNo.test.js new file mode 100644 index 000000000..b3d658754 --- /dev/null +++ b/test/yesNo/yesNo.test.js @@ -0,0 +1,46 @@ +const expect = require('expect'); +const yesNo = require('./yesNo.js'); + + + test('yesNo is a Function', () => { + expect(yesNo).toBeInstanceOf(Function); +}); + test('yesNo(Y) returns true', () => { + expect(yesNo('Y')).toBeTruthy(); +}); + test('yesNo(yes) returns true', () => { + expect(yesNo('yes')).toBeTruthy(); +}); + test('yesNo(foo, true) returns true', () => { + expect(yesNo('foo', true)).toBeTruthy(); +}); + test('yesNo(No) returns false', () => { + expect(yesNo('No')).toBeFalsy(); +}); + test('yesNo() returns false', () => { + expect(yesNo()).toBeFalsy(); +}); + test('yesNo(null) returns false', () => { + expect(yesNo(null)).toBeFalsy(); +}); + test('yesNo(undefined) returns false', () => { + expect(yesNo(undefined)).toBeFalsy(); +}); + test('yesNo([123, null]) returns false', () => { + expect(yesNo([123, null])).toBeFalsy(); +}); + test('yesNo([Yes, No]) returns false', () => { + expect(yesNo(['Yes', 'No'])).toBeFalsy(); +}); + test('yesNo({ 2: Yes }) returns false', () => { + expect(yesNo({ 2: 'Yes' })).toBeFalsy(); +}); + test('yesNo([Yes, No], true) returns true', () => { + expect(yesNo(['Yes', 'No'], true)).toBeTruthy(); +}); + test('yesNo({ 2: Yes }, true) returns true', () => { + expect(yesNo({ 2: 'Yes' }, true)).toBeTruthy(); +}); + + + diff --git a/test6/zip/zip.js b/test/zip/zip.js similarity index 98% rename from test6/zip/zip.js rename to test/zip/zip.js index 54a162bce..aad64ff83 100644 --- a/test6/zip/zip.js +++ b/test/zip/zip.js @@ -2,6 +2,6 @@ const zip = (...arrays) => { const maxLength = Math.max(...arrays.map(x => x.length)); return Array.from({ length: maxLength }).map((_, i) => { return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); -}); + }; module.exports = zip; \ No newline at end of file diff --git a/test/zip/zip.test.js b/test/zip/zip.test.js new file mode 100644 index 000000000..a0b075e87 --- /dev/null +++ b/test/zip/zip.test.js @@ -0,0 +1,22 @@ +const expect = require('expect'); +const zip = require('./zip.js'); + + + test('zip is a Function', () => { + expect(zip).toBeInstanceOf(Function); +}); + t.deepEqual(zip(['a', 'b'], [1, 2], [true, false]), [['a', 1, true], ['b', 2, false]], 'zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]]'); + t.deepEqual(zip(['a'], [1, 2], [true, false]), [['a', 1, true], [undefined, 2, false]], 'zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]]'); + t.deepEqual(zip(), [], 'zip([]) returns []'); + t.deepEqual(zip(123), [], 'zip(123) returns []'); + test('zip([a, b], [1, 2], [true, false]) returns an Array', () => { + expect(Array.isArray(zip(['a', 'b'], [1, 2], [true, false]))).toBeTruthy(); +}); + test('zip([a], [1, 2], [true, false]) returns an Array', () => { + expect(Array.isArray(zip(['a'], [1, 2], [true, false]))).toBeTruthy(); +}); + t.throws(() => zip(null), 'zip(null) throws an error'); + t.throws(() => zip(undefined), 'zip(undefined) throws an error'); + + + diff --git a/test6/zipObject/zipObject.js b/test/zipObject/zipObject.js similarity index 91% rename from test6/zipObject/zipObject.js rename to test/zipObject/zipObject.js index c44e95eda..90aeeacf1 100644 --- a/test6/zipObject/zipObject.js +++ b/test/zipObject/zipObject.js @@ -1,3 +1,3 @@ const zipObject = (props, values) => -props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); +props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), { module.exports = zipObject; \ No newline at end of file diff --git a/test/zipObject/zipObject.test.js b/test/zipObject/zipObject.test.js new file mode 100644 index 000000000..c703b3f68 --- /dev/null +++ b/test/zipObject/zipObject.test.js @@ -0,0 +1,19 @@ +const expect = require('expect'); +const zipObject = require('./zipObject.js'); + + + test('zipObject is a Function', () => { + expect(zipObject).toBeInstanceOf(Function); +}); + t.deepEqual(zipObject(['a', 'b', 'c'], [1, 2]), {a: 1, b: 2, c: undefined}, 'zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined}'); + t.deepEqual(zipObject(['a', 'b'], [1, 2, 3]), {a: 1, b: 2}, 'zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2}'); + t.deepEqual(zipObject(['a', 'b', 'c'], 'string'), { a: 's', b: 't', c: 'r' }, 'zipObject([a, b, c], string) returns { a: s, b: t, c: r }'); + t.deepEqual(zipObject(['a'], 'string'), { a: 's' }, 'zipObject([a], string) returns { a: s }'); + t.throws(() => zipObject(), 'zipObject() throws an error'); + t.throws(() => zipObject(['string'], null), 'zipObject([string], null) throws an error'); + t.throws(() => zipObject(null, [1]), 'zipObject(null, [1]) throws an error'); + t.throws(() => zipObject('string'), 'zipObject(string) throws an error'); + t.throws(() => zipObject('test', 'string'), 'zipObject(test, string) throws an error'); + + + diff --git a/test6/zipWith/zipWith.js b/test/zipWith/zipWith.js similarity index 100% rename from test6/zipWith/zipWith.js rename to test/zipWith/zipWith.js diff --git a/test/zipWith/zipWith.test.js b/test/zipWith/zipWith.test.js new file mode 100644 index 000000000..f5e60492e --- /dev/null +++ b/test/zipWith/zipWith.test.js @@ -0,0 +1,8 @@ +const expect = require('expect'); +const zipWith = require('./zipWith.js'); + + + test('zipWith is a Function', () => { + expect(zipWith).toBeInstanceOf(Function); +}); + diff --git a/test2/defaults/defaults.test.js b/test2/defaults/defaults.test.js deleted file mode 100644 index 79c5a5472..000000000 --- a/test2/defaults/defaults.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const defaults = require('./defaults.js'); - -test('Testing defaults', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof defaults === 'function').toBeTruthy(); - expect(defaults({ a: 1 }, { b: 2 }, { b: 6 }, { a: 3 })).toEqual({ a: 1, b: 2 }); -}); diff --git a/test2/defer/defer.test.js b/test2/defer/defer.test.js deleted file mode 100644 index c5db044d2..000000000 --- a/test2/defer/defer.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const defer = require('./defer.js'); - -test('Testing defer', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof defer === 'function').toBeTruthy(); -}); diff --git a/test2/degreesToRads/degreesToRads.test.js b/test2/degreesToRads/degreesToRads.test.js deleted file mode 100644 index 742faaad3..000000000 --- a/test2/degreesToRads/degreesToRads.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const degreesToRads = require('./degreesToRads.js'); - -test('Testing degreesToRads', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - const approxeq = (v1,v2, diff = 0.001) => Math.abs(v1 - v2) < diff; // Use to account for rounding errors - expect(typeof degreesToRads === 'function').toBeTruthy(); - expect(approxeq(degreesToRads(90.0), Math.PI / 2)).toBeTruthy(); -}); diff --git a/test2/delay/delay.test.js b/test2/delay/delay.test.js deleted file mode 100644 index 68fc4dd89..000000000 --- a/test2/delay/delay.test.js +++ /dev/null @@ -1,15 +0,0 @@ -const expect = require('expect'); -const delay = require('./delay.js'); - -test('Testing delay', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof delay === 'function').toBeTruthy(); - delay( - function(text) { - expect(text).toBe('test'); - }, - 1000, - 'test' - ); -}); diff --git a/test2/detectDeviceType/detectDeviceType.test.js b/test2/detectDeviceType/detectDeviceType.test.js deleted file mode 100644 index 708f7ebe6..000000000 --- a/test2/detectDeviceType/detectDeviceType.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const detectDeviceType = require('./detectDeviceType.js'); - -test('Testing detectDeviceType', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof detectDeviceType === 'function').toBeTruthy(); -}); diff --git a/test2/difference/difference.test.js b/test2/difference/difference.test.js deleted file mode 100644 index 21e4fac21..000000000 --- a/test2/difference/difference.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const difference = require('./difference.js'); - -test('Testing difference', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof difference === 'function').toBeTruthy(); - expect(difference([1, 2, 3], [1, 2, 4])).toEqual([3]); -}); \ No newline at end of file diff --git a/test2/differenceBy/differenceBy.test.js b/test2/differenceBy/differenceBy.test.js deleted file mode 100644 index 4d7dfe471..000000000 --- a/test2/differenceBy/differenceBy.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const differenceBy = require('./differenceBy.js'); - -test('Testing differenceBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof differenceBy === 'function').toBeTruthy(); - expect(differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor)).toEqual([1.2]); - expect(differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], v => v.x)).toEqual([ { x: 2 } ]); -}); diff --git a/test2/differenceWith/differenceWith.test.js b/test2/differenceWith/differenceWith.test.js deleted file mode 100644 index 0e27a4501..000000000 --- a/test2/differenceWith/differenceWith.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const differenceWith = require('./differenceWith.js'); - -test('Testing differenceWith', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof differenceWith === 'function').toBeTruthy(); - expect( - differenceWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Math.round(b)) - ).toEqual([1, 1.2]); -}); \ No newline at end of file diff --git a/test2/digitize/digitize.test.js b/test2/digitize/digitize.test.js deleted file mode 100644 index 75b554e53..000000000 --- a/test2/digitize/digitize.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const digitize = require('./digitize.js'); - -test('Testing digitize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof digitize === 'function').toBeTruthy(); - expect(digitize(123)).toEqual([1, 2, 3]); -}); \ No newline at end of file diff --git a/test2/distance/distance.test.js b/test2/distance/distance.test.js deleted file mode 100644 index 495cf60c0..000000000 --- a/test2/distance/distance.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const distance = require('./distance.js'); - -test('Testing distance', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof distance === 'function').toBeTruthy(); - expect(distance(1, 1, 2, 3)).toBe(2.23606797749979); -}); diff --git a/test2/drop/drop.test.js b/test2/drop/drop.test.js deleted file mode 100644 index ea9715842..000000000 --- a/test2/drop/drop.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const drop = require('./drop.js'); - -test('Testing drop', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof drop === 'function').toBeTruthy(); - expect(drop([1, 2, 3])).toEqual([2,3]); - expect(drop([1, 2, 3], 2)).toEqual([3]); - expect(drop([1, 2, 3], 42)).toEqual([]); -}); diff --git a/test2/dropRight/dropRight.test.js b/test2/dropRight/dropRight.test.js deleted file mode 100644 index ffd46e6d3..000000000 --- a/test2/dropRight/dropRight.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const dropRight = require('./dropRight.js'); - -test('Testing dropRight', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof dropRight === 'function').toBeTruthy(); - expect(dropRight([1, 2, 3])).toEqual([1,2]); - expect(dropRight([1, 2, 3], 2)).toEqual([1]); - expect(dropRight([1, 2, 3], 42)).toEqual([]); -}); \ No newline at end of file diff --git a/test2/dropRightWhile/dropRightWhile.test.js b/test2/dropRightWhile/dropRightWhile.test.js deleted file mode 100644 index 1df6588a5..000000000 --- a/test2/dropRightWhile/dropRightWhile.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const dropRightWhile = require('./dropRightWhile.js'); - -test('Testing dropRightWhile', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof dropRightWhile === 'function').toBeTruthy(); - expect(dropRightWhile([1, 2, 3, 4], n => n < 3)).toEqual([1, 2]); -}); diff --git a/test2/dropWhile/dropWhile.test.js b/test2/dropWhile/dropWhile.test.js deleted file mode 100644 index 8a2be7a17..000000000 --- a/test2/dropWhile/dropWhile.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const dropWhile = require('./dropWhile.js'); - -test('Testing dropWhile', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof dropWhile === 'function').toBeTruthy(); - expect(dropWhile([1, 2, 3, 4], n => n >= 3)).toEqual([3,4]); -}); diff --git a/test2/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js b/test2/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js deleted file mode 100644 index 2707cbc4e..000000000 --- a/test2/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const elementIsVisibleInViewport = require('./elementIsVisibleInViewport.js'); - -test('Testing elementIsVisibleInViewport', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof elementIsVisibleInViewport === 'function').toBeTruthy(); -}); diff --git a/test2/elo/elo.test.js b/test2/elo/elo.test.js deleted file mode 100644 index a0c483696..000000000 --- a/test2/elo/elo.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const elo = require('./elo.js'); - -test('Testing elo', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof elo === 'function').toBeTruthy(); - expect(elo([1200, 1200])).toEqual([1216, 1184]); - expect(elo([1200, 1200], 64)).toEqual([1232, 1168]), "Standard 1v1s"; - expect(elo([1200, 1200, 1200, 1200]).map(Math.round)).toEqual([1246, 1215, 1185, 1154]); -}); \ No newline at end of file diff --git a/test2/equals/equals.test.js b/test2/equals/equals.test.js deleted file mode 100644 index f84987498..000000000 --- a/test2/equals/equals.test.js +++ /dev/null @@ -1,15 +0,0 @@ -const expect = require('expect'); -const equals = require('./equals.js'); - -test('Testing equals', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof equals === 'function').toBeTruthy(); - expect( - equals({ a: [2, {e: 3}], b: [4], c: 'foo' }, { a: [2, {e: 3}], b: [4], c: 'foo' }) - ).toBeTruthy(); - expect(equals([1, 2, 3], [1, 2, 3])).toBeTruthy(); - expect(equals({ a: [2, 3], b: [4] }, { a: [2, 3], b: [6] })).toBeFalsy(); - expect(equals([1, 2, 3], [1, 2, 4])).toBeFalsy(); - expect(equals([1, 2, 3], { 0: 1, 1: 2, 2: 3 })).toBeTruthy(); -}); diff --git a/test2/escapeHTML/escapeHTML.test.js b/test2/escapeHTML/escapeHTML.test.js deleted file mode 100644 index a040ed437..000000000 --- a/test2/escapeHTML/escapeHTML.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const escapeHTML = require('./escapeHTML.js'); - -test('Testing escapeHTML', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof escapeHTML === 'function').toBeTruthy(); - expect(escapeHTML('Me & you')).toBe('<a href="#">Me & you</a>'); -}); \ No newline at end of file diff --git a/test2/escapeRegExp/escapeRegExp.test.js b/test2/escapeRegExp/escapeRegExp.test.js deleted file mode 100644 index 1890779fb..000000000 --- a/test2/escapeRegExp/escapeRegExp.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const escapeRegExp = require('./escapeRegExp.js'); - -test('Testing escapeRegExp', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof escapeRegExp === 'function').toBeTruthy(); - expect(escapeRegExp('(test)')).toBe('\\(test\\)'); -}); \ No newline at end of file diff --git a/test2/everyNth/everyNth.test.js b/test2/everyNth/everyNth.test.js deleted file mode 100644 index 7301eeeed..000000000 --- a/test2/everyNth/everyNth.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const everyNth = require('./everyNth.js'); - -test('Testing everyNth', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof everyNth === 'function').toBeTruthy(); - expect(everyNth([1, 2, 3, 4, 5, 6], 2)).toEqual([ 2, 4, 6 ]); -}); \ No newline at end of file diff --git a/test2/extendHex/extendHex.test.js b/test2/extendHex/extendHex.test.js deleted file mode 100644 index 172c9259e..000000000 --- a/test2/extendHex/extendHex.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const extendHex = require('./extendHex.js'); - -test('Testing extendHex', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof extendHex === 'function').toBeTruthy(); - expect(extendHex('#03f')).toBe('#0033ff'); - expect(extendHex('05a')).toBe('#0055aa'); -}); \ No newline at end of file diff --git a/test2/factorial/factorial.test.js b/test2/factorial/factorial.test.js deleted file mode 100644 index ea04c6b50..000000000 --- a/test2/factorial/factorial.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const factorial = require('./factorial.js'); - -test('Testing factorial', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof factorial === 'function').toBeTruthy(); - expect(factorial(6)).toBe(720); - expect(factorial(0)).toBe(1); - expect(factorial(1)).toBe(1); - expect(factorial(4)).toBe(24); - expect(factorial(10)).toBe(3628800); -}); \ No newline at end of file diff --git a/test2/factors/factors.test.js b/test2/factors/factors.test.js deleted file mode 100644 index 458b48f5c..000000000 --- a/test2/factors/factors.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const factors = require('./factors.js'); - -test('Testing factors', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof factors === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test2/fibonacci/fibonacci.test.js b/test2/fibonacci/fibonacci.test.js deleted file mode 100644 index cd3be86df..000000000 --- a/test2/fibonacci/fibonacci.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const fibonacci = require('./fibonacci.js'); - -test('Testing fibonacci', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof fibonacci === 'function').toBeTruthy(); - expect(fibonacci(6)).toEqual([0, 1, 1, 2, 3, 5]); -}); \ No newline at end of file diff --git a/test2/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js b/test2/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js deleted file mode 100644 index b54b33bf5..000000000 --- a/test2/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const fibonacciCountUntilNum = require('./fibonacciCountUntilNum.js'); - -test('Testing fibonacciCountUntilNum', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof fibonacciCountUntilNum === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test2/fibonacciUntilNum/fibonacciUntilNum.test.js b/test2/fibonacciUntilNum/fibonacciUntilNum.test.js deleted file mode 100644 index 77d6970ae..000000000 --- a/test2/fibonacciUntilNum/fibonacciUntilNum.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const fibonacciUntilNum = require('./fibonacciUntilNum.js'); - -test('Testing fibonacciUntilNum', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof fibonacciUntilNum === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test2/filterNonUnique/filterNonUnique.test.js b/test2/filterNonUnique/filterNonUnique.test.js deleted file mode 100644 index 05009e044..000000000 --- a/test2/filterNonUnique/filterNonUnique.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const filterNonUnique = require('./filterNonUnique.js'); - -test('Testing filterNonUnique', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof filterNonUnique === 'function').toBeTruthy(); - expect(filterNonUnique([1, 2, 2, 3, 4, 4, 5])).toEqual([1,3,5]); -}); \ No newline at end of file diff --git a/test2/findKey/findKey.test.js b/test2/findKey/findKey.test.js deleted file mode 100644 index 9c3e354a4..000000000 --- a/test2/findKey/findKey.test.js +++ /dev/null @@ -1,16 +0,0 @@ -const expect = require('expect'); -const findKey = require('./findKey.js'); - -test('Testing findKey', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof findKey === 'function').toBeTruthy(); - expect(findKey( - { - barney: { age: 36, active: true }, - fred: { age: 40, active: false }, - pebbles: { age: 1, active: true } - }, - o => o['active'] -)).toEqual('barney'); -}); diff --git a/test2/findLast/findLast.test.js b/test2/findLast/findLast.test.js deleted file mode 100644 index 69e768dee..000000000 --- a/test2/findLast/findLast.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const findLast = require('./findLast.js'); - -test('Testing findLast', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof findLast === 'function').toBeTruthy(); - expect(findLast([1, 2, 3, 4], n => n % 2 === 1)).toBe(3); -}); diff --git a/test2/findLastIndex/findLastIndex.test.js b/test2/findLastIndex/findLastIndex.test.js deleted file mode 100644 index 2e1c57351..000000000 --- a/test2/findLastIndex/findLastIndex.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const findLastIndex = require('./findLastIndex.js'); - -test('Testing findLastIndex', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof findLastIndex === 'function').toBeTruthy(); - expect(findLastIndex([1, 2, 3, 4], n => n % 2 === 1)).toBe(2); -}); diff --git a/test2/findLastKey/findLastKey.test.js b/test2/findLastKey/findLastKey.test.js deleted file mode 100644 index bbaa493d5..000000000 --- a/test2/findLastKey/findLastKey.test.js +++ /dev/null @@ -1,16 +0,0 @@ -const expect = require('expect'); -const findLastKey = require('./findLastKey.js'); - -test('Testing findLastKey', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof findLastKey === 'function').toBeTruthy(); - expect(findLastKey( - { - barney: { age: 36, active: true }, - fred: { age: 40, active: false }, - pebbles: { age: 1, active: true } - }, - o => o['active'] -)).toBe('pebbles'); -}); diff --git a/test2/flatten/flatten.test.js b/test2/flatten/flatten.test.js deleted file mode 100644 index 24da6650b..000000000 --- a/test2/flatten/flatten.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const flatten = require('./flatten.js'); - -test('Testing flatten', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof flatten === 'function').toBeTruthy(); - expect(flatten([1, [2], 3, 4])).toEqual([1, 2, 3, 4]); - expect(flatten([1, [2, [3, [4, 5], 6], 7], 8], 2)).toEqual([1, 2, 3, [4, 5], 6, 7, 8]); -}); \ No newline at end of file diff --git a/test2/flattenObject/flattenObject.test.js b/test2/flattenObject/flattenObject.test.js deleted file mode 100644 index cc864ba37..000000000 --- a/test2/flattenObject/flattenObject.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const flattenObject = require('./flattenObject.js'); - -test('Testing flattenObject', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof flattenObject === 'function').toBeTruthy(); - expect(flattenObject({ a: { b: { c: 1 } }, d: 1 })).toEqual({ 'a.b.c': 1, d: 1 }); - expect(flattenObject([0,1,[2,[1]],1])).toEqual({ 0: 0, 1: 1, 3: 1, '2.0': 2, '2.1.0': 1 }); -}); diff --git a/test2/flip/flip.test.js b/test2/flip/flip.test.js deleted file mode 100644 index 6227b2f44..000000000 --- a/test2/flip/flip.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const flip = require('./flip.js'); - -test('Testing flip', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof flip === 'function').toBeTruthy(); - let a = { name: 'John Smith' }; - let b = {}; - const mergeFrom = flip(Object.assign); - let mergePerson = mergeFrom.bind(null, a); - expect(mergePerson(b)).toEqual(a); -}); diff --git a/test2/forEachRight/forEachRight.test.js b/test2/forEachRight/forEachRight.test.js deleted file mode 100644 index b64188386..000000000 --- a/test2/forEachRight/forEachRight.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const forEachRight = require('./forEachRight.js'); - -test('Testing forEachRight', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof forEachRight === 'function').toBeTruthy(); - let output = ''; - forEachRight([1, 2, 3, 4], val => output+=val); - expect(output).toBe('4321'); -}); diff --git a/test2/forOwn/forOwn.test.js b/test2/forOwn/forOwn.test.js deleted file mode 100644 index 85553ad3f..000000000 --- a/test2/forOwn/forOwn.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const forOwn = require('./forOwn.js'); - -test('Testing forOwn', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof forOwn === 'function').toBeTruthy(); - let output = []; - forOwn({ foo: 'bar', a: 1 }, v => output.push(v)); // 'bar', 1 - expect(output).toEqual(['bar', 1]); -}); diff --git a/test2/forOwnRight/forOwnRight.test.js b/test2/forOwnRight/forOwnRight.test.js deleted file mode 100644 index db6008220..000000000 --- a/test2/forOwnRight/forOwnRight.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const forOwnRight = require('./forOwnRight.js'); - -test('Testing forOwnRight', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof forOwnRight === 'function').toBeTruthy(); - let output = []; - forOwnRight({ foo: 'bar', a: 1 }, v => output.push(v)); // 'bar', 1 - expect(output).toEqual([1, 'bar']); -}); diff --git a/test2/formatDuration/formatDuration.test.js b/test2/formatDuration/formatDuration.test.js deleted file mode 100644 index ebe26a0bd..000000000 --- a/test2/formatDuration/formatDuration.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const formatDuration = require('./formatDuration.js'); - -test('Testing formatDuration', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof formatDuration === 'function').toBeTruthy(); - expect(formatDuration(1001)).toBe('1 second, 1 millisecond'); - expect(formatDuration(34325055574)).toBe('397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds'); -}); \ No newline at end of file diff --git a/test2/fromCamelCase/fromCamelCase.test.js b/test2/fromCamelCase/fromCamelCase.test.js deleted file mode 100644 index 5ab939e12..000000000 --- a/test2/fromCamelCase/fromCamelCase.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const fromCamelCase = require('./fromCamelCase.js'); - -test('Testing fromCamelCase', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof fromCamelCase === 'function').toBeTruthy(); - expect(fromCamelCase('someDatabaseFieldName', ' ')).toBe('some database field name'); - expect(fromCamelCase('someLabelThatNeedsToBeCamelized', '-')).toBe('some-label-that-needs-to-be-camelized'); - expect(fromCamelCase('someJavascriptProperty', '_')).toBe('some_javascript_property'); -}); \ No newline at end of file diff --git a/test2/functionName/functionName.test.js b/test2/functionName/functionName.test.js deleted file mode 100644 index 8d00a5278..000000000 --- a/test2/functionName/functionName.test.js +++ /dev/null @@ -1,19 +0,0 @@ -import expect from 'expect'; -let output = ''; -const console = {}; -console.debug = (x) => output = x; -// Override for testing -const functionName = fn => (console.debug(fn.name), fn); -test('Testing functionName', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof functionName === 'function').toBeTruthy(); - functionName(Math.max); - expect(output).toBe('max'); - function fun(x) {return x;} - functionName(fun); - expect(output).toBe('fun'); - const fn = x => x; - functionName(fn); - expect(output).toBe('fn'); -}); diff --git a/test2/functions/functions.test.js b/test2/functions/functions.test.js deleted file mode 100644 index c6f94fc8c..000000000 --- a/test2/functions/functions.test.js +++ /dev/null @@ -1,15 +0,0 @@ -const expect = require('expect'); -const functions = require('./functions.js'); - -test('Testing functions', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof functions === 'function').toBeTruthy(); - function Foo() { - this.a = () => 1; - this.b = () => 2; - } - Foo.prototype.c = () => 3; - expect(functions(new Foo())).toEqual(['a', 'b']); - expect(functions(new Foo(), true)).toEqual(['a', 'b', 'c']); -}); diff --git a/test2/gcd/gcd.test.js b/test2/gcd/gcd.test.js deleted file mode 100644 index a96a20050..000000000 --- a/test2/gcd/gcd.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const gcd = require('./gcd.js'); - -test('Testing gcd', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof gcd === 'function').toBeTruthy(); - expect(gcd(8, 36)).toBe(4); - expect(gcd(...[12, 8, 32])).toEqual(4); -}); \ No newline at end of file diff --git a/test2/geometricProgression/geometricProgression.test.js b/test2/geometricProgression/geometricProgression.test.js deleted file mode 100644 index d1cd39d4c..000000000 --- a/test2/geometricProgression/geometricProgression.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const geometricProgression = require('./geometricProgression.js'); - -test('Testing geometricProgression', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof geometricProgression === 'function').toBeTruthy(); - expect(geometricProgression(256)).toEqual([1, 2, 4, 8, 16, 32, 64, 128, 256]); - expect(geometricProgression(256, 3)).toEqual([3, 6, 12, 24, 48, 96, 192]); - expect(geometricProgression(256, 1, 4)).toEqual([1, 4, 16, 64, 256]); -}); \ No newline at end of file diff --git a/test2/get/get.test.js b/test2/get/get.test.js deleted file mode 100644 index 358f50b85..000000000 --- a/test2/get/get.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const get = require('./get.js'); - -test('Testing get', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof get === 'function').toBeTruthy(); - const obj = { selector: { to: { val: 'val to get' } } }; - expect(get(obj, 'selector.to.val')).toEqual(['val to get']); -}); diff --git a/test2/getColonTimeFromDate/getColonTimeFromDate.test.js b/test2/getColonTimeFromDate/getColonTimeFromDate.test.js deleted file mode 100644 index 6336f0a1e..000000000 --- a/test2/getColonTimeFromDate/getColonTimeFromDate.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const getColonTimeFromDate = require('./getColonTimeFromDate.js'); - -test('Testing getColonTimeFromDate', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof getColonTimeFromDate === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test2/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js b/test2/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js deleted file mode 100644 index c3c9ab2e0..000000000 --- a/test2/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const getDaysDiffBetweenDates = require('./getDaysDiffBetweenDates.js'); - -test('Testing getDaysDiffBetweenDates', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof getDaysDiffBetweenDates === 'function').toBeTruthy(); - expect(getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22'))).toBe(9); -}); \ No newline at end of file diff --git a/test2/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js b/test2/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js deleted file mode 100644 index c265282ef..000000000 --- a/test2/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const getMeridiemSuffixOfInteger = require('./getMeridiemSuffixOfInteger.js'); - -test('Testing getMeridiemSuffixOfInteger', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof getMeridiemSuffixOfInteger === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test2/getScrollPosition/getScrollPosition.test.js b/test2/getScrollPosition/getScrollPosition.test.js deleted file mode 100644 index ca75aec52..000000000 --- a/test2/getScrollPosition/getScrollPosition.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const getScrollPosition = require('./getScrollPosition.js'); - -test('Testing getScrollPosition', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof getScrollPosition === 'function').toBeTruthy(); -}); diff --git a/test2/getStyle/getStyle.test.js b/test2/getStyle/getStyle.test.js deleted file mode 100644 index 1d1fc4e47..000000000 --- a/test2/getStyle/getStyle.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const getStyle = require('./getStyle.js'); - -test('Testing getStyle', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof getStyle === 'function').toBeTruthy(); -}); diff --git a/test2/getType/getType.test.js b/test2/getType/getType.test.js deleted file mode 100644 index 4e7b38e4b..000000000 --- a/test2/getType/getType.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const getType = require('./getType.js'); - -test('Testing getType', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof getType === 'function').toBeTruthy(); - expect(getType(new Set([1, 2, 3]))).toBe('set'); -}); \ No newline at end of file diff --git a/test2/getURLParameters/getURLParameters.test.js b/test2/getURLParameters/getURLParameters.test.js deleted file mode 100644 index 4b93ceca6..000000000 --- a/test2/getURLParameters/getURLParameters.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const getURLParameters = require('./getURLParameters.js'); - -test('Testing getURLParameters', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof getURLParameters === 'function').toBeTruthy(); - expect(getURLParameters('http://url.com/page?name=Adam&surname=Smith')).toEqual({name: 'Adam', surname: 'Smith'}); -}); \ No newline at end of file diff --git a/test3/groupBy/groupBy.test.js b/test3/groupBy/groupBy.test.js deleted file mode 100644 index a639ba073..000000000 --- a/test3/groupBy/groupBy.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const groupBy = require('./groupBy.js'); - -test('Testing groupBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof groupBy === 'function').toBeTruthy(); - expect(groupBy([6.1, 4.2, 6.3], Math.floor)).toEqual({4: [4.2], 6: [6.1, 6.3]}); - expect(groupBy(['one', 'two', 'three'], 'length')).toEqual({3: ['one', 'two'], 5: ['three']}); -}); \ No newline at end of file diff --git a/test3/hammingDistance/hammingDistance.test.js b/test3/hammingDistance/hammingDistance.test.js deleted file mode 100644 index 8ec3fef99..000000000 --- a/test3/hammingDistance/hammingDistance.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const hammingDistance = require('./hammingDistance.js'); - -test('Testing hammingDistance', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hammingDistance === 'function').toBeTruthy(); - expect(hammingDistance(2, 3)).toBe(1); -}); \ No newline at end of file diff --git a/test3/hasClass/hasClass.test.js b/test3/hasClass/hasClass.test.js deleted file mode 100644 index 5b04c1444..000000000 --- a/test3/hasClass/hasClass.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const hasClass = require('./hasClass.js'); - -test('Testing hasClass', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hasClass === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/hasFlags/hasFlags.test.js b/test3/hasFlags/hasFlags.test.js deleted file mode 100644 index 50a922aae..000000000 --- a/test3/hasFlags/hasFlags.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const hasFlags = require('./hasFlags.js'); - -test('Testing hasFlags', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hasFlags === 'function').toBeTruthy(); -}); diff --git a/test3/hashBrowser/hashBrowser.test.js b/test3/hashBrowser/hashBrowser.test.js deleted file mode 100644 index 103e968b1..000000000 --- a/test3/hashBrowser/hashBrowser.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const hashBrowser = require('./hashBrowser.js'); - -test('Testing hashBrowser', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hashBrowser === 'function').toBeTruthy(); -}); diff --git a/test3/hashNode/hashNode.test.js b/test3/hashNode/hashNode.test.js deleted file mode 100644 index b594baf55..000000000 --- a/test3/hashNode/hashNode.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const hashNode = require('./hashNode.js'); - -test('Testing hashNode', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hashNode === 'function').toBeTruthy(); - hashNode(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(v => expect(v).toBe('04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393')); -}); diff --git a/test3/head/head.test.js b/test3/head/head.test.js deleted file mode 100644 index cb300bfcf..000000000 --- a/test3/head/head.test.js +++ /dev/null @@ -1,20 +0,0 @@ -const expect = require('expect'); -const head = require('./head.js'); - -test('Testing head', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof head === 'function').toBeTruthy(); - expect(head({ a: 1234}) === undefined).toBeTruthy(); - expect(head([1, 2, 3])).toBe(1); - expect(head({ 0: false})).toBe(false); - expect(head('String')).toBe('S'); - expect(() => head(null)).toThrow(); - expect(() => head(undefined)).toThrow(); - expect(() => head()).toThrow(); - - let start = new Date().getTime(); - head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/hexToRGB/hexToRGB.test.js b/test3/hexToRGB/hexToRGB.test.js deleted file mode 100644 index 20e0bdf32..000000000 --- a/test3/hexToRGB/hexToRGB.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const hexToRGB = require('./hexToRGB.js'); - -test('Testing hexToRGB', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hexToRGB === 'function').toBeTruthy(); - expect(hexToRGB('#27ae60ff')).toBe('rgba(39, 174, 96, 255)'); - expect(hexToRGB('27ae60')).toBe('rgb(39, 174, 96)'); - expect(hexToRGB('#fff')).toBe('rgb(255, 255, 255)'); -}); \ No newline at end of file diff --git a/test3/hide/hide.test.js b/test3/hide/hide.test.js deleted file mode 100644 index f011daf95..000000000 --- a/test3/hide/hide.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const hide = require('./hide.js'); - -test('Testing hide', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hide === 'function').toBeTruthy(); -}); diff --git a/test3/howManyTimes/howManyTimes.test.js b/test3/howManyTimes/howManyTimes.test.js deleted file mode 100644 index daacb5c6d..000000000 --- a/test3/howManyTimes/howManyTimes.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const howManyTimes = require('./howManyTimes.js'); - -test('Testing howManyTimes', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof howManyTimes === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/httpDelete/httpDelete.test.js b/test3/httpDelete/httpDelete.test.js deleted file mode 100644 index afc68db92..000000000 --- a/test3/httpDelete/httpDelete.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const httpDelete = require('./httpDelete.js'); - -test('Testing httpDelete', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof httpDelete === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/httpPut/httpPut.test.js b/test3/httpPut/httpPut.test.js deleted file mode 100644 index 57cc17100..000000000 --- a/test3/httpPut/httpPut.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const httpPut = require('./httpPut.js'); - -test('Testing httpPut', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof httpPut === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/httpsRedirect/httpsRedirect.js b/test3/httpsRedirect/httpsRedirect.js deleted file mode 100644 index 42473e321..000000000 --- a/test3/httpsRedirect/httpsRedirect.js +++ /dev/null @@ -1,4 +0,0 @@ -const httpsRedirect = () => { -if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); -}; -module.exports = httpsRedirect; \ No newline at end of file diff --git a/test3/httpsRedirect/httpsRedirect.test.js b/test3/httpsRedirect/httpsRedirect.test.js deleted file mode 100644 index dcea1d1e6..000000000 --- a/test3/httpsRedirect/httpsRedirect.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const httpsRedirect = require('./httpsRedirect.js'); - -test('Testing httpsRedirect', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof httpsRedirect === 'function').toBeTruthy(); -}); diff --git a/test3/hz/hz.test.js b/test3/hz/hz.test.js deleted file mode 100644 index 0181386c2..000000000 --- a/test3/hz/hz.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const hz = require('./hz.js'); - -test('Testing hz', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof hz === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/inRange/inRange.test.js b/test3/inRange/inRange.test.js deleted file mode 100644 index dbaa8e096..000000000 --- a/test3/inRange/inRange.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const inRange = require('./inRange.js'); - -test('Testing inRange', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof inRange === 'function').toBeTruthy(); - expect(inRange(3, 2, 5)).toBe(true); - expect(inRange(3, 4)).toBe(true); - expect(inRange(2, 3, 5)).toBe(false); - expect(inRange(3, 2)).toBe(false); -}); \ No newline at end of file diff --git a/test3/indexOfAll/indexOfAll.test.js b/test3/indexOfAll/indexOfAll.test.js deleted file mode 100644 index 792cd1f16..000000000 --- a/test3/indexOfAll/indexOfAll.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const indexOfAll = require('./indexOfAll.js'); - -test('Testing indexOfAll', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof indexOfAll === 'function').toBeTruthy(); - expect(indexOfAll([1, 2, 3, 1, 2, 3], 1)).toEqual([0,3]); - expect(indexOfAll([1, 2, 3], 4)).toEqual([]); -}); \ No newline at end of file diff --git a/test3/initial/initial.test.js b/test3/initial/initial.test.js deleted file mode 100644 index c4febca6a..000000000 --- a/test3/initial/initial.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const initial = require('./initial.js'); - -test('Testing initial', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof initial === 'function').toBeTruthy(); - expect(initial([1, 2, 3])).toEqual([1, 2]); -}); \ No newline at end of file diff --git a/test3/initialize2DArray/initialize2DArray.test.js b/test3/initialize2DArray/initialize2DArray.test.js deleted file mode 100644 index c8bbb69cb..000000000 --- a/test3/initialize2DArray/initialize2DArray.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const initialize2DArray = require('./initialize2DArray.js'); - -test('Testing initialize2DArray', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof initialize2DArray === 'function').toBeTruthy(); - expect(initialize2DArray(2, 2, 0)).toEqual([[0,0], [0,0]]); -}); \ No newline at end of file diff --git a/test3/initializeArrayWithRange/initializeArrayWithRange.test.js b/test3/initializeArrayWithRange/initializeArrayWithRange.test.js deleted file mode 100644 index e232928c2..000000000 --- a/test3/initializeArrayWithRange/initializeArrayWithRange.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const initializeArrayWithRange = require('./initializeArrayWithRange.js'); - -test('Testing initializeArrayWithRange', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof initializeArrayWithRange === 'function').toBeTruthy(); - expect(initializeArrayWithRange(5)).toEqual([0, 1, 2, 3, 4, 5]); -}); \ No newline at end of file diff --git a/test3/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js b/test3/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js deleted file mode 100644 index 462cf1c8b..000000000 --- a/test3/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const initializeArrayWithRangeRight = require('./initializeArrayWithRangeRight.js'); - -test('Testing initializeArrayWithRangeRight', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof initializeArrayWithRangeRight === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/initializeArrayWithValues/initializeArrayWithValues.test.js b/test3/initializeArrayWithValues/initializeArrayWithValues.test.js deleted file mode 100644 index c7b4bbd2f..000000000 --- a/test3/initializeArrayWithValues/initializeArrayWithValues.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const initializeArrayWithValues = require('./initializeArrayWithValues.js'); - -test('Testing initializeArrayWithValues', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof initializeArrayWithValues === 'function').toBeTruthy(); - expect(initializeArrayWithValues(5, 2)).toEqual([2, 2, 2, 2, 2]); -}); \ No newline at end of file diff --git a/test3/initializeNDArray/initializeNDArray.test.js b/test3/initializeNDArray/initializeNDArray.test.js deleted file mode 100644 index c2557c2ce..000000000 --- a/test3/initializeNDArray/initializeNDArray.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const initializeNDArray = require('./initializeNDArray.js'); - -test('Testing initializeNDArray', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof initializeNDArray === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/intersection/intersection.test.js b/test3/intersection/intersection.test.js deleted file mode 100644 index 10377e033..000000000 --- a/test3/intersection/intersection.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const intersection = require('./intersection.js'); - -test('Testing intersection', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof intersection === 'function').toBeTruthy(); - expect(intersection([1, 2, 3], [4, 3, 2])).toEqual([2, 3]); -}); \ No newline at end of file diff --git a/test3/intersectionBy/intersectionBy.test.js b/test3/intersectionBy/intersectionBy.test.js deleted file mode 100644 index 903e522ed..000000000 --- a/test3/intersectionBy/intersectionBy.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const intersectionBy = require('./intersectionBy.js'); - -test('Testing intersectionBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof intersectionBy === 'function').toBeTruthy(); - expect(intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor)).toEqual([2.1]); -}); diff --git a/test3/intersectionWith/intersectionWith.test.js b/test3/intersectionWith/intersectionWith.test.js deleted file mode 100644 index bf2c4a091..000000000 --- a/test3/intersectionWith/intersectionWith.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const intersectionWith = require('./intersectionWith.js'); - -test('Testing intersectionWith', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof intersectionWith === 'function').toBeTruthy(); - expect( - intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)) - ).toEqual([1.5, 3, 0]); -}); diff --git a/test3/invertKeyValues/invertKeyValues.test.js b/test3/invertKeyValues/invertKeyValues.test.js deleted file mode 100644 index 02a21f85e..000000000 --- a/test3/invertKeyValues/invertKeyValues.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const invertKeyValues = require('./invertKeyValues.js'); - -test('Testing invertKeyValues', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof invertKeyValues === 'function').toBeTruthy(); - expect(invertKeyValues({ a: 1, b: 2, c: 1 })).toEqual({ 1: [ 'a', 'c' ], 2: [ 'b' ] }); - expect(invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value)).toEqual({ group1: [ 'a', 'c' ], group2: [ 'b' ] }); -}); \ No newline at end of file diff --git a/test3/is/is.test.js b/test3/is/is.test.js deleted file mode 100644 index b39b90d11..000000000 --- a/test3/is/is.test.js +++ /dev/null @@ -1,24 +0,0 @@ -const expect = require('expect'); -const is = require('./is.js'); - -test('Testing is', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof is === 'function').toBeTruthy(); - expect(is(Array, [1])).toBeTruthy(); - expect(is(Array, [])).toBeTruthy(); - expect(is(Array, {})).toBeFalsy(); - expect(is(Object, {})).toBeTruthy(); - expect(is(Map, new Map())).toBeTruthy(); - expect(is(RegExp, /./g)).toBeTruthy(); - expect(is(Set, new Set())).toBeTruthy(); - expect(is(WeakMap, new WeakMap())).toBeTruthy(); - expect(is(WeakSet, new WeakSet())).toBeTruthy(); - expect(is(String, '')).toBeTruthy(); - expect(is(String, new String(''))).toBeTruthy(); - expect(is(Number, 1)).toBeTruthy(); - expect(is(Number, new Number('10'))).toBeTruthy(); - expect(is(Boolean, false)).toBeTruthy(); - expect(is(Boolean, new Boolean(false))).toBeTruthy(); - expect(is(Function, () => null)).toBeTruthy(); -}); diff --git a/test3/isAbsoluteURL/isAbsoluteURL.test.js b/test3/isAbsoluteURL/isAbsoluteURL.test.js deleted file mode 100644 index 085b7cf3c..000000000 --- a/test3/isAbsoluteURL/isAbsoluteURL.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const isAbsoluteURL = require('./isAbsoluteURL.js'); - -test('Testing isAbsoluteURL', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isAbsoluteURL === 'function').toBeTruthy(); - expect(isAbsoluteURL('https://google.com')).toBe(true); - expect(isAbsoluteURL('ftp://www.myserver.net')).toBe(true); - expect(isAbsoluteURL('/foo/bar')).toBe(false); -}); \ No newline at end of file diff --git a/test3/isArmstrongNumber/isArmstrongNumber.test.js b/test3/isArmstrongNumber/isArmstrongNumber.test.js deleted file mode 100644 index 07c78dd06..000000000 --- a/test3/isArmstrongNumber/isArmstrongNumber.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isArmstrongNumber = require('./isArmstrongNumber.js'); - -test('Testing isArmstrongNumber', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isArmstrongNumber === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/isArray/isArray.test.js b/test3/isArray/isArray.test.js deleted file mode 100644 index 21416f848..000000000 --- a/test3/isArray/isArray.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const isArray = require('./isArray.js'); - -test('Testing isArray', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isArray === 'function').toBeTruthy(); - expect(isArray([1])).toBe(true); - expect(isArray('array')).toBe(false); -}); \ No newline at end of file diff --git a/test3/isArrayBuffer/isArrayBuffer.test.js b/test3/isArrayBuffer/isArrayBuffer.test.js deleted file mode 100644 index 3e9264b89..000000000 --- a/test3/isArrayBuffer/isArrayBuffer.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isArrayBuffer = require('./isArrayBuffer.js'); - -test('Testing isArrayBuffer', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isArrayBuffer === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/isArrayLike/isArrayLike.test.js b/test3/isArrayLike/isArrayLike.test.js deleted file mode 100644 index a11a11186..000000000 --- a/test3/isArrayLike/isArrayLike.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const isArrayLike = require('./isArrayLike.js'); - -test('Testing isArrayLike', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isArrayLike === 'function').toBeTruthy(); - expect(isArrayLike('abc')).toBe(true); - expect(isArrayLike([1,2,3])).toBe(true); - expect(isArrayLike(null)).toBe(false); -}); diff --git a/test3/isBoolean/isBoolean.test.js b/test3/isBoolean/isBoolean.test.js deleted file mode 100644 index f5b7ebefd..000000000 --- a/test3/isBoolean/isBoolean.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const isBoolean = require('./isBoolean.js'); - -test('Testing isBoolean', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isBoolean === 'function').toBeTruthy(); - expect(isBoolean(null)).toBe(false); - expect(isBoolean(false)).toBe(true); -}); \ No newline at end of file diff --git a/test3/isBrowser/isBrowser.test.js b/test3/isBrowser/isBrowser.test.js deleted file mode 100644 index bb0a421d5..000000000 --- a/test3/isBrowser/isBrowser.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isBrowser = require('./isBrowser.js'); - -test('Testing isBrowser', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isBrowser === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/isBrowserTabFocused/isBrowserTabFocused.test.js b/test3/isBrowserTabFocused/isBrowserTabFocused.test.js deleted file mode 100644 index 54989d858..000000000 --- a/test3/isBrowserTabFocused/isBrowserTabFocused.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isBrowserTabFocused = require('./isBrowserTabFocused.js'); - -test('Testing isBrowserTabFocused', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isBrowserTabFocused === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/isDivisible/isDivisible.test.js b/test3/isDivisible/isDivisible.test.js deleted file mode 100644 index 637d6b4d5..000000000 --- a/test3/isDivisible/isDivisible.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const isDivisible = require('./isDivisible.js'); - -test('Testing isDivisible', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isDivisible === 'function').toBeTruthy(); - expect(isDivisible(6, 3)).toBe(true); -}); \ No newline at end of file diff --git a/test3/isEmpty/isEmpty.test.js b/test3/isEmpty/isEmpty.test.js deleted file mode 100644 index 70806b461..000000000 --- a/test3/isEmpty/isEmpty.test.js +++ /dev/null @@ -1,18 +0,0 @@ -const expect = require('expect'); -const isEmpty = require('./isEmpty.js'); - -test('Testing isEmpty', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isEmpty === 'function').toBeTruthy(); - expect(isEmpty(new Map())).toBe(true); - expect(isEmpty(new Set())).toBe(true); - expect(isEmpty([])).toBe(true); - expect(isEmpty({})).toBe(true); - expect(isEmpty('')).toBe(true); - expect(isEmpty([1, 2])).toBe(false); - expect(isEmpty({ a: 1, b: 2 })).toBe(false); - expect(isEmpty('text')).toBe(false); - expect(isEmpty(123)).toBe(true); - expect(isEmpty(true)).toBe(true); -}); diff --git a/test3/isEven/isEven.test.js b/test3/isEven/isEven.test.js deleted file mode 100644 index 1babab815..000000000 --- a/test3/isEven/isEven.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const isEven = require('./isEven.js'); - -test('Testing isEven', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isEven === 'function').toBeTruthy(); - expect(isEven(4)).toBe(true); - expect(isEven(5)).toBeFalsy(); -}); \ No newline at end of file diff --git a/test3/isFunction/isFunction.test.js b/test3/isFunction/isFunction.test.js deleted file mode 100644 index 97c8b64f5..000000000 --- a/test3/isFunction/isFunction.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const isFunction = require('./isFunction.js'); - -test('Testing isFunction', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isFunction === 'function').toBeTruthy(); - expect(isFunction(x => x)).toBe(true); - expect(isFunction('x')).toBe(false); -}); \ No newline at end of file diff --git a/test3/isLowerCase/isLowerCase.test.js b/test3/isLowerCase/isLowerCase.test.js deleted file mode 100644 index 624400811..000000000 --- a/test3/isLowerCase/isLowerCase.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const isLowerCase = require('./isLowerCase.js'); - -test('Testing isLowerCase', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isLowerCase === 'function').toBeTruthy(); - expect(isLowerCase('abc')).toBe(true); - expect(isLowerCase('a3@$')).toBe(true); - expect(isLowerCase('A3@$')).toBe(false); -}); \ No newline at end of file diff --git a/test3/isMap/isMap.test.js b/test3/isMap/isMap.test.js deleted file mode 100644 index 27a16b4a6..000000000 --- a/test3/isMap/isMap.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isMap = require('./isMap.js'); - -test('Testing isMap', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isMap === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test3/isNil/isNil.test.js b/test3/isNil/isNil.test.js deleted file mode 100644 index d3412b0fb..000000000 --- a/test3/isNil/isNil.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const isNil = require('./isNil.js'); - -test('Testing isNil', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isNil === 'function').toBeTruthy(); - expect(isNil(null)).toBe(true); - expect(isNil(undefined)).toBe(true); - expect(isNil('')).toBe(false); -}); diff --git a/test3/isNull/isNull.test.js b/test3/isNull/isNull.test.js deleted file mode 100644 index d9d6935c0..000000000 --- a/test3/isNull/isNull.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const isNull = require('./isNull.js'); - -test('Testing isNull', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isNull === 'function').toBeTruthy(); - expect(isNull(null)).toBe(true); - expect(isNull(NaN)).toBe(false); -}); \ No newline at end of file diff --git a/test3/isNumber/isNumber.test.js b/test3/isNumber/isNumber.test.js deleted file mode 100644 index c0effd774..000000000 --- a/test3/isNumber/isNumber.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const isNumber = require('./isNumber.js'); - -test('Testing isNumber', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isNumber === 'function').toBeTruthy(); - expect(isNumber(1)).toBe(true); - expect(isNumber('1')).toBe(false); -}); \ No newline at end of file diff --git a/test3/isObject/isObject.test.js b/test3/isObject/isObject.test.js deleted file mode 100644 index 8531462f5..000000000 --- a/test3/isObject/isObject.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const isObject = require('./isObject.js'); - -test('Testing isObject', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isObject === 'function').toBeTruthy(); - - expect(isObject([1, 2, 3, 4])).toBeTruthy(); - expect(isObject([])).toBeTruthy(); - expect(isObject({ a:1 })).toBeTruthy(); - expect(isObject(true)).toBeFalsy(); -}); diff --git a/test3/isObjectLike/isObjectLike.test.js b/test3/isObjectLike/isObjectLike.test.js deleted file mode 100644 index 5058fe8b1..000000000 --- a/test3/isObjectLike/isObjectLike.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const isObjectLike = require('./isObjectLike.js'); - -test('Testing isObjectLike', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isObjectLike === 'function').toBeTruthy(); - expect(isObjectLike({})).toBe(true); - expect(isObjectLike([1, 2, 3])).toBe(true); - expect(isObjectLike(x => x)).toBe(false); - expect(isObjectLike(null)).toBe(false); -}); diff --git a/test3/isPlainObject/isPlainObject.test.js b/test3/isPlainObject/isPlainObject.test.js deleted file mode 100644 index ce6feaa5b..000000000 --- a/test3/isPlainObject/isPlainObject.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const isPlainObject = require('./isPlainObject.js'); - -test('Testing isPlainObject', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isPlainObject === 'function').toBeTruthy(); - expect(isPlainObject({ a: 1 })).toBe(true); - expect(isPlainObject(new Map())).toBe(false); -}); diff --git a/test4/JSONToDate/JSONToDate.test.js b/test4/JSONToDate/JSONToDate.test.js deleted file mode 100644 index bf3f186c8..000000000 --- a/test4/JSONToDate/JSONToDate.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const JSONToDate = require('./JSONToDate.js'); - -test('Testing JSONToDate', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof JSONToDate === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/JSONToFile/JSONToFile.test.js b/test4/JSONToFile/JSONToFile.test.js deleted file mode 100644 index 6a17cb86d..000000000 --- a/test4/JSONToFile/JSONToFile.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const JSONToFile = require('./JSONToFile.js'); - -test('Testing JSONToFile', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof JSONToFile === 'function').toBeTruthy(); -}); diff --git a/test4/isPrime/isPrime.test.js b/test4/isPrime/isPrime.test.js deleted file mode 100644 index 5d17948ef..000000000 --- a/test4/isPrime/isPrime.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const isPrime = require('./isPrime.js'); - -test('Testing isPrime', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isPrime === 'function').toBeTruthy(); - expect(isPrime(11)).toBe(true); -}); \ No newline at end of file diff --git a/test4/isPrimitive/isPrimitive.test.js b/test4/isPrimitive/isPrimitive.test.js deleted file mode 100644 index 0ce6c26b0..000000000 --- a/test4/isPrimitive/isPrimitive.test.js +++ /dev/null @@ -1,23 +0,0 @@ -const expect = require('expect'); -const isPrimitive = require('./isPrimitive.js'); - -test('Testing isPrimitive', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isPrimitive === 'function').toBeTruthy(); - expect(isPrimitive(null)).toBeTruthy(); - expect(isPrimitive(undefined)).toBeTruthy(); - expect(isPrimitive('string')).toBeTruthy(); - expect(isPrimitive(true)).toBeTruthy(); - expect(isPrimitive(50)).toBeTruthy(); - expect(isPrimitive('Hello')).toBeTruthy(); - expect(isPrimitive(false)).toBeTruthy(); - expect(isPrimitive(Symbol())).toBeTruthy(); - expect(isPrimitive([1, 2, 3])).toBeFalsy(); - expect(isPrimitive({ a: 123 })).toBeFalsy(); - - let start = new Date().getTime(); - isPrimitive({ a: 123 }); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/isPromiseLike/isPromiseLike.test.js b/test4/isPromiseLike/isPromiseLike.test.js deleted file mode 100644 index a971c86f0..000000000 --- a/test4/isPromiseLike/isPromiseLike.test.js +++ /dev/null @@ -1,15 +0,0 @@ -const expect = require('expect'); -const isPromiseLike = require('./isPromiseLike.js'); - -test('Testing isPromiseLike', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isPromiseLike === 'function').toBeTruthy(); - expect(isPromiseLike({ - then: function() { - return ''; - } - })).toBe(true); - expect(isPromiseLike(null)).toBe(false); - expect(isPromiseLike({})).toBe(false); -}); diff --git a/test4/isRegExp/isRegExp.test.js b/test4/isRegExp/isRegExp.test.js deleted file mode 100644 index c72df0593..000000000 --- a/test4/isRegExp/isRegExp.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isRegExp = require('./isRegExp.js'); - -test('Testing isRegExp', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isRegExp === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/isSet/isSet.test.js b/test4/isSet/isSet.test.js deleted file mode 100644 index 0cc4d8995..000000000 --- a/test4/isSet/isSet.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isSet = require('./isSet.js'); - -test('Testing isSet', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isSet === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/isSimilar/isSimilar.test.js b/test4/isSimilar/isSimilar.test.js deleted file mode 100644 index 24d4e6abf..000000000 --- a/test4/isSimilar/isSimilar.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isSimilar = require('./isSimilar.js'); - -test('Testing isSimilar', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isSimilar === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/isSorted/isSorted.test.js b/test4/isSorted/isSorted.test.js deleted file mode 100644 index c9f3432d6..000000000 --- a/test4/isSorted/isSorted.test.js +++ /dev/null @@ -1,20 +0,0 @@ -const expect = require('expect'); -const isSorted = require('./isSorted.js'); - -test('Testing isSorted', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isSorted === 'function').toBeTruthy(); - //t.deepEqual(isSorted(args..), 'Expected'); - expect(isSorted([0, 1, 2])).toBe(1); - expect(isSorted([0, 1, 2, 2])).toBe(1); - expect(isSorted([-4, -3, -2])).toBe(1); - expect(isSorted([0, 0, 1, 2])).toBe(1); - expect(isSorted([2, 1, 0])).toBe(-1); - expect(isSorted([2, 2, 1, 0])).toBe(-1); - expect(isSorted([-2, -3, -4])).toBe(-1); - expect(isSorted([2, 1, 0, 0])).toBe(-1); - expect(isSorted([])).toBe(undefined); - expect(isSorted([1])).toBe(0); - expect(isSorted([1, 2, 1])).toBe(0); -}); diff --git a/test4/isString/isString.test.js b/test4/isString/isString.test.js deleted file mode 100644 index be8d629a2..000000000 --- a/test4/isString/isString.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const isString = require('./isString.js'); - -test('Testing isString', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isString === 'function').toBeTruthy(); - expect(isString('foo')).toBe(true); - expect(isString('10')).toBe(true); - expect(isString('')).toBe(true); - expect(isString(10)).toBe(false); - expect(isString(true)).toBe(false); -}); \ No newline at end of file diff --git a/test4/isSymbol/isSymbol.test.js b/test4/isSymbol/isSymbol.test.js deleted file mode 100644 index 6eebd3e54..000000000 --- a/test4/isSymbol/isSymbol.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const isSymbol = require('./isSymbol.js'); - -test('Testing isSymbol', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isSymbol === 'function').toBeTruthy(); - expect(isSymbol(Symbol('x'))).toBe(true); -}); \ No newline at end of file diff --git a/test4/isTravisCI/isTravisCI.test.js b/test4/isTravisCI/isTravisCI.test.js deleted file mode 100644 index 58a776d2d..000000000 --- a/test4/isTravisCI/isTravisCI.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const isTravisCI = require('./isTravisCI.js'); - -test('Testing isTravisCI', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isTravisCI === 'function').toBeTruthy(); - if(isTravisCI()) - expect(isTravisCI()).toBeTruthy(); - else - expect(isTravisCI()).toBeFalsy(); -}); diff --git a/test4/isTypedArray/isTypedArray.test.js b/test4/isTypedArray/isTypedArray.test.js deleted file mode 100644 index deec79621..000000000 --- a/test4/isTypedArray/isTypedArray.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isTypedArray = require('./isTypedArray.js'); - -test('Testing isTypedArray', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isTypedArray === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/isUndefined/isUndefined.test.js b/test4/isUndefined/isUndefined.test.js deleted file mode 100644 index d345a2f69..000000000 --- a/test4/isUndefined/isUndefined.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const isUndefined = require('./isUndefined.js'); - -test('Testing isUndefined', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isUndefined === 'function').toBeTruthy(); - expect(isUndefined(undefined)).toBeTruthy(); -}); diff --git a/test4/isUpperCase/isUpperCase.test.js b/test4/isUpperCase/isUpperCase.test.js deleted file mode 100644 index 660ad5547..000000000 --- a/test4/isUpperCase/isUpperCase.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const isUpperCase = require('./isUpperCase.js'); - -test('Testing isUpperCase', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isUpperCase === 'function').toBeTruthy(); - //t.deepEqual(isUpperCase(args..), 'Expected'); - expect(isUpperCase('ABC')).toBe(true); - expect(isUpperCase('abc')).toBe(false); - expect(isUpperCase('A3@$')).toBe(true); -}); \ No newline at end of file diff --git a/test4/isValidJSON/isValidJSON.test.js b/test4/isValidJSON/isValidJSON.test.js deleted file mode 100644 index 3d3d9a152..000000000 --- a/test4/isValidJSON/isValidJSON.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const isValidJSON = require('./isValidJSON.js'); - -test('Testing isValidJSON', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isValidJSON === 'function').toBeTruthy(); - expect(isValidJSON('{"name":"Adam","age":20}')).toBe(true); - expect(isValidJSON('{"name":"Adam",age:"20"}')).toBe(false); - expect(isValidJSON(null)).toBe(true); -}); \ No newline at end of file diff --git a/test4/isWeakMap/isWeakMap.test.js b/test4/isWeakMap/isWeakMap.test.js deleted file mode 100644 index e79e1410a..000000000 --- a/test4/isWeakMap/isWeakMap.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isWeakMap = require('./isWeakMap.js'); - -test('Testing isWeakMap', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isWeakMap === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/isWeakSet/isWeakSet.test.js b/test4/isWeakSet/isWeakSet.test.js deleted file mode 100644 index 7da0fec69..000000000 --- a/test4/isWeakSet/isWeakSet.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const isWeakSet = require('./isWeakSet.js'); - -test('Testing isWeakSet', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof isWeakSet === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/join/join.test.js b/test4/join/join.test.js deleted file mode 100644 index 6e173d9fa..000000000 --- a/test4/join/join.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const join = require('./join.js'); - -test('Testing join', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof join === 'function').toBeTruthy(); - expect(join(['pen', 'pineapple', 'apple', 'pen'], ',', '&')).toEqual("pen,pineapple,apple&pen"); - expect(join(['pen', 'pineapple', 'apple', 'pen'], ',')).toEqual("pen,pineapple,apple,pen"); - expect(join(['pen', 'pineapple', 'apple', 'pen'])).toEqual("pen,pineapple,apple,pen"); -}); \ No newline at end of file diff --git a/test4/last/last.test.js b/test4/last/last.test.js deleted file mode 100644 index df9817754..000000000 --- a/test4/last/last.test.js +++ /dev/null @@ -1,20 +0,0 @@ -const expect = require('expect'); -const last = require('./last.js'); - -test('Testing last', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof last === 'function').toBeTruthy(); - expect(last({ a: 1234}) === undefined).toBeTruthy(); - expect(last([1, 2, 3])).toBe(3); - expect(last({ 0: false})).toBe(undefined); - expect(last('String')).toBe('g'); - expect(() => last(null)).toThrow(); - expect(() => last(undefined)).toThrow(); - expect(() => last()).toThrow(); - - let start = new Date().getTime(); - last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/lcm/lcm.test.js b/test4/lcm/lcm.test.js deleted file mode 100644 index 76e1cf03d..000000000 --- a/test4/lcm/lcm.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const lcm = require('./lcm.js'); - -test('Testing lcm', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof lcm === 'function').toBeTruthy(); - expect(lcm(12, 7)).toBe(84); - expect(lcm(...[1, 3, 4, 5])).toBe(60); -}); \ No newline at end of file diff --git a/test4/levenshteinDistance/levenshteinDistance.test.js b/test4/levenshteinDistance/levenshteinDistance.test.js deleted file mode 100644 index 01afeb869..000000000 --- a/test4/levenshteinDistance/levenshteinDistance.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const levenshteinDistance = require('./levenshteinDistance.js'); - -test('Testing levenshteinDistance', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof levenshteinDistance === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/longestItem/longestItem.test.js b/test4/longestItem/longestItem.test.js deleted file mode 100644 index d4961f009..000000000 --- a/test4/longestItem/longestItem.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const longestItem = require('./longestItem.js'); - -test('Testing longestItem', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof longestItem === 'function').toBeTruthy(); - expect(longestItem('this', 'is', 'a', 'testcase')).toEqual('testcase'); -}); \ No newline at end of file diff --git a/test4/lowercaseKeys/lowercaseKeys.test.js b/test4/lowercaseKeys/lowercaseKeys.test.js deleted file mode 100644 index 537b699a7..000000000 --- a/test4/lowercaseKeys/lowercaseKeys.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const lowercaseKeys = require('./lowercaseKeys.js'); - -test('Testing lowercaseKeys', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof lowercaseKeys === 'function').toBeTruthy(); - const myObj = { Name: 'Adam', sUrnAME: 'Smith' }; - const myObjLower = lowercaseKeys(myObj); - expect(myObjLower).toEqual({name: 'Adam', surname: 'Smith'}); - expect(myObj).toEqual({ Name: 'Adam', sUrnAME: 'Smith' }); -}); diff --git a/test4/luhnCheck/luhnCheck.test.js b/test4/luhnCheck/luhnCheck.test.js deleted file mode 100644 index dec48f653..000000000 --- a/test4/luhnCheck/luhnCheck.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const luhnCheck = require('./luhnCheck.js'); - -test('Testing luhnCheck', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof luhnCheck === 'function').toBeTruthy(); - expect(luhnCheck(6011329933655299)).toBe(false); - expect(luhnCheck('4485275742308327')).toBe(true); - expect(luhnCheck(123456789)).toBe(false); -}); \ No newline at end of file diff --git a/test4/mapKeys/mapKeys.test.js b/test4/mapKeys/mapKeys.test.js deleted file mode 100644 index 0aa00bf36..000000000 --- a/test4/mapKeys/mapKeys.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const mapKeys = require('./mapKeys.js'); - -test('Testing mapKeys', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof mapKeys === 'function').toBeTruthy(); - expect(mapKeys({ a: 1, b: 2 }, (val, key) => key + val)).toEqual({ a1: 1, b2: 2 }); -}); diff --git a/test4/mapObject/mapObject.test.js b/test4/mapObject/mapObject.test.js deleted file mode 100644 index 80c2295a8..000000000 --- a/test4/mapObject/mapObject.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const mapObject = require('./mapObject.js'); - -test('Testing mapObject', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof mapObject === 'function').toBeTruthy(); - expect(mapObject([1, 2, 3], a => a * a)).toEqual({ 1: 1, 2: 4, 3: 9 }); - expect(mapObject([1, 2, 3, 4], (a, b) => b - a)).toEqual({ 1: -1, 2: -1, 3: -1, 4: -1 }); - expect(mapObject([1, 2, 3, 4], (a, b) => a - b)).toEqual({ 1: 1, 2: 1, 3: 1, 4: 1 }); -}); diff --git a/test4/mapValues/mapValues.test.js b/test4/mapValues/mapValues.test.js deleted file mode 100644 index 862909d71..000000000 --- a/test4/mapValues/mapValues.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const mapValues = require('./mapValues.js'); - -test('Testing mapValues', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof mapValues === 'function').toBeTruthy(); - const users = { - fred: { user: 'fred', age: 40 }, - pebbles: { user: 'pebbles', age: 1 } - }; - expect(mapValues(users, u => u.age)).toEqual({ fred: 40, pebbles: 1 }); -}); diff --git a/test4/mask/mask.test.js b/test4/mask/mask.test.js deleted file mode 100644 index a313029c0..000000000 --- a/test4/mask/mask.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const mask = require('./mask.js'); - -test('Testing mask', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof mask === 'function').toBeTruthy(); - expect(mask(1234567890)).toBe('******7890'); - expect(mask(1234567890, 3)).toBe('*******890'); - expect(mask(1234567890, -4, '$')).toBe('$$$$567890'); -}); \ No newline at end of file diff --git a/test4/matches/matches.test.js b/test4/matches/matches.test.js deleted file mode 100644 index b8c61f7fb..000000000 --- a/test4/matches/matches.test.js +++ /dev/null @@ -1,14 +0,0 @@ -const expect = require('expect'); -const matches = require('./matches.js'); - -test('Testing matches', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof matches === 'function').toBeTruthy(); - expect( - matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true }) - ).toBeTruthy(); - expect( - matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }) - ).toBeFalsy(); -}); diff --git a/test4/matchesWith/matchesWith.test.js b/test4/matchesWith/matchesWith.test.js deleted file mode 100644 index aef31c802..000000000 --- a/test4/matchesWith/matchesWith.test.js +++ /dev/null @@ -1,14 +0,0 @@ -const expect = require('expect'); -const matchesWith = require('./matchesWith.js'); - -test('Testing matchesWith', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof matchesWith === 'function').toBeTruthy(); - const isGreeting = val => /^h(?:i|ello)$/.test(val); - expect(matchesWith( - { greeting: 'hello' }, - { greeting: 'hi' }, - (oV, sV) => isGreeting(oV) && isGreeting(sV) - )).toBeTruthy(); -}); diff --git a/test4/maxBy/maxBy.test.js b/test4/maxBy/maxBy.test.js deleted file mode 100644 index 041e16d5f..000000000 --- a/test4/maxBy/maxBy.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const maxBy = require('./maxBy.js'); - -test('Testing maxBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof maxBy === 'function').toBeTruthy(); - expect(maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n)).toBe(8); - expect(maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n')).toBe(8); -}); diff --git a/test4/maxN/maxN.test.js b/test4/maxN/maxN.test.js deleted file mode 100644 index e714acd04..000000000 --- a/test4/maxN/maxN.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const maxN = require('./maxN.js'); - -test('Testing maxN', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof maxN === 'function').toBeTruthy(); - expect(maxN([1, 2, 3])).toEqual([3]); - expect(maxN([1, 2, 3], 2)).toEqual([3, 2]); -}); \ No newline at end of file diff --git a/test4/median/median.test.js b/test4/median/median.test.js deleted file mode 100644 index d7e14899e..000000000 --- a/test4/median/median.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const median = require('./median.js'); - -test('Testing median', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof median === 'function').toBeTruthy(); - expect(median([5, 6, 50, 1, -5])).toBe(5); - expect(median([1, 2, 3])).toBe(2); -}); \ No newline at end of file diff --git a/test4/memoize/memoize.test.js b/test4/memoize/memoize.test.js deleted file mode 100644 index 29ef30ccb..000000000 --- a/test4/memoize/memoize.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const memoize = require('./memoize.js'); - -test('Testing memoize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof memoize === 'function').toBeTruthy(); - const f = x => x * x; - const square = memoize(f); - expect(square(2)).toBe(4); - expect(square(3)).toBe(9); - expect(Array.from(square.cache)).toEqual([[2,4],[3,9]]); -}); diff --git a/test4/merge/merge.test.js b/test4/merge/merge.test.js deleted file mode 100644 index c3369f320..000000000 --- a/test4/merge/merge.test.js +++ /dev/null @@ -1,18 +0,0 @@ -const expect = require('expect'); -const merge = require('./merge.js'); - -test('Testing merge', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof merge === 'function').toBeTruthy(); - const object = { - a: [{ x: 2 }, { y: 4 }], - b: 1 - }; - const other = { - a: { z: 3 }, - b: [2, 3], - c: 'foo' - }; - expect(merge(object, other)).toEqual({ a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ], c: 'foo' }); -}); diff --git a/test4/minBy/minBy.test.js b/test4/minBy/minBy.test.js deleted file mode 100644 index 58efee38f..000000000 --- a/test4/minBy/minBy.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const minBy = require('./minBy.js'); - -test('Testing minBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof minBy === 'function').toBeTruthy(); - expect(minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n)).toBe(2); - expect(minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n')).toBe(2); -}); diff --git a/test4/minN/minN.test.js b/test4/minN/minN.test.js deleted file mode 100644 index c10fd200f..000000000 --- a/test4/minN/minN.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const minN = require('./minN.js'); - -test('Testing minN', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof minN === 'function').toBeTruthy(); - expect(minN([1, 2, 3])).toEqual([1]); - expect(minN([1, 2, 3], 2)).toEqual([1, 2]); -}); \ No newline at end of file diff --git a/test4/mostPerformant/mostPerformant.test.js b/test4/mostPerformant/mostPerformant.test.js deleted file mode 100644 index b83d3ff0f..000000000 --- a/test4/mostPerformant/mostPerformant.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const mostPerformant = require('./mostPerformant.js'); - -test('Testing mostPerformant', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof mostPerformant === 'function').toBeTruthy(); -}); diff --git a/test4/negate/negate.test.js b/test4/negate/negate.test.js deleted file mode 100644 index 3a3799bb8..000000000 --- a/test4/negate/negate.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const negate = require('./negate.js'); - -test('Testing negate', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof negate === 'function').toBeTruthy(); - expect([1, 2, 3, 4, 5, 6].filter(negate(n => n % 2 === 0))).toEqual([1, 3, 5]); -}); diff --git a/test4/nest/nest.test.js b/test4/nest/nest.test.js deleted file mode 100644 index 2866537ad..000000000 --- a/test4/nest/nest.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const nest = require('./nest.js'); - -test('Testing nest', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof nest === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/nodeListToArray/nodeListToArray.test.js b/test4/nodeListToArray/nodeListToArray.test.js deleted file mode 100644 index cc16b355d..000000000 --- a/test4/nodeListToArray/nodeListToArray.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const nodeListToArray = require('./nodeListToArray.js'); - -test('Testing nodeListToArray', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof nodeListToArray === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test4/none/none.test.js b/test4/none/none.test.js deleted file mode 100644 index fdf7c6bbc..000000000 --- a/test4/none/none.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const none = require('./none.js'); - -test('Testing none', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof none === 'function').toBeTruthy(); - expect(none([0,undefined,NaN,null,''])).toBeTruthy(); - expect(none([0,1])).toBeFalsy(); - expect(none([4,1,0,3], x => x < 0)).toBeTruthy(); - expect(none([0,1,2], x => x === 1)).toBeFalsy(); -}); diff --git a/test4/nthArg/nthArg.test.js b/test4/nthArg/nthArg.test.js deleted file mode 100644 index b63828fe4..000000000 --- a/test4/nthArg/nthArg.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const nthArg = require('./nthArg.js'); - -test('Testing nthArg', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof nthArg === 'function').toBeTruthy(); - const third = nthArg(2); - expect(third(1, 2, 3)).toBe(3); - expect(third(1, 2)).toBe(undefined); - const last = nthArg(-1); - expect(last(1, 2, 3, 4, 5)).toBe(5); -}); diff --git a/test4/nthElement/nthElement.test.js b/test4/nthElement/nthElement.test.js deleted file mode 100644 index 3ba010c0d..000000000 --- a/test4/nthElement/nthElement.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const nthElement = require('./nthElement.js'); - -test('Testing nthElement', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof nthElement === 'function').toBeTruthy(); - expect(nthElement(['a', 'b', 'c'], 1)).toBe('b'); - expect(nthElement(['a', 'b', 'c'], -3)).toBe('a'); -}); \ No newline at end of file diff --git a/test4/objectFromPairs/objectFromPairs.test.js b/test4/objectFromPairs/objectFromPairs.test.js deleted file mode 100644 index 7497fee6a..000000000 --- a/test4/objectFromPairs/objectFromPairs.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const objectFromPairs = require('./objectFromPairs.js'); - -test('Testing objectFromPairs', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof objectFromPairs === 'function').toBeTruthy(); - expect(objectFromPairs([['a', 1], ['b', 2]])).toEqual({a: 1, b: 2}); -}); \ No newline at end of file diff --git a/test4/objectToPairs/objectToPairs.test.js b/test4/objectToPairs/objectToPairs.test.js deleted file mode 100644 index c274408bd..000000000 --- a/test4/objectToPairs/objectToPairs.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const objectToPairs = require('./objectToPairs.js'); - -test('Testing objectToPairs', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof objectToPairs === 'function').toBeTruthy(); - expect(objectToPairs({ a: 1, b: 2 })).toEqual([['a',1],['b',2]]); -}); \ No newline at end of file diff --git a/test4/observeMutations/observeMutations.test.js b/test4/observeMutations/observeMutations.test.js deleted file mode 100644 index 4cf9349e0..000000000 --- a/test4/observeMutations/observeMutations.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const observeMutations = require('./observeMutations.js'); - -test('Testing observeMutations', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof observeMutations === 'function').toBeTruthy(); -}); diff --git a/test4/off/off.test.js b/test4/off/off.test.js deleted file mode 100644 index 90702b03a..000000000 --- a/test4/off/off.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const off = require('./off.js'); - -test('Testing off', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof off === 'function').toBeTruthy(); -}); diff --git a/test4/offset/offset.test.js b/test4/offset/offset.test.js deleted file mode 100644 index 8cf281e0c..000000000 --- a/test4/offset/offset.test.js +++ /dev/null @@ -1,14 +0,0 @@ -const expect = require('expect'); -const offset = require('./offset.js'); - -test('Testing offset', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof offset === 'function').toBeTruthy(); - expect(offset([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]); - expect(offset([1, 2, 3, 4, 5], 2)).toEqual([3, 4, 5, 1, 2]); - expect(offset([1, 2, 3, 4, 5], -2)).toEqual([4, 5, 1, 2, 3]); - expect(offset([1, 2, 3, 4, 5], 6)).toEqual([1, 2, 3, 4, 5]); - expect(offset([1, 2, 3, 4, 5], -6)).toEqual([1, 2, 3, 4, 5]); - expect(offset([], 3)).toEqual([]); -}); diff --git a/test4/omit/omit.test.js b/test4/omit/omit.test.js deleted file mode 100644 index bcb2365ee..000000000 --- a/test4/omit/omit.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const omit = require('./omit.js'); - -test('Testing omit', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof omit === 'function').toBeTruthy(); - expect(omit({ a: 1, b: '2', c: 3 }, ['b'])).toEqual({ 'a': 1, 'c': 3 }); -}); diff --git a/test5/RGBToHex/RGBToHex.test.js b/test5/RGBToHex/RGBToHex.test.js deleted file mode 100644 index d0fc0f92e..000000000 --- a/test5/RGBToHex/RGBToHex.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const RGBToHex = require('./RGBToHex.js'); - -test('Testing RGBToHex', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof RGBToHex === 'function').toBeTruthy(); - expect(RGBToHex(255, 165, 1)).toBe('ffa501'); -}); \ No newline at end of file diff --git a/test5/omitBy/omitBy.test.js b/test5/omitBy/omitBy.test.js deleted file mode 100644 index dce45eea2..000000000 --- a/test5/omitBy/omitBy.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const omitBy = require('./omitBy.js'); - -test('Testing omitBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof omitBy === 'function').toBeTruthy(); - expect(omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number')).toEqual({ b: '2' }); -}); diff --git a/test5/on/on.test.js b/test5/on/on.test.js deleted file mode 100644 index 7fbf62c6c..000000000 --- a/test5/on/on.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const on = require('./on.js'); - -test('Testing on', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof on === 'function').toBeTruthy(); -}); diff --git a/test5/onUserInputChange/onUserInputChange.test.js b/test5/onUserInputChange/onUserInputChange.test.js deleted file mode 100644 index 2224a0f2d..000000000 --- a/test5/onUserInputChange/onUserInputChange.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const onUserInputChange = require('./onUserInputChange.js'); - -test('Testing onUserInputChange', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof onUserInputChange === 'function').toBeTruthy(); -}); diff --git a/test5/once/once.test.js b/test5/once/once.test.js deleted file mode 100644 index 0df7c89b2..000000000 --- a/test5/once/once.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const once = require('./once.js'); - -test('Testing once', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof once === 'function').toBeTruthy(); -}); diff --git a/test5/orderBy/orderBy.test.js b/test5/orderBy/orderBy.test.js deleted file mode 100644 index b2f2079a7..000000000 --- a/test5/orderBy/orderBy.test.js +++ /dev/null @@ -1,15 +0,0 @@ -const expect = require('expect'); -const orderBy = require('./orderBy.js'); - -test('Testing orderBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof orderBy === 'function').toBeTruthy(); - const users = [{ name: 'fred', age: 48 }, { name: 'barney', age: 36 }, { name: 'fred', age: 40 }]; - expect(orderBy(users, ['name', 'age'], ['asc', 'desc'])).toEqual( - [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}] - ); - expect(orderBy(users, ['name', 'age'])).toEqual( - [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}] - ); -}); \ No newline at end of file diff --git a/test5/over/over.test.js b/test5/over/over.test.js deleted file mode 100644 index 0ecda5749..000000000 --- a/test5/over/over.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const over = require('./over.js'); - -test('Testing over', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof over === 'function').toBeTruthy(); - const minMax = over(Math.min, Math.max); - expect(minMax(1, 2, 3, 4, 5)).toEqual([1,5]); -}); diff --git a/test5/overArgs/overArgs.test.js b/test5/overArgs/overArgs.test.js deleted file mode 100644 index 78c9edfd3..000000000 --- a/test5/overArgs/overArgs.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const overArgs = require('./overArgs.js'); - -test('Testing overArgs', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof overArgs === 'function').toBeTruthy(); - const square = n => n * n; - const double = n => n * 2; - const fn = overArgs((x, y) => [x, y], [square, double]); - expect(fn(9, 3)).toEqual([81, 6]); -}); diff --git a/test5/pad/pad.test.js b/test5/pad/pad.test.js deleted file mode 100644 index a2a036ec5..000000000 --- a/test5/pad/pad.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const pad = require('./pad.js'); - -test('Testing pad', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pad === 'function').toBeTruthy(); - expect(pad('cat',8)).toBe(' cat '); - expect(pad('cat',8).length).toBe(8); - expect(pad(String(42), 6, '0')).toBe('004200'); - expect(pad('foobar', 3)).toBe('foobar'); -}); diff --git a/test5/palindrome/palindrome.test.js b/test5/palindrome/palindrome.test.js deleted file mode 100644 index 44d983dc9..000000000 --- a/test5/palindrome/palindrome.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const palindrome = require('./palindrome.js'); - -test('Testing palindrome', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof palindrome === 'function').toBeTruthy(); - expect(palindrome('taco cat')).toBe(true); - expect(palindrome('foobar')).toBe(false); -}); \ No newline at end of file diff --git a/test5/parseCookie/parseCookie.test.js b/test5/parseCookie/parseCookie.test.js deleted file mode 100644 index 84e046a69..000000000 --- a/test5/parseCookie/parseCookie.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const parseCookie = require('./parseCookie.js'); - -test('Testing parseCookie', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof parseCookie === 'function').toBeTruthy(); - expect(parseCookie('foo=bar; equation=E%3Dmc%5E2')).toEqual({ foo: 'bar', equation: 'E=mc^2' }); -}); diff --git a/test5/partial/partial.test.js b/test5/partial/partial.test.js deleted file mode 100644 index 813eef79a..000000000 --- a/test5/partial/partial.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const partial = require('./partial.js'); - -test('Testing partial', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof partial === 'function').toBeTruthy(); - function greet(greeting, name) { - return greeting + ' ' + name + '!'; - } - const greetHello = partial(greet, 'Hello'); - expect(greetHello('John')).toBe('Hello John!'); -}); diff --git a/test5/partialRight/partialRight.test.js b/test5/partialRight/partialRight.test.js deleted file mode 100644 index 480ce7ec6..000000000 --- a/test5/partialRight/partialRight.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const partialRight = require('./partialRight.js'); - -test('Testing partialRight', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof partialRight === 'function').toBeTruthy(); - function greet(greeting, name) { - return greeting + ' ' + name + '!'; - } - const greetJohn = partialRight(greet, 'John'); - expect(greetJohn('Hello')).toBe('Hello John!'); -}); diff --git a/test5/partition/partition.test.js b/test5/partition/partition.test.js deleted file mode 100644 index 968876650..000000000 --- a/test5/partition/partition.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const partition = require('./partition.js'); - -test('Testing partition', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof partition === 'function').toBeTruthy(); - const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }]; - expect(partition(users, o => o.active)).toEqual( - [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]] - ); -}); \ No newline at end of file diff --git a/test5/percentile/percentile.test.js b/test5/percentile/percentile.test.js deleted file mode 100644 index af64d3032..000000000 --- a/test5/percentile/percentile.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const percentile = require('./percentile.js'); - -test('Testing percentile', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof percentile === 'function').toBeTruthy(); - expect(percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6)).toBe(55); -}); \ No newline at end of file diff --git a/test5/permutations/permutations.test.js b/test5/permutations/permutations.test.js deleted file mode 100644 index 9aa5fa4fb..000000000 --- a/test5/permutations/permutations.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const permutations = require('./permutations.js'); - -test('Testing permutations', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof permutations === 'function').toBeTruthy(); - expect(permutations([1, 33, 5])).toEqual( - [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ] - ); -}); diff --git a/test5/pick/pick.test.js b/test5/pick/pick.test.js deleted file mode 100644 index 20f11cb4d..000000000 --- a/test5/pick/pick.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const pick = require('./pick.js'); - -test('Testing pick', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pick === 'function').toBeTruthy(); - expect(pick({ a: 1, b: '2', c: 3 }, ['a', 'c'])).toEqual({ 'a': 1, 'c': 3 }); -}); \ No newline at end of file diff --git a/test5/pickBy/pickBy.test.js b/test5/pickBy/pickBy.test.js deleted file mode 100644 index 8c5620d33..000000000 --- a/test5/pickBy/pickBy.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const pickBy = require('./pickBy.js'); - -test('Testing pickBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pickBy === 'function').toBeTruthy(); - expect(pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number')).toEqual({ 'a': 1, 'c': 3 }); -}); diff --git a/test5/pipeAsyncFunctions/pipeAsyncFunctions.test.js b/test5/pipeAsyncFunctions/pipeAsyncFunctions.test.js deleted file mode 100644 index 5724dec11..000000000 --- a/test5/pipeAsyncFunctions/pipeAsyncFunctions.test.js +++ /dev/null @@ -1,19 +0,0 @@ -const expect = require('expect'); -const pipeAsyncFunctions = require('./pipeAsyncFunctions.js'); - -test('Testing pipeAsyncFunctions', async () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pipeAsyncFunctions === 'function').toBeTruthy(); - //t.deepEqual(pipeAsyncFunctions(args..), 'Expected'); - //t.equal(pipeAsyncFunctions(args..), 'Expected'); - //t.false(pipeAsyncFunctions(args..), 'Expected'); - //t.throws(pipeAsyncFunctions(args..), 'Expected'); - expect(await pipeAsyncFunctions( - (x) => x + 1, - (x) => new Promise((resolve) => setTimeout(() => resolve(x + 2), 0)), - (x) => x + 3, - async (x) => await x + 4, - ) - (5)).toBe(15); -}); \ No newline at end of file diff --git a/test5/pipeFunctions/pipeFunctions.test.js b/test5/pipeFunctions/pipeFunctions.test.js deleted file mode 100644 index b334a71ae..000000000 --- a/test5/pipeFunctions/pipeFunctions.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const pipeFunctions = require('./pipeFunctions.js'); - -test('Testing pipeFunctions', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pipeFunctions === 'function').toBeTruthy(); - const add5 = x => x + 5; - const multiply = (x, y) => x * y; - const multiplyAndAdd5 = pipeFunctions(multiply, add5); - expect(multiplyAndAdd5(5, 2)).toBe(15); -}); diff --git a/test5/pluralize/pluralize.test.js b/test5/pluralize/pluralize.test.js deleted file mode 100644 index 4fafc2f10..000000000 --- a/test5/pluralize/pluralize.test.js +++ /dev/null @@ -1,18 +0,0 @@ -const expect = require('expect'); -const pluralize = require('./pluralize.js'); - -test('Testing pluralize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pluralize === 'function').toBeTruthy(); - expect(pluralize(0, 'apple')).toBe('apples'); - expect(pluralize(1, 'apple')).toBe('apple'); - expect(pluralize(2, 'apple')).toBe('apples'); - expect(pluralize(2, 'person', 'people')).toBe('people'); - const PLURALS = { - person: 'people', - radius: 'radii' - }; - const autoPluralize = pluralize(PLURALS); - expect(autoPluralize(2, 'person')).toBe('people'); -}); diff --git a/test5/powerset/powerset.test.js b/test5/powerset/powerset.test.js deleted file mode 100644 index 7413dedb8..000000000 --- a/test5/powerset/powerset.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const powerset = require('./powerset.js'); - -test('Testing powerset', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof powerset === 'function').toBeTruthy(); - expect(powerset([1, 2])).toEqual([[], [1], [2], [2,1]]); -}); \ No newline at end of file diff --git a/test5/prefix/prefix.test.js b/test5/prefix/prefix.test.js deleted file mode 100644 index c4f88eca6..000000000 --- a/test5/prefix/prefix.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const prefix = require('./prefix.js'); - -test('Testing prefix', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof prefix === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test5/prettyBytes/prettyBytes.test.js b/test5/prettyBytes/prettyBytes.test.js deleted file mode 100644 index a2cccd3a6..000000000 --- a/test5/prettyBytes/prettyBytes.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const prettyBytes = require('./prettyBytes.js'); - -test('Testing prettyBytes', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof prettyBytes === 'function').toBeTruthy(); - expect(prettyBytes(1000)).toBe('1 KB'); - expect(prettyBytes(-27145424323.5821, 5)).toBe('-27.145 GB'); - expect(prettyBytes(123456789, 3, false)).toBe('123MB'); -}); \ No newline at end of file diff --git a/test5/primes/primes.test.js b/test5/primes/primes.test.js deleted file mode 100644 index d0b4ae15c..000000000 --- a/test5/primes/primes.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const primes = require('./primes.js'); - -test('Testing primes', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof primes === 'function').toBeTruthy(); - expect(primes(10)).toEqual([2, 3, 5, 7]); -}); \ No newline at end of file diff --git a/test5/promisify/promisify.test.js b/test5/promisify/promisify.test.js deleted file mode 100644 index 145a8c004..000000000 --- a/test5/promisify/promisify.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const promisify = require('./promisify.js'); - -test('Testing promisify', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof promisify === 'function').toBeTruthy(); - const x = promisify(Math.max); - expect(x() instanceof Promise).toBeTruthy(); - const delay = promisify((d, cb) => setTimeout(cb, d)); - delay(200).then(() => ); -}); diff --git a/test5/pull/pull.test.js b/test5/pull/pull.test.js deleted file mode 100644 index f38d1c0bf..000000000 --- a/test5/pull/pull.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const pull = require('./pull.js'); - -test('Testing pull', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pull === 'function').toBeTruthy(); - let myArray = ['a', 'b', 'c', 'a', 'b', 'c']; - pull(myArray, 'a', 'c'); - expect(myArray).toEqual(['b','b']); -}); diff --git a/test5/pullAtIndex/pullAtIndex.test.js b/test5/pullAtIndex/pullAtIndex.test.js deleted file mode 100644 index 9715d6c95..000000000 --- a/test5/pullAtIndex/pullAtIndex.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const pullAtIndex = require('./pullAtIndex.js'); - -test('Testing pullAtIndex', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pullAtIndex === 'function').toBeTruthy(); - let myArray = ['a', 'b', 'c', 'd']; - let pulled = pullAtIndex(myArray, [1, 3]); - expect(myArray).toEqual([ 'a', 'c' ]); - expect(pulled).toEqual([ 'b', 'd' ]); -}); diff --git a/test5/pullAtValue/pullAtValue.test.js b/test5/pullAtValue/pullAtValue.test.js deleted file mode 100644 index b15a3baa4..000000000 --- a/test5/pullAtValue/pullAtValue.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const pullAtValue = require('./pullAtValue.js'); - -test('Testing pullAtValue', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pullAtValue === 'function').toBeTruthy(); - let myArray = ['a', 'b', 'c', 'd']; - let pulled = pullAtValue(myArray, ['b', 'd']); - expect(myArray).toEqual([ 'a', 'c' ]); - expect(pulled).toEqual([ 'b', 'd' ]); -}); diff --git a/test5/pullBy/pullBy.test.js b/test5/pullBy/pullBy.test.js deleted file mode 100644 index 5b6f656d5..000000000 --- a/test5/pullBy/pullBy.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const pullBy = require('./pullBy.js'); - -test('Testing pullBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof pullBy === 'function').toBeTruthy(); - var myArray = [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }]; - pullBy(myArray, [{ x: 1 }, { x: 3 }], o => o.x); - expect(myArray).toEqual([{ x: 2 }]); -}); diff --git a/test5/quickSort/quickSort.test.js b/test5/quickSort/quickSort.test.js deleted file mode 100644 index 019749405..000000000 --- a/test5/quickSort/quickSort.test.js +++ /dev/null @@ -1,20 +0,0 @@ -const expect = require('expect'); -const quickSort = require('./quickSort.js'); - -test('Testing quickSort', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof quickSort === 'function').toBeTruthy(); - expect(quickSort([5, 6, 4, 3, 1, 2])).toEqual([1, 2, 3, 4, 5, 6]); - expect(quickSort([-1, 0, -2])).toEqual([-2, -1, 0]); - expect(() => quickSort()).toThrow(); - expect(() => quickSort(123)).toThrow(); - expect(() => quickSort({ 234: string})).toThrow(); - expect(() => quickSort(null)).toThrow(); - expect(() => quickSort(undefined)).toThrow(); - - let start = new Date().getTime(); - quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); diff --git a/test5/radsToDegrees/radsToDegrees.test.js b/test5/radsToDegrees/radsToDegrees.test.js deleted file mode 100644 index 4b492e176..000000000 --- a/test5/radsToDegrees/radsToDegrees.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const radsToDegrees = require('./radsToDegrees.js'); - -test('Testing radsToDegrees', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof radsToDegrees === 'function').toBeTruthy(); - expect(radsToDegrees(Math.PI / 2)).toBe(90); -}); diff --git a/test5/randomHexColorCode/randomHexColorCode.test.js b/test5/randomHexColorCode/randomHexColorCode.test.js deleted file mode 100644 index c2d92bf7c..000000000 --- a/test5/randomHexColorCode/randomHexColorCode.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const randomHexColorCode = require('./randomHexColorCode.js'); - -test('Testing randomHexColorCode', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof randomHexColorCode === 'function').toBeTruthy(); - //t.deepEqual(randomHexColorCode(args..), 'Expected'); - expect(randomHexColorCode().length).toBe(7); - expect(randomHexColorCode().startsWith('#')).toBeTruthy(); - expect(randomHexColorCode().slice(1).match(/[^0123456789abcdef]/i) === null).toBeTruthy(); -}); diff --git a/test5/readFileLines/readFileLines.test.js b/test5/readFileLines/readFileLines.test.js deleted file mode 100644 index 36813c5b5..000000000 --- a/test5/readFileLines/readFileLines.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const readFileLines = require('./readFileLines.js'); - -test('Testing readFileLines', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof readFileLines === 'function').toBeTruthy(); -}); diff --git a/test5/rearg/rearg.test.js b/test5/rearg/rearg.test.js deleted file mode 100644 index ce426c97c..000000000 --- a/test5/rearg/rearg.test.js +++ /dev/null @@ -1,15 +0,0 @@ -const expect = require('expect'); -const rearg = require('./rearg.js'); - -test('Testing rearg', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof rearg === 'function').toBeTruthy(); - var rearged = rearg( - function(a, b, c) { - return [a, b, c]; - }, - [2, 0, 1] - ); - expect(rearged('b', 'c', 'a')).toEqual(['a', 'b', 'c']); -}); diff --git a/test5/recordAnimationFrames/recordAnimationFrames.test.js b/test5/recordAnimationFrames/recordAnimationFrames.test.js deleted file mode 100644 index 9c71212e5..000000000 --- a/test5/recordAnimationFrames/recordAnimationFrames.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const recordAnimationFrames = require('./recordAnimationFrames.js'); - -test('Testing recordAnimationFrames', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof recordAnimationFrames === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test5/redirect/redirect.test.js b/test5/redirect/redirect.test.js deleted file mode 100644 index d468f09ec..000000000 --- a/test5/redirect/redirect.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const redirect = require('./redirect.js'); - -test('Testing redirect', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof redirect === 'function').toBeTruthy(); -}); diff --git a/test5/reduceSuccessive/reduceSuccessive.test.js b/test5/reduceSuccessive/reduceSuccessive.test.js deleted file mode 100644 index 4bb7fada1..000000000 --- a/test5/reduceSuccessive/reduceSuccessive.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const reduceSuccessive = require('./reduceSuccessive.js'); - -test('Testing reduceSuccessive', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof reduceSuccessive === 'function').toBeTruthy(); - expect(reduceSuccessive([1, 2, 3, 4, 5, 6], (acc, val) => acc + val, 0)).toEqual([0, 1, 3, 6, 10, 15, 21]); -}); diff --git a/test5/reduceWhich/reduceWhich.test.js b/test5/reduceWhich/reduceWhich.test.js deleted file mode 100644 index 46b14797e..000000000 --- a/test5/reduceWhich/reduceWhich.test.js +++ /dev/null @@ -1,14 +0,0 @@ -const expect = require('expect'); -const reduceWhich = require('./reduceWhich.js'); - -test('Testing reduceWhich', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof reduceWhich === 'function').toBeTruthy(); - expect(reduceWhich([1, 3, 2])).toBe(1); - expect(reduceWhich([1, 3, 2], (a, b) => b - a)).toBe(3); - expect(reduceWhich( - [{ name: 'Tom', age: 12 }, { name: 'Jack', age: 18 }, { name: 'Lucy', age: 9 }], - (a, b) => a.age - b.age -)).toEqual({name: "Lucy", age: 9}); -}); diff --git a/test5/reducedFilter/reducedFilter.test.js b/test5/reducedFilter/reducedFilter.test.js deleted file mode 100644 index a9f87d3e6..000000000 --- a/test5/reducedFilter/reducedFilter.test.js +++ /dev/null @@ -1,21 +0,0 @@ -const expect = require('expect'); -const reducedFilter = require('./reducedFilter.js'); - -test('Testing reducedFilter', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof reducedFilter === 'function').toBeTruthy(); - const data = [ - { - id: 1, - name: 'john', - age: 24 - }, - { - id: 2, - name: 'mike', - age: 50 - } - ]; - expect(reducedFilter(data, ['id', 'name'], item => item.age > 24)).toEqual([{ id: 2, name: 'mike'}]); -}); \ No newline at end of file diff --git a/test5/reject/reject.test.js b/test5/reject/reject.test.js deleted file mode 100644 index 525aaeab4..000000000 --- a/test5/reject/reject.test.js +++ /dev/null @@ -1,22 +0,0 @@ -const expect = require('expect'); -const reject = require('./reject.js'); - -test('Testing reject', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof reject === 'function').toBeTruthy(); - - const noEvens = reject( - (x) => x % 2 === 0, - [1, 2, 3, 4, 5] - ); - - expect(noEvens).toEqual([1, 3, 5]); - - const fourLettersOrLess = reject( - (word) => word.length > 4, - ['Apple', 'Pear', 'Kiwi', 'Banana'] - ); - - expect(fourLettersOrLess).toEqual(['Pear', 'Kiwi']); -}); diff --git a/test5/remove/remove.test.js b/test5/remove/remove.test.js deleted file mode 100644 index 235ec23ac..000000000 --- a/test5/remove/remove.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const remove = require('./remove.js'); - -test('Testing remove', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof remove === 'function').toBeTruthy(); - expect(remove([1, 2, 3, 4], n => n % 2 === 0)).toEqual([2, 4]); -}); diff --git a/test5/removeNonASCII/removeNonASCII.test.js b/test5/removeNonASCII/removeNonASCII.test.js deleted file mode 100644 index d0d22b435..000000000 --- a/test5/removeNonASCII/removeNonASCII.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const removeNonASCII = require('./removeNonASCII.js'); - -test('Testing removeNonASCII', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof removeNonASCII === 'function').toBeTruthy(); - expect(removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ')).toBe('lorem-ipsum'); -}); diff --git a/test5/removeVowels/removeVowels.test.js b/test5/removeVowels/removeVowels.test.js deleted file mode 100644 index 79896ad4a..000000000 --- a/test5/removeVowels/removeVowels.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const removeVowels = require('./removeVowels.js'); - -test('Testing removeVowels', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof removeVowels === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test5/renameKeys/renameKeys.test.js b/test5/renameKeys/renameKeys.test.js deleted file mode 100644 index 553959820..000000000 --- a/test5/renameKeys/renameKeys.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const renameKeys = require('./renameKeys.js'); - -test('Testing renameKeys', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof renameKeys === 'function').toBeTruthy(); - - const obj = { name: 'Bobo', job: 'Front-End Master', shoeSize: 100 }; - const renamedObj = renameKeys({ name: 'firstName', job: 'passion' }, obj); - - expect(renamedObj).toEqual({ firstName: 'Bobo', passion: 'Front-End Master', shoeSize: 100 }); -}); diff --git a/test5/reverseString/reverseString.test.js b/test5/reverseString/reverseString.test.js deleted file mode 100644 index 6891a2ca8..000000000 --- a/test5/reverseString/reverseString.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const reverseString = require('./reverseString.js'); - -test('Testing reverseString', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof reverseString === 'function').toBeTruthy(); - expect(reverseString('foobar')).toBe('raboof'); -}); \ No newline at end of file diff --git a/test5/round/round.test.js b/test5/round/round.test.js deleted file mode 100644 index 3dda04bfe..000000000 --- a/test5/round/round.test.js +++ /dev/null @@ -1,22 +0,0 @@ -const expect = require('expect'); -const round = require('./round.js'); - -test('Testing round', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof round === 'function').toBeTruthy(); - expect(round(1.005, 2)).toBe(1.01); - expect(round(123.3423345345345345344, 11)).toBe(123.34233453453); - expect(round(3.342, 11)).toBe(3.342); - expect(round(1.005)).toBe(1); - expect(isNaN(round([1.005, 2]))).toBeTruthy(); - expect(isNaN(round('string'))).toBeTruthy(); - expect(isNaN(round())).toBeTruthy(); - expect(isNaN(round(132, 413, 4134))).toBeTruthy(); - expect(isNaN(round({a: 132}, 413))).toBeTruthy(); - - let start = new Date().getTime(); - round(123.3423345345345345344, 11); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); diff --git a/test6/URLJoin/URLJoin.test.js b/test6/URLJoin/URLJoin.test.js deleted file mode 100644 index 203e39fa3..000000000 --- a/test6/URLJoin/URLJoin.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const URLJoin = require('./URLJoin.js'); - -test('Testing URLJoin', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof URLJoin === 'function').toBeTruthy(); - expect(URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo')).toBe('http://www.google.com/a/b/cd?foo=123&bar=foo'); - expect(URLJoin('file://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo')).toBe('file:///www.google.com/a/b/cd?foo=123&bar=foo'); -}); diff --git a/test6/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js b/test6/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js deleted file mode 100644 index 95bc482a7..000000000 --- a/test6/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const UUIDGeneratorBrowser = require('./UUIDGeneratorBrowser.js'); - -test('Testing UUIDGeneratorBrowser', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof UUIDGeneratorBrowser === 'function').toBeTruthy(); -}); diff --git a/test6/UUIDGeneratorNode/UUIDGeneratorNode.test.js b/test6/UUIDGeneratorNode/UUIDGeneratorNode.test.js deleted file mode 100644 index 1be773a7e..000000000 --- a/test6/UUIDGeneratorNode/UUIDGeneratorNode.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const UUIDGeneratorNode = require('./UUIDGeneratorNode.js'); - -test('Testing UUIDGeneratorNode', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof UUIDGeneratorNode === 'function').toBeTruthy(); - const uuid = UUIDGeneratorNode(); - expect([uuid[8], uuid[13], uuid[18], uuid[23]]).toEqual(['-', '-', '-', '-']); - expect(/^[0-9A-Fa-f-]+$/.test(uuid)).toBeTruthy(); -}); diff --git a/test6/runAsync/runAsync.test.js b/test6/runAsync/runAsync.test.js deleted file mode 100644 index 703f15186..000000000 --- a/test6/runAsync/runAsync.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const runAsync = require('./runAsync.js'); - -test('Testing runAsync', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof runAsync === 'function').toBeTruthy(); -}); diff --git a/test6/runPromisesInSeries/runPromisesInSeries.test.js b/test6/runPromisesInSeries/runPromisesInSeries.test.js deleted file mode 100644 index 51e937d2d..000000000 --- a/test6/runPromisesInSeries/runPromisesInSeries.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const runPromisesInSeries = require('./runPromisesInSeries.js'); - -test('Testing runPromisesInSeries', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof runPromisesInSeries === 'function').toBeTruthy(); - const delay = d => new Promise(r => setTimeout(r, d)); - runPromisesInSeries([() => delay(100), () => delay(200).then(() => )]); -}); diff --git a/test6/sample/sample.test.js b/test6/sample/sample.test.js deleted file mode 100644 index 11847222f..000000000 --- a/test6/sample/sample.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const sample = require('./sample.js'); - -test('Testing sample', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sample === 'function').toBeTruthy(); - const arr = [3,7,9,11]; - expect(arr.includes(sample(arr))).toBeTruthy(); - expect(sample([1])).toBe(1); - expect(sample([])).toBe(undefined); -}); diff --git a/test6/sampleSize/sampleSize.test.js b/test6/sampleSize/sampleSize.test.js deleted file mode 100644 index e955495cf..000000000 --- a/test6/sampleSize/sampleSize.test.js +++ /dev/null @@ -1,14 +0,0 @@ -const expect = require('expect'); -const sampleSize = require('./sampleSize.js'); - -test('Testing sampleSize', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sampleSize === 'function').toBeTruthy(); - const arr = [3,7,9,11]; - expect(sampleSize(arr).length).toBe(1); - expect(sampleSize(arr, 2).every(x => arr.includes(x))).toBeTruthy(); - expect(sampleSize(arr, 5).length).toBe(4); - expect(sampleSize([], 2)).toEqual([]); - expect(sampleSize(arr, 0)).toEqual([]); -}); diff --git a/test6/scrollToTop/scrollToTop.test.js b/test6/scrollToTop/scrollToTop.test.js deleted file mode 100644 index 2f0f8ec27..000000000 --- a/test6/scrollToTop/scrollToTop.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const scrollToTop = require('./scrollToTop.js'); - -test('Testing scrollToTop', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof scrollToTop === 'function').toBeTruthy(); -}); diff --git a/test6/sdbm/sdbm.test.js b/test6/sdbm/sdbm.test.js deleted file mode 100644 index 361581a59..000000000 --- a/test6/sdbm/sdbm.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const sdbm = require('./sdbm.js'); - -test('Testing sdbm', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sdbm === 'function').toBeTruthy(); - expect(sdbm('name')).toBe(-3521204949); -}); \ No newline at end of file diff --git a/test6/serializeCookie/serializeCookie.test.js b/test6/serializeCookie/serializeCookie.test.js deleted file mode 100644 index 181b0d4c1..000000000 --- a/test6/serializeCookie/serializeCookie.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const serializeCookie = require('./serializeCookie.js'); - -test('Testing serializeCookie', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof serializeCookie === 'function').toBeTruthy(); - expect(serializeCookie('foo', 'bar')).toBe('foo=bar'); -}); diff --git a/test6/setStyle/setStyle.test.js b/test6/setStyle/setStyle.test.js deleted file mode 100644 index 395bb5621..000000000 --- a/test6/setStyle/setStyle.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const setStyle = require('./setStyle.js'); - -test('Testing setStyle', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof setStyle === 'function').toBeTruthy(); -}); diff --git a/test6/shallowClone/shallowClone.test.js b/test6/shallowClone/shallowClone.test.js deleted file mode 100644 index 6d6d64666..000000000 --- a/test6/shallowClone/shallowClone.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const shallowClone = require('./shallowClone.js'); - -test('Testing shallowClone', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof shallowClone === 'function').toBeTruthy(); - const a = { foo: 'bar', obj: { a: 1, b: 2 } }; - const b = shallowClone(a); - expect(a).not.toBe(b); - expect(a.obj).toBe(b.obj); -}); diff --git a/test6/show/show.test.js b/test6/show/show.test.js deleted file mode 100644 index 11113916a..000000000 --- a/test6/show/show.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const show = require('./show.js'); - -test('Testing show', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof show === 'function').toBeTruthy(); -}); diff --git a/test6/shuffle/shuffle.test.js b/test6/shuffle/shuffle.test.js deleted file mode 100644 index 56c472359..000000000 --- a/test6/shuffle/shuffle.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const shuffle = require('./shuffle.js'); - -test('Testing shuffle', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof shuffle === 'function').toBeTruthy(); - const arr = [1,2,3,4,5,6]; - expect(shuffle(arr)).not.toBe(arr); - expect(shuffle(arr).every(x => arr.includes(x))).toBeTruthy(); - expect(shuffle([])).toEqual([]); - expect(shuffle([1])).toEqual([1]); -}); diff --git a/test6/similarity/similarity.test.js b/test6/similarity/similarity.test.js deleted file mode 100644 index 2de50178f..000000000 --- a/test6/similarity/similarity.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const similarity = require('./similarity.js'); - -test('Testing similarity', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof similarity === 'function').toBeTruthy(); - expect(similarity([1, 2, 3], [1, 2, 4])).toEqual([1, 2]); //t.equal(similarity(args..), 'Expected'); -}); \ No newline at end of file diff --git a/test6/size/size.test.js b/test6/size/size.test.js deleted file mode 100644 index b35037e1a..000000000 --- a/test6/size/size.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const size = require('./size.js'); - -test('Testing size', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof size === 'function').toBeTruthy(); - expect(size([1, 2, 3, 4, 5])).toBe(5); - // t.equal(size('size'), 4, "Get size of arrays, objects or strings."); DOESN'T WORK IN NODE ENV - expect(size({ one: 1, two: 2, three: 3 })).toBe(3); -}); \ No newline at end of file diff --git a/test6/sleep/sleep.test.js b/test6/sleep/sleep.test.js deleted file mode 100644 index 72c1abf06..000000000 --- a/test6/sleep/sleep.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const sleep = require('./sleep.js'); - -test('Testing sleep', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sleep === 'function').toBeTruthy(); - async function sleepyWork() { - await sleep(1000); - } -}); diff --git a/test6/smoothScroll/smoothScroll.test.js b/test6/smoothScroll/smoothScroll.test.js deleted file mode 100644 index f5475db0e..000000000 --- a/test6/smoothScroll/smoothScroll.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const smoothScroll = require('./smoothScroll.js'); - -test('Testing smoothScroll', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof smoothScroll === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test6/solveRPN/solveRPN.test.js b/test6/solveRPN/solveRPN.test.js deleted file mode 100644 index f2c2420de..000000000 --- a/test6/solveRPN/solveRPN.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const solveRPN = require('./solveRPN.js'); - -test('Testing solveRPN', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof solveRPN === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test6/sortCharactersInString/sortCharactersInString.test.js b/test6/sortCharactersInString/sortCharactersInString.test.js deleted file mode 100644 index ab0ab6e1d..000000000 --- a/test6/sortCharactersInString/sortCharactersInString.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const sortCharactersInString = require('./sortCharactersInString.js'); - -test('Testing sortCharactersInString', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sortCharactersInString === 'function').toBeTruthy(); - expect(sortCharactersInString('cabbage')).toBe('aabbceg'); -}); \ No newline at end of file diff --git a/test6/sortedIndex/sortedIndex.test.js b/test6/sortedIndex/sortedIndex.test.js deleted file mode 100644 index 06af95ed1..000000000 --- a/test6/sortedIndex/sortedIndex.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const sortedIndex = require('./sortedIndex.js'); - -test('Testing sortedIndex', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sortedIndex === 'function').toBeTruthy(); - expect(sortedIndex([5, 3, 2, 1], 4)).toBe(1); - expect(sortedIndex([30, 50], 40)).toBe(1); -}); \ No newline at end of file diff --git a/test6/sortedIndexBy/sortedIndexBy.test.js b/test6/sortedIndexBy/sortedIndexBy.test.js deleted file mode 100644 index dede4bfdd..000000000 --- a/test6/sortedIndexBy/sortedIndexBy.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const sortedIndexBy = require('./sortedIndexBy.js'); - -test('Testing sortedIndexBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sortedIndexBy === 'function').toBeTruthy(); - expect(sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x)).toBe(0); -}); diff --git a/test6/sortedLastIndex/sortedLastIndex.test.js b/test6/sortedLastIndex/sortedLastIndex.test.js deleted file mode 100644 index 7ceb05736..000000000 --- a/test6/sortedLastIndex/sortedLastIndex.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const sortedLastIndex = require('./sortedLastIndex.js'); - -test('Testing sortedLastIndex', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sortedLastIndex === 'function').toBeTruthy(); - expect(sortedLastIndex([10, 20, 30, 30, 40], 30)).toBe(4); -}); diff --git a/test6/sortedLastIndexBy/sortedLastIndexBy.test.js b/test6/sortedLastIndexBy/sortedLastIndexBy.test.js deleted file mode 100644 index ec71c7f4b..000000000 --- a/test6/sortedLastIndexBy/sortedLastIndexBy.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const sortedLastIndexBy = require('./sortedLastIndexBy.js'); - -test('Testing sortedLastIndexBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sortedLastIndexBy === 'function').toBeTruthy(); - expect(sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x)).toBe(1); -}); diff --git a/test6/speechSynthesis/speechSynthesis.test.js b/test6/speechSynthesis/speechSynthesis.test.js deleted file mode 100644 index 7546f1972..000000000 --- a/test6/speechSynthesis/speechSynthesis.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const speechSynthesis = require('./speechSynthesis.js'); - -test('Testing speechSynthesis', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof speechSynthesis === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test6/splitLines/splitLines.test.js b/test6/splitLines/splitLines.test.js deleted file mode 100644 index bbeb1c5d8..000000000 --- a/test6/splitLines/splitLines.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const splitLines = require('./splitLines.js'); - -test('Testing splitLines', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof splitLines === 'function').toBeTruthy(); - expect(splitLines('This\nis a\nmultiline\nstring.\n')).toEqual(['This', 'is a', 'multiline', 'string.' , '']); -}); \ No newline at end of file diff --git a/test6/spreadOver/spreadOver.test.js b/test6/spreadOver/spreadOver.test.js deleted file mode 100644 index e198d4c70..000000000 --- a/test6/spreadOver/spreadOver.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const spreadOver = require('./spreadOver.js'); - -test('Testing spreadOver', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof spreadOver === 'function').toBeTruthy(); - const arrayMax = spreadOver(Math.max); - expect(arrayMax([1, 2, 3])).toBe(3); -}); \ No newline at end of file diff --git a/test6/stableSort/stableSort.test.js b/test6/stableSort/stableSort.test.js deleted file mode 100644 index 1915459ea..000000000 --- a/test6/stableSort/stableSort.test.js +++ /dev/null @@ -1,16 +0,0 @@ -const expect = require('expect'); -const stableSort = require('./stableSort.js'); - -test('Testing stableSort', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof stableSort === 'function').toBeTruthy(); - //t.deepEqual(stableSort(args..), 'Expected'); - //t.equal(stableSort(args..), 'Expected'); - //t.false(stableSort(args..), 'Expected'); - //t.throws(stableSort(args..), 'Expected'); - - const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - const compare = () => 0; - expect(stableSort(arr, compare)).toEqual(arr); -}); diff --git a/test6/standardDeviation/standardDeviation.test.js b/test6/standardDeviation/standardDeviation.test.js deleted file mode 100644 index 0708aff3a..000000000 --- a/test6/standardDeviation/standardDeviation.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const standardDeviation = require('./standardDeviation.js'); - -test('Testing standardDeviation', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof standardDeviation === 'function').toBeTruthy(); - expect(standardDeviation([10, 2, 38, 23, 38, 23, 21])).toBe(13.284434142114991); - expect(standardDeviation([10, 2, 38, 23, 38, 23, 21], true)).toBe(12.29899614287479); -}); \ No newline at end of file diff --git a/test6/stringPermutations/stringPermutations.test.js b/test6/stringPermutations/stringPermutations.test.js deleted file mode 100644 index 85c645ee3..000000000 --- a/test6/stringPermutations/stringPermutations.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const stringPermutations = require('./stringPermutations.js'); - -test('Testing stringPermutations', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof stringPermutations === 'function').toBeTruthy(); - expect(stringPermutations('abc')).toEqual(['abc','acb','bac','bca','cab','cba']); - expect(stringPermutations('a')).toEqual(['a']); - expect(stringPermutations('')).toEqual(['']); -}); diff --git a/test6/stripHTMLTags/stripHTMLTags.test.js b/test6/stripHTMLTags/stripHTMLTags.test.js deleted file mode 100644 index e3c59163f..000000000 --- a/test6/stripHTMLTags/stripHTMLTags.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const stripHTMLTags = require('./stripHTMLTags.js'); - -test('Testing stripHTMLTags', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof stripHTMLTags === 'function').toBeTruthy(); - expect(stripHTMLTags('

lorem ipsum


')).toBe('lorem ipsum'); -}); diff --git a/test6/sum/sum.test.js b/test6/sum/sum.test.js deleted file mode 100644 index 07b5cafc1..000000000 --- a/test6/sum/sum.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const sum = require('./sum.js'); - -test('Testing sum', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sum === 'function').toBeTruthy(); - expect(sum(...[1, 2, 3, 4])).toBe(10); -}); \ No newline at end of file diff --git a/test6/sumBy/sumBy.test.js b/test6/sumBy/sumBy.test.js deleted file mode 100644 index 390699e6a..000000000 --- a/test6/sumBy/sumBy.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const sumBy = require('./sumBy.js'); - -test('Testing sumBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sumBy === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test6/sumPower/sumPower.test.js b/test6/sumPower/sumPower.test.js deleted file mode 100644 index 684c57bc5..000000000 --- a/test6/sumPower/sumPower.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const sumPower = require('./sumPower.js'); - -test('Testing sumPower', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof sumPower === 'function').toBeTruthy(); - expect(sumPower(10)).toBe(385); - expect(sumPower(10, 3)).toBe(3025); - expect(sumPower(10, 3, 5)).toBe(2925); -}); \ No newline at end of file diff --git a/test6/symmetricDifference/symmetricDifference.test.js b/test6/symmetricDifference/symmetricDifference.test.js deleted file mode 100644 index 62c87aed3..000000000 --- a/test6/symmetricDifference/symmetricDifference.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const symmetricDifference = require('./symmetricDifference.js'); - -test('Testing symmetricDifference', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof symmetricDifference === 'function').toBeTruthy(); - expect(symmetricDifference([1, 2, 3], [1, 2, 4])).toEqual([3, 4]); -}); \ No newline at end of file diff --git a/test6/symmetricDifferenceBy/symmetricDifferenceBy.test.js b/test6/symmetricDifferenceBy/symmetricDifferenceBy.test.js deleted file mode 100644 index 537e68858..000000000 --- a/test6/symmetricDifferenceBy/symmetricDifferenceBy.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const symmetricDifferenceBy = require('./symmetricDifferenceBy.js'); - -test('Testing symmetricDifferenceBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof symmetricDifferenceBy === 'function').toBeTruthy(); - expect(symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor)).toEqual([ 1.2, 3.4 ]); -}); diff --git a/test6/symmetricDifferenceWith/symmetricDifferenceWith.test.js b/test6/symmetricDifferenceWith/symmetricDifferenceWith.test.js deleted file mode 100644 index db58684a5..000000000 --- a/test6/symmetricDifferenceWith/symmetricDifferenceWith.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const symmetricDifferenceWith = require('./symmetricDifferenceWith.js'); - -test('Testing symmetricDifferenceWith', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof symmetricDifferenceWith === 'function').toBeTruthy(); - expect(symmetricDifferenceWith( - [1, 1.2, 1.5, 3, 0], - [1.9, 3, 0, 3.9], - (a, b) => Math.round(a) === Math.round(b) -)).toEqual([1, 1.2, 3.9]); -}); diff --git a/test6/tail/tail.test.js b/test6/tail/tail.test.js deleted file mode 100644 index 198cdd6e9..000000000 --- a/test6/tail/tail.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const tail = require('./tail.js'); - -test('Testing tail', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof tail === 'function').toBeTruthy(); - expect(tail([1, 2, 3])).toEqual([2, 3]); - expect(tail([1])).toEqual([1]); -}); \ No newline at end of file diff --git a/test6/take/take.test.js b/test6/take/take.test.js deleted file mode 100644 index 52938149d..000000000 --- a/test6/take/take.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const take = require('./take.js'); - -test('Testing take', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof take === 'function').toBeTruthy(); - expect(take([1, 2, 3], 5)).toEqual([1, 2, 3]); - expect(take([1, 2, 3], 0)).toEqual([]); -}); diff --git a/test6/takeRight/takeRight.test.js b/test6/takeRight/takeRight.test.js deleted file mode 100644 index 3181ac032..000000000 --- a/test6/takeRight/takeRight.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const takeRight = require('./takeRight.js'); - -test('Testing takeRight', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof takeRight === 'function').toBeTruthy(); - expect(takeRight([1, 2, 3], 2)).toEqual([2, 3]); - expect(takeRight([1, 2, 3])).toEqual([3]); -}); \ No newline at end of file diff --git a/test6/takeRightWhile/takeRightWhile.test.js b/test6/takeRightWhile/takeRightWhile.test.js deleted file mode 100644 index 8adfeba6a..000000000 --- a/test6/takeRightWhile/takeRightWhile.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const takeRightWhile = require('./takeRightWhile.js'); - -test('Testing takeRightWhile', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof takeRightWhile === 'function').toBeTruthy(); - expect(takeRightWhile([1, 2, 3, 4], n => n < 3)).toEqual([3, 4]); -}); diff --git a/test6/takeWhile/takeWhile.test.js b/test6/takeWhile/takeWhile.test.js deleted file mode 100644 index 267e27bc2..000000000 --- a/test6/takeWhile/takeWhile.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const takeWhile = require('./takeWhile.js'); - -test('Testing takeWhile', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof takeWhile === 'function').toBeTruthy(); - expect(takeWhile([1, 2, 3, 4], n => n >= 3)).toEqual([1, 2]); -}); diff --git a/test6/throttle/throttle.test.js b/test6/throttle/throttle.test.js deleted file mode 100644 index 9335ed791..000000000 --- a/test6/throttle/throttle.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const throttle = require('./throttle.js'); - -test('Testing throttle', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof throttle === 'function').toBeTruthy(); -}); diff --git a/test6/timeTaken/timeTaken.test.js b/test6/timeTaken/timeTaken.test.js deleted file mode 100644 index 8105b99e7..000000000 --- a/test6/timeTaken/timeTaken.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const timeTaken = require('./timeTaken.js'); - -test('Testing timeTaken', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof timeTaken === 'function').toBeTruthy(); -}); diff --git a/test6/times/times.test.js b/test6/times/times.test.js deleted file mode 100644 index 0bd27bb8d..000000000 --- a/test6/times/times.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const times = require('./times.js'); - -test('Testing times', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof times === 'function').toBeTruthy(); - var output = ''; - times(5, i => (output += i)); - expect(output).toBe('01234'); -}); diff --git a/test6/toCamelCase/toCamelCase.test.js b/test6/toCamelCase/toCamelCase.test.js deleted file mode 100644 index 44ed8eee7..000000000 --- a/test6/toCamelCase/toCamelCase.test.js +++ /dev/null @@ -1,21 +0,0 @@ -const expect = require('expect'); -const toCamelCase = require('./toCamelCase.js'); - -test('Testing toCamelCase', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toCamelCase === 'function').toBeTruthy(); - expect(toCamelCase('some_database_field_name')).toBe('someDatabaseFieldName'); - expect(toCamelCase('Some label that needs to be camelized')).toBe('someLabelThatNeedsToBeCamelized'); - expect(toCamelCase('some-javascript-property')).toBe('someJavascriptProperty'); - expect(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens')).toBe('someMixedStringWithSpacesUnderscoresAndHyphens'); - expect(() => toCamelCase()).toThrow(); - expect(() => toCamelCase([])).toThrow(); - expect(() => toCamelCase({})).toThrow(); - expect(() => toCamelCase(123)).toThrow(); - - let start = new Date().getTime(); - toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); diff --git a/test6/toCurrency/toCurrency.test.js b/test6/toCurrency/toCurrency.test.js deleted file mode 100644 index 094796e01..000000000 --- a/test6/toCurrency/toCurrency.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const toCurrency = require('./toCurrency.js'); - -test('Testing toCurrency', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toCurrency === 'function').toBeTruthy(); - expect(toCurrency(123456.789, 'EUR')).toBe('€ 123,456.79'); - expect(toCurrency(123456.789, 'USD', 'en-us')).toBe('$123,456.79'); - //t.equal(toCurrency(123456.789, 'USD', 'fa'), '۱۲۳٬۴۵۶٫۷۹ ؜$', 'currency: US Dollar | currencyLangFormat: Farsi'); - These break in node - expect(toCurrency(322342436423.2435, 'JPY')).toBe('JP¥ 322,342,436,423'); -}); diff --git a/test6/toDecimalMark/toDecimalMark.test.js b/test6/toDecimalMark/toDecimalMark.test.js deleted file mode 100644 index ccd255818..000000000 --- a/test6/toDecimalMark/toDecimalMark.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const toDecimalMark = require('./toDecimalMark.js'); - -test('Testing toDecimalMark', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toDecimalMark === 'function').toBeTruthy(); - expect(toDecimalMark(12305030388.9087)).toBe("12,305,030,388.909"); -}); \ No newline at end of file diff --git a/test6/toHash/toHash.test.js b/test6/toHash/toHash.test.js deleted file mode 100644 index 13d1b12ca..000000000 --- a/test6/toHash/toHash.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const toHash = require('./toHash.js'); - -test('Testing toHash', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toHash === 'function').toBeTruthy(); -}); \ No newline at end of file diff --git a/test6/toKebabCase/toKebabCase.test.js b/test6/toKebabCase/toKebabCase.test.js deleted file mode 100644 index df6540382..000000000 --- a/test6/toKebabCase/toKebabCase.test.js +++ /dev/null @@ -1,25 +0,0 @@ -const expect = require('expect'); -const toKebabCase = require('./toKebabCase.js'); - -test('Testing toKebabCase', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toKebabCase === 'function').toBeTruthy(); - expect(toKebabCase('camelCase')).toBe('camel-case'); - expect(toKebabCase('some text')).toBe('some-text'); - expect(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens')).toBe('some-mixed-string-with-spaces-underscores-and-hyphens'); - expect( - toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') - ).toBe( - 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html' - ); - expect(toKebabCase()).toBe(undefined); - expect(() => toKebabCase([])).toThrow(); - expect(() => toKebabCase({})).toThrow(); - expect(() => toKebabCase(123)).toThrow(); - - let start = new Date().getTime(); - toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); diff --git a/test6/toOrdinalSuffix/toOrdinalSuffix.test.js b/test6/toOrdinalSuffix/toOrdinalSuffix.test.js deleted file mode 100644 index 03456a4a1..000000000 --- a/test6/toOrdinalSuffix/toOrdinalSuffix.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const toOrdinalSuffix = require('./toOrdinalSuffix.js'); - -test('Testing toOrdinalSuffix', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toOrdinalSuffix === 'function').toBeTruthy(); - expect(toOrdinalSuffix('123')).toBe('123rd'); - expect(toOrdinalSuffix(5)).toBe('5th'); - expect(toOrdinalSuffix(1)).toBe('1st'); - expect(toOrdinalSuffix(0)).toBe('0th'); -}); \ No newline at end of file diff --git a/test6/toSafeInteger/toSafeInteger.test.js b/test6/toSafeInteger/toSafeInteger.test.js deleted file mode 100644 index 82662b13b..000000000 --- a/test6/toSafeInteger/toSafeInteger.test.js +++ /dev/null @@ -1,23 +0,0 @@ -const expect = require('expect'); -const toSafeInteger = require('./toSafeInteger.js'); - -test('Testing toSafeInteger', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toSafeInteger === 'function').toBeTruthy(); - expect(Number(toSafeInteger(3.2))).toBeTruthy(); - expect(toSafeInteger(3.2)).toBe(3); - expect(toSafeInteger('4.2')).toBe(4); - expect(toSafeInteger(4.6)).toBe(5); - expect(toSafeInteger([])).toBe(0); - expect(isNaN(toSafeInteger([1.5, 3124]))).toBeTruthy(); - expect(isNaN(toSafeInteger('string'))).toBeTruthy(); - expect(isNaN(toSafeInteger({}))).toBeTruthy(); - expect(isNaN(toSafeInteger())).toBeTruthy(); - expect(toSafeInteger(Infinity)).toBe(9007199254740991); - - let start = new Date().getTime(); - toSafeInteger(3.2); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); diff --git a/test6/toSnakeCase/toSnakeCase.test.js b/test6/toSnakeCase/toSnakeCase.test.js deleted file mode 100644 index 42bd32fe2..000000000 --- a/test6/toSnakeCase/toSnakeCase.test.js +++ /dev/null @@ -1,25 +0,0 @@ -const expect = require('expect'); -const toSnakeCase = require('./toSnakeCase.js'); - -test('Testing toSnakeCase', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toSnakeCase === 'function').toBeTruthy(); - expect(toSnakeCase('camelCase')).toBe('camel_case'); - expect(toSnakeCase('some text')).toBe('some_text'); - expect(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens')).toBe('some_mixed_string_with_spaces_underscores_and_hyphens'); - expect( - toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') - ).toBe( - 'i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html' - ); - expect(toSnakeCase()).toBe(undefined); - expect(() => toSnakeCase([])).toThrow(); - expect(() => toSnakeCase({})).toThrow(); - expect(() => toSnakeCase(123)).toThrow(); - - let start = new Date().getTime(); - toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); diff --git a/test6/toggleClass/toggleClass.test.js b/test6/toggleClass/toggleClass.test.js deleted file mode 100644 index ed3488b5b..000000000 --- a/test6/toggleClass/toggleClass.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const toggleClass = require('./toggleClass.js'); - -test('Testing toggleClass', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof toggleClass === 'function').toBeTruthy(); -}); diff --git a/test6/tomorrow/tomorrow.test.js b/test6/tomorrow/tomorrow.test.js deleted file mode 100644 index ce4b5dddc..000000000 --- a/test6/tomorrow/tomorrow.test.js +++ /dev/null @@ -1,13 +0,0 @@ -const expect = require('expect'); -const tomorrow = require('./tomorrow.js'); - -test('Testing tomorrow', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof tomorrow === 'function').toBeTruthy(); - const t1 = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1); - const t2 = new Date(tomorrow()); - expect(t1.getFullYear()).toBe(t2.getFullYear()); - expect(t1.getMonth()).toBe(t2.getMonth()); - expect(t1.getDate()).toBe(t2.getDate()); -}); diff --git a/test6/transform/transform.test.js b/test6/transform/transform.test.js deleted file mode 100644 index c53499392..000000000 --- a/test6/transform/transform.test.js +++ /dev/null @@ -1,16 +0,0 @@ -const expect = require('expect'); -const transform = require('./transform.js'); - -test('Testing transform', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof transform === 'function').toBeTruthy(); - expect(transform( - { a: 1, b: 2, c: 1 }, - (r, v, k) => { - (r[v] || (r[v] = [])).push(k); - return r; - }, - {} -)).toEqual({ '1': ['a', 'c'], '2': ['b'] }); -}); diff --git a/test6/truncateString/truncateString.test.js b/test6/truncateString/truncateString.test.js deleted file mode 100644 index fa9506bee..000000000 --- a/test6/truncateString/truncateString.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const truncateString = require('./truncateString.js'); - -test('Testing truncateString', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof truncateString === 'function').toBeTruthy(); - expect(truncateString('boomerang', 7)).toBe('boom...'); -}); \ No newline at end of file diff --git a/test6/truthCheckCollection/truthCheckCollection.test.js b/test6/truthCheckCollection/truthCheckCollection.test.js deleted file mode 100644 index 7df47434b..000000000 --- a/test6/truthCheckCollection/truthCheckCollection.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const truthCheckCollection = require('./truthCheckCollection.js'); - -test('Testing truthCheckCollection', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof truthCheckCollection === 'function').toBeTruthy(); - expect( - truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex') - ).toBe(true); -}); \ No newline at end of file diff --git a/test6/unary/unary.test.js b/test6/unary/unary.test.js deleted file mode 100644 index 0b62e983f..000000000 --- a/test6/unary/unary.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const unary = require('./unary.js'); - -test('Testing unary', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unary === 'function').toBeTruthy(); - expect(['6', '8', '10'].map(unary(parseInt))).toEqual([6, 8, 10]); -}); diff --git a/test6/uncurry/uncurry.test.js b/test6/uncurry/uncurry.test.js deleted file mode 100644 index 72fa6bd80..000000000 --- a/test6/uncurry/uncurry.test.js +++ /dev/null @@ -1,15 +0,0 @@ -const expect = require('expect'); -const uncurry = require('./uncurry.js'); - -test('Testing uncurry', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof uncurry === 'function').toBeTruthy(); - const add = x => y => z => x + y + z; - const add1 = uncurry(add); - const add2 = uncurry(add, 2); - const add3 = uncurry(add, 3); - expect(add1(1)(2)(3)).toBe(6); - expect(add2(1,2)(3)).toBe(6); - expect(add3(1,2,3)).toBe(6); -}); diff --git a/test6/unescapeHTML/unescapeHTML.test.js b/test6/unescapeHTML/unescapeHTML.test.js deleted file mode 100644 index d1c7417a6..000000000 --- a/test6/unescapeHTML/unescapeHTML.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const unescapeHTML = require('./unescapeHTML.js'); - -test('Testing unescapeHTML', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unescapeHTML === 'function').toBeTruthy(); - expect(unescapeHTML('<a href="#">Me & you</a>')).toBe('Me & you'); -}); \ No newline at end of file diff --git a/test6/unflattenObject/unflattenObject.test.js b/test6/unflattenObject/unflattenObject.test.js deleted file mode 100644 index 48975c4a0..000000000 --- a/test6/unflattenObject/unflattenObject.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const unflattenObject = require('./unflattenObject.js'); - -test('Testing unflattenObject', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unflattenObject === 'function').toBeTruthy(); - expect(unflattenObject({ 'a.b.c': 1, d: 1 })).toEqual({ a: { b: { c: 1 } }, d: 1 }); -}); diff --git a/test6/unfold/unfold.test.js b/test6/unfold/unfold.test.js deleted file mode 100644 index 08dd245d5..000000000 --- a/test6/unfold/unfold.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const unfold = require('./unfold.js'); - -test('Testing unfold', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unfold === 'function').toBeTruthy(); - var f = n => (n > 50 ? false : [-n, n + 10]); - expect(unfold(f, 10)).toEqual([-10, -20, -30, -40, -50]); -}); diff --git a/test6/union/union.test.js b/test6/union/union.test.js deleted file mode 100644 index a49ba0af5..000000000 --- a/test6/union/union.test.js +++ /dev/null @@ -1,23 +0,0 @@ -const expect = require('expect'); -const union = require('./union.js'); - -test('Testing union', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof union === 'function').toBeTruthy(); - expect(union([1, 2, 3], [4, 3, 2])).toEqual([1, 2, 3, 4]); - expect(union('str', 'asd')).toEqual([ 's', 't', 'r', 'a', 'd' ]); - expect(union([[], {}], [1, 2, 3])).toEqual([[], {}, 1, 2, 3]); - expect(union([], [])).toEqual([]); - expect(() => union()).toThrow(); - expect(() => union(true, 'str')).toThrow(); - expect(() => union('false', true)).toThrow(); - expect(() => union(123, {})).toThrow(); - expect(() => union([], {})).toThrow(); - expect(() => union(undefined, null)).toThrow(); - - let start = new Date().getTime(); - union([1, 2, 3], [4, 3, 2]); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); diff --git a/test6/unionBy/unionBy.test.js b/test6/unionBy/unionBy.test.js deleted file mode 100644 index 730f9d05a..000000000 --- a/test6/unionBy/unionBy.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const unionBy = require('./unionBy.js'); - -test('Testing unionBy', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unionBy === 'function').toBeTruthy(); - expect(unionBy([2.1], [1.2, 2.3], Math.floor)).toEqual([2.1, 1.2]); -}); diff --git a/test6/unionWith/unionWith.test.js b/test6/unionWith/unionWith.test.js deleted file mode 100644 index f6d69956e..000000000 --- a/test6/unionWith/unionWith.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const unionWith = require('./unionWith.js'); - -test('Testing unionWith', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unionWith === 'function').toBeTruthy(); - expect( - unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)) - ).toEqual([1, 1.2, 1.5, 3, 0, 3.9]); -}); diff --git a/test6/uniqueElements/uniqueElements.test.js b/test6/uniqueElements/uniqueElements.test.js deleted file mode 100644 index ca9a46bfe..000000000 --- a/test6/uniqueElements/uniqueElements.test.js +++ /dev/null @@ -1,26 +0,0 @@ -const expect = require('expect'); -const uniqueElements = require('./uniqueElements.js'); - -test('Testing uniqueElements', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof uniqueElements === 'function').toBeTruthy(); - expect(uniqueElements([1, 2, 2, 3, 4, 4, 5])).toEqual([1,2,3,4,5]); - expect(uniqueElements([1, 23, 53])).toEqual([1, 23, 53]); - expect(uniqueElements([true, 0, 1, false, false, undefined, null, ''])).toEqual([true, 0, 1, false, undefined, null, '']); - expect(uniqueElements()).toEqual([]); - expect(uniqueElements(null)).toEqual([]); - expect(uniqueElements(undefined)).toEqual([]); - expect(uniqueElements('strt')).toEqual(['s', 't', 'r']); - expect(() => uniqueElements(1, 1, 2543, 534, 5)).toThrow(); - expect(() => uniqueElements({})).toThrow(); - expect(() => uniqueElements(true)).toThrow(); - expect(() => uniqueElements(false)).toThrow(); - - let start = new Date().getTime(); - uniqueElements([true, 0, 1, false, false, undefined, null, '']); - let end = new Date().getTime(); - expect((end - start) < 2000).toBeTruthy(); -}); - -uniqueElements([1, 2, 2, '1', 4, 4, 4, 5, true]); // [1,2,3,4,5] diff --git a/test6/untildify/untildify.test.js b/test6/untildify/untildify.test.js deleted file mode 100644 index cbad74b6b..000000000 --- a/test6/untildify/untildify.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const untildify = require('./untildify.js'); - -test('Testing untildify', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof untildify === 'function').toBeTruthy(); - expect(untildify('~/test/dir/file.f').indexOf('~') === -1).toBeTruthy(); - expect(untildify('~/test/dir/file.f').slice(-16)).toBe('/test/dir/file.f'); - expect(untildify('test/dir/file.f')).toBe('test/dir/file.f'); -}); diff --git a/test6/unzip/unzip.test.js b/test6/unzip/unzip.test.js deleted file mode 100644 index e3b88825d..000000000 --- a/test6/unzip/unzip.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const expect = require('expect'); -const unzip = require('./unzip.js'); - -test('Testing unzip', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unzip === 'function').toBeTruthy(); - expect(unzip([['a', 1, true], ['b', 2, false]])).toEqual([['a', 'b'], [1, 2], [true, false]]); - expect(unzip([['a', 1, true], ['b', 2]])).toEqual([['a', 'b'], [1, 2], [true]]); -}); diff --git a/test6/unzipWith/unzipWith.test.js b/test6/unzipWith/unzipWith.test.js deleted file mode 100644 index 40752b618..000000000 --- a/test6/unzipWith/unzipWith.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const expect = require('expect'); -const unzipWith = require('./unzipWith.js'); - -test('Testing unzipWith', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof unzipWith === 'function').toBeTruthy(); - expect( - unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) - ).toEqual([3, 30, 300]); -}); diff --git a/test6/validateNumber/validateNumber.test.js b/test6/validateNumber/validateNumber.test.js deleted file mode 100644 index ef31971ae..000000000 --- a/test6/validateNumber/validateNumber.test.js +++ /dev/null @@ -1,20 +0,0 @@ -const expect = require('expect'); -const validateNumber = require('./validateNumber.js'); - -test('Testing validateNumber', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof validateNumber === 'function').toBeTruthy(); - expect(validateNumber(9)).toBeTruthy(); - expect(validateNumber('234asd'.slice(0, 2))).toBeTruthy(); - expect(validateNumber(1232)).toBeTruthy(); - expect(validateNumber(1232 + 13423)).toBeTruthy(); - expect(validateNumber(1232 * 2342 * 123)).toBeTruthy(); - expect(validateNumber(1232.23423536)).toBeTruthy(); - expect(validateNumber('234asd')).toBeFalsy(); - expect(validateNumber('e234d')).toBeFalsy(); - expect(validateNumber(false)).toBeFalsy(); - expect(validateNumber(true)).toBeFalsy(); - expect(validateNumber(null)).toBeFalsy(); - expect(validateNumber(123 * 'asd')).toBeFalsy(); -}); diff --git a/test6/when/when.test.js b/test6/when/when.test.js deleted file mode 100644 index 154c84c4f..000000000 --- a/test6/when/when.test.js +++ /dev/null @@ -1,16 +0,0 @@ -const expect = require('expect'); -const when = require('./when.js'); - -test('Testing when', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof when === 'function').toBeTruthy(); - - const doubleEvenNumbers = when( - (x) => x % 2 === 0, - (x) => x * 2 - ); - - expect(doubleEvenNumbers(2) === 4).toBeTruthy(); - expect(doubleEvenNumbers(1) === 1).toBeTruthy(); -}); diff --git a/test6/without/without.test.js b/test6/without/without.test.js deleted file mode 100644 index 88053f595..000000000 --- a/test6/without/without.test.js +++ /dev/null @@ -1,17 +0,0 @@ -const expect = require('expect'); -const without = require('./without.js'); - -test('Testing without', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof without === 'function').toBeTruthy(); - expect(without([2, 1, 2, 3], 1, 2)).toEqual([3]); - expect(without([])).toEqual([]); - expect(without([3, 1, true, '3', true], '3', true)).toEqual([3, 1]); - expect(without('string'.split(''), 's', 't', 'g')).toEqual(['r', 'i', 'n']); - expect(() => without()).toThrow(); - expect(() => without(null)).toThrow(); - expect(() => without(undefined)).toThrow(); - expect(() => without(123)).toThrow(); - expect(() => without({})).toThrow(); -}); diff --git a/test6/words/words.test.js b/test6/words/words.test.js deleted file mode 100644 index 9d57bdf0e..000000000 --- a/test6/words/words.test.js +++ /dev/null @@ -1,17 +0,0 @@ -const expect = require('expect'); -const words = require('./words.js'); - -test('Testing words', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof words === 'function').toBeTruthy(); - expect(words('I love javaScript!!')).toEqual(["I", "love", "javaScript"]); - expect(words('python, javaScript & coffee')).toEqual(["python", "javaScript", "coffee"]); - expect(Array.isArray(words('I love javaScript!!'))).toBeTruthy(); - expect(() => words()).toThrow(); - expect(() => words(null)).toThrow(); - expect(() => words(undefined)).toThrow(); - expect(() => words({})).toThrow(); - expect(() => words([])).toThrow(); - expect(() => words(1234)).toThrow(); -}); diff --git a/test6/xProd/xProd.test.js b/test6/xProd/xProd.test.js deleted file mode 100644 index 9c94485c4..000000000 --- a/test6/xProd/xProd.test.js +++ /dev/null @@ -1,9 +0,0 @@ -const expect = require('expect'); -const xProd = require('./xProd.js'); - -test('Testing xProd', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof xProd === 'function').toBeTruthy(); - expect(xProd([1, 2], ['a', 'b'])).toEqual([[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]); -}); diff --git a/test6/yesNo/yesNo.test.js b/test6/yesNo/yesNo.test.js deleted file mode 100644 index 6947ca429..000000000 --- a/test6/yesNo/yesNo.test.js +++ /dev/null @@ -1,20 +0,0 @@ -const expect = require('expect'); -const yesNo = require('./yesNo.js'); - -test('Testing yesNo', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof yesNo === 'function').toBeTruthy(); - expect(yesNo('Y')).toBeTruthy(); - expect(yesNo('yes')).toBeTruthy(); - expect(yesNo('foo', true)).toBeTruthy(); - expect(yesNo('No')).toBeFalsy(); - expect(yesNo()).toBeFalsy(); - expect(yesNo(null)).toBeFalsy(); - expect(yesNo(undefined)).toBeFalsy(); - expect(yesNo([123, null])).toBeFalsy(); - expect(yesNo(['Yes', 'No'])).toBeFalsy(); - expect(yesNo({ 2: 'Yes' })).toBeFalsy(); - expect(yesNo(['Yes', 'No'], true)).toBeTruthy(); - expect(yesNo({ 2: 'Yes' }, true)).toBeTruthy(); -}); diff --git a/test6/zip/zip.test.js b/test6/zip/zip.test.js deleted file mode 100644 index 7da9b8d65..000000000 --- a/test6/zip/zip.test.js +++ /dev/null @@ -1,16 +0,0 @@ -const expect = require('expect'); -const zip = require('./zip.js'); - -test('Testing zip', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof zip === 'function').toBeTruthy(); - expect(zip(['a', 'b'], [1, 2], [true, false])).toEqual([['a', 1, true], ['b', 2, false]]); - expect(zip(['a'], [1, 2], [true, false])).toEqual([['a', 1, true], [undefined, 2, false]]); - expect(zip()).toEqual([]); - expect(zip(123)).toEqual([]); - expect(Array.isArray(zip(['a', 'b'], [1, 2], [true, false]))).toBeTruthy(); - expect(Array.isArray(zip(['a'], [1, 2], [true, false]))).toBeTruthy(); - expect(() => zip(null)).toThrow(); - expect(() => zip(undefined)).toThrow(); -}); diff --git a/test6/zipObject/zipObject.test.js b/test6/zipObject/zipObject.test.js deleted file mode 100644 index de895be37..000000000 --- a/test6/zipObject/zipObject.test.js +++ /dev/null @@ -1,17 +0,0 @@ -const expect = require('expect'); -const zipObject = require('./zipObject.js'); - -test('Testing zipObject', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof zipObject === 'function').toBeTruthy(); - expect(zipObject(['a', 'b', 'c'], [1, 2])).toEqual({a: 1, b: 2, c: undefined}); - expect(zipObject(['a', 'b'], [1, 2, 3])).toEqual({a: 1, b: 2}); - expect(zipObject(['a', 'b', 'c'], 'string')).toEqual({ a: 's', b: 't', c: 'r' }); - expect(zipObject(['a'], 'string')).toEqual({ a: 's' }); - expect(() => zipObject()).toThrow(); - expect(() => zipObject(['string'], null)).toThrow(); - expect(() => zipObject(null, [1])).toThrow(); - expect(() => zipObject('string')).toThrow(); - expect(() => zipObject('test', 'string')).toThrow(); -}); diff --git a/test6/zipWith/zipWith.test.js b/test6/zipWith/zipWith.test.js deleted file mode 100644 index 1c6f8199e..000000000 --- a/test6/zipWith/zipWith.test.js +++ /dev/null @@ -1,8 +0,0 @@ -const expect = require('expect'); -const zipWith = require('./zipWith.js'); - -test('Testing zipWith', () => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - expect(typeof zipWith === 'function').toBeTruthy(); -}); \ No newline at end of file