Merge branch 'master' into add-permuteAll
This commit is contained in:
2
test/all/all.js
Normal file
2
test/all/all.js
Normal file
@ -0,0 +1,2 @@
|
||||
const all = (arr, fn = Boolean) => arr.every(fn);
|
||||
module.exports = all;
|
||||
21
test/all/all.test.js
Normal file
21
test/all/all.test.js
Normal file
@ -0,0 +1,21 @@
|
||||
const test = require('tape');
|
||||
const all = require('./all.js');
|
||||
|
||||
test('Testing all', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof all === 'function', 'all is a Function');
|
||||
t.true(all([4,1,2,3]), 'Returns true for arrays with no falsey values');
|
||||
t.false(all([0,1]), 'Returns false for arrays with 0');
|
||||
t.false(all([NaN,1]), 'Returns false for arrays with NaN');
|
||||
t.false(all([undefined,1]), 'Returns false for arrays with undefined');
|
||||
t.false(all([null,1]), 'Returns false for arrays with null');
|
||||
t.false(all(['',1]), 'Returns false for arrays with empty strings');
|
||||
t.true(all([4,1,2,3], x => x >= 1), 'Returns true with predicate function');
|
||||
t.false(all([0,1], x => x >= 1), 'Returns false with a predicate function');
|
||||
//t.deepEqual(all(args..), 'Expected');
|
||||
//t.equal(all(args..), 'Expected');
|
||||
//t.false(all(args..), 'Expected');
|
||||
//t.throws(all(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
2
test/any/any.js
Normal file
2
test/any/any.js
Normal file
@ -0,0 +1,2 @@
|
||||
const any = (arr, fn = Boolean) => arr.some(fn);
|
||||
module.exports = any;
|
||||
18
test/any/any.test.js
Normal file
18
test/any/any.test.js
Normal file
@ -0,0 +1,18 @@
|
||||
const test = require('tape');
|
||||
const any = require('./any.js');
|
||||
|
||||
test('Testing any', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof any === 'function', 'any is a Function');
|
||||
t.true(any([0,1,2,3]), 'Returns true for arrays with at least one truthy value');
|
||||
t.false(any([0,0]), 'Returns false for arrays with no truthy values');
|
||||
t.false(any([NaN,0,undefined,null,'']), 'Returns false for arrays with no truthy values');
|
||||
t.true(any([4,1,0,3], x => x >= 1), 'Returns true with predicate function');
|
||||
t.false(any([0,1], x => x < 0), 'Returns false with a predicate function');
|
||||
//t.deepEqual(any(args..), 'Expected');
|
||||
//t.equal(any(args..), 'Expected');
|
||||
//t.false(any(args..), 'Expected');
|
||||
//t.throws(any(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
2
test/approximatelyEqual/approximatelyEqual.js
Normal file
2
test/approximatelyEqual/approximatelyEqual.js
Normal file
@ -0,0 +1,2 @@
|
||||
const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;
|
||||
module.exports = approximatelyEqual;
|
||||
17
test/approximatelyEqual/approximatelyEqual.test.js
Normal file
17
test/approximatelyEqual/approximatelyEqual.test.js
Normal file
@ -0,0 +1,17 @@
|
||||
const test = require('tape');
|
||||
const approximatelyEqual = require('./approximatelyEqual.js');
|
||||
|
||||
test('Testing approximatelyEqual', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof approximatelyEqual === 'function', 'approximatelyEqual is a Function');
|
||||
t.true(approximatelyEqual(Math.PI / 2.0 , 1.5708), 'Works for PI / 2');
|
||||
t.true(approximatelyEqual(0.1 + 0.2, 0.3), 'Works for 0.1 + 0.2 === 0.3');
|
||||
t.true(approximatelyEqual(0.5, 0.5), 'Works for exactly equal values');
|
||||
t.true(approximatelyEqual(0.501, 0.5, 0.1), 'Works for a custom epsilon');
|
||||
//t.deepEqual(approximatelyEqual(args..), 'Expected');
|
||||
//t.equal(approximatelyEqual(args..), 'Expected');
|
||||
//t.false(approximatelyEqual(args..), 'Expected');
|
||||
//t.throws(approximatelyEqual(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -5,9 +5,10 @@ test('Testing arrayToHtmlList', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof arrayToHtmlList === 'function', 'arrayToHtmlList is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(arrayToHtmlList(args..), 'Expected');
|
||||
//t.equal(arrayToHtmlList(args..), 'Expected');
|
||||
//t.false(arrayToHtmlList(args..), 'Expected');
|
||||
//t.throws(arrayToHtmlList(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -19,6 +19,6 @@ test('Testing average', (t) => {
|
||||
let start = new Date().getTime();
|
||||
average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631);
|
||||
let end = new Date().getTime();
|
||||
t.true((end - start) < 2000, 'head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run');
|
||||
t.true((end - start) < 2000, 'average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run');
|
||||
t.end();
|
||||
});
|
||||
3
test/bifurcate/bifurcate.js
Normal file
3
test/bifurcate/bifurcate.js
Normal file
@ -0,0 +1,3 @@
|
||||
const bifurcate = (arr, filter) =>
|
||||
arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]);
|
||||
module.exports = bifurcate;
|
||||
14
test/bifurcate/bifurcate.test.js
Normal file
14
test/bifurcate/bifurcate.test.js
Normal file
@ -0,0 +1,14 @@
|
||||
const test = require('tape');
|
||||
const bifurcate = require('./bifurcate.js');
|
||||
|
||||
test('Testing bifurcate', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof bifurcate === 'function', 'bifurcate is a Function');
|
||||
t.deepEqual(bifurcate([ 'beep', 'boop', 'foo', 'bar' ], [ true, true, false, true ]), [ ['beep', 'boop', 'bar'], ['foo'] ], 'Splits the collection into two groups');
|
||||
//t.deepEqual(bifurcate(args..), 'Expected');
|
||||
//t.equal(bifurcate(args..), 'Expected');
|
||||
//t.false(bifurcate(args..), 'Expected');
|
||||
//t.throws(bifurcate(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
3
test/bifurcateBy/bifurcateBy.js
Normal file
3
test/bifurcateBy/bifurcateBy.js
Normal file
@ -0,0 +1,3 @@
|
||||
const bifurcateBy = (arr, fn) =>
|
||||
arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]);
|
||||
module.exports = bifurcateBy;
|
||||
14
test/bifurcateBy/bifurcateBy.test.js
Normal file
14
test/bifurcateBy/bifurcateBy.test.js
Normal file
@ -0,0 +1,14 @@
|
||||
const test = require('tape');
|
||||
const bifurcateBy = require('./bifurcateBy.js');
|
||||
|
||||
test('Testing bifurcateBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof bifurcateBy === 'function', 'bifurcateBy is a Function');
|
||||
t.deepEqual(bifurcateBy([ 'beep', 'boop', 'foo', 'bar' ], x => x[0] === 'b'), [ ['beep', 'boop', 'bar'], ['foo'] ], 'Splits the collection into two groups');
|
||||
//t.deepEqual(bifurcateBy(args..), 'Expected');
|
||||
//t.equal(bifurcateBy(args..), 'Expected');
|
||||
//t.false(bifurcateBy(args..), 'Expected');
|
||||
//t.throws(bifurcateBy(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
11
test/binomialCoefficient/binomialCoefficient.js
Normal file
11
test/binomialCoefficient/binomialCoefficient.js
Normal file
@ -0,0 +1,11 @@
|
||||
const binomialCoefficient = (n, k) => {
|
||||
if (Number.isNaN(n) || Number.isNaN(k)) return NaN;
|
||||
if (k < 0 || k > n) return 0;
|
||||
if (k === 0 || k === n) return 1;
|
||||
if (k === 1 || k === n - 1) return n;
|
||||
if (n - k < k) k = n - k;
|
||||
let res = n;
|
||||
for (let j = 2; j <= k; j++) res *= (n - j + 1) / j;
|
||||
return Math.round(res);
|
||||
};
|
||||
module.exports = binomialCoefficient;
|
||||
18
test/binomialCoefficient/binomialCoefficient.test.js
Normal file
18
test/binomialCoefficient/binomialCoefficient.test.js
Normal file
@ -0,0 +1,18 @@
|
||||
const test = require('tape');
|
||||
const binomialCoefficient = require('./binomialCoefficient.js');
|
||||
|
||||
test('Testing binomialCoefficient', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof binomialCoefficient === 'function', 'binomialCoefficient is a 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');
|
||||
t.true(Number.isNaN(binomialCoefficient(NaN, 3)), 'Returns NaN');
|
||||
t.true(Number.isNaN(binomialCoefficient(5, NaN)), 'Returns NaN');
|
||||
//t.deepEqual(binomialCoefficient(args..), 'Expected');
|
||||
//t.equal(binomialCoefficient(args..), 'Expected');
|
||||
//t.false(binomialCoefficient(args..), 'Expected');
|
||||
//t.throws(binomialCoefficient(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -5,22 +5,19 @@ test('Testing chainAsync', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof chainAsync === 'function', 'chainAsync is a Function');
|
||||
//t.deepEqual(chainAsync(args..), 'Expected');
|
||||
// chainAsync([
|
||||
// next => {
|
||||
// next();
|
||||
// },
|
||||
// next => {
|
||||
// (() =>{
|
||||
// next()
|
||||
// })();
|
||||
// },
|
||||
// next => {
|
||||
// t.pass("Calls all functions in an array");
|
||||
// next();
|
||||
// }
|
||||
// ]);
|
||||
//
|
||||
chainAsync([
|
||||
next => {
|
||||
next();
|
||||
},
|
||||
next => {
|
||||
(() => {
|
||||
next();
|
||||
})();
|
||||
},
|
||||
next => {
|
||||
t.pass("Calls all functions in an array");
|
||||
}
|
||||
]);
|
||||
// // Ensure we wait for the 2nd assertion to be made
|
||||
// t.plan(2);
|
||||
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing createElement', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof createElement === 'function', 'createElement is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(createElement(args..), 'Expected');
|
||||
//t.equal(createElement(args..), 'Expected');
|
||||
//t.false(createElement(args..), 'Expected');
|
||||
//t.throws(createElement(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing createEventHub', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof createEventHub === 'function', 'createEventHub is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(createEventHub(args..), 'Expected');
|
||||
//t.equal(createEventHub(args..), 'Expected');
|
||||
//t.false(createEventHub(args..), 'Expected');
|
||||
//t.throws(createEventHub(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing currentURL', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof currentURL === 'function', 'currentURL is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(currentURL(args..), 'Expected');
|
||||
//t.equal(currentURL(args..), 'Expected');
|
||||
//t.false(currentURL(args..), 'Expected');
|
||||
//t.throws(currentURL(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing debounce', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof debounce === 'function', 'debounce is a Function');
|
||||
debounce(() => {t.pass('Works as expected');}, 250);
|
||||
//t.deepEqual(debounce(args..), 'Expected');
|
||||
//t.equal(debounce(args..), 'Expected');
|
||||
//t.false(debounce(args..), 'Expected');
|
||||
//t.throws(debounce(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing defaults', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof defaults === 'function', 'defaults is a Function');
|
||||
t.deepEqual(defaults({ a: 1 }, { b: 2 }, { b: 6 }, { a: 3 }), { a: 1, b: 2 }, 'Assigns default values for undefined properties');
|
||||
//t.deepEqual(defaults(args..), 'Expected');
|
||||
//t.equal(defaults(args..), 'Expected');
|
||||
//t.false(defaults(args..), 'Expected');
|
||||
//t.throws(defaults(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing defer', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof defer === 'function', 'defer is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(defer(args..), 'Expected');
|
||||
//t.equal(defer(args..), 'Expected');
|
||||
//t.false(defer(args..), 'Expected');
|
||||
//t.throws(defer(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
2
test/degreesToRads/degreesToRads.js
Normal file
2
test/degreesToRads/degreesToRads.js
Normal file
@ -0,0 +1,2 @@
|
||||
const degreesToRads = deg => deg * Math.PI / 180.0;
|
||||
module.exports = degreesToRads;
|
||||
15
test/degreesToRads/degreesToRads.test.js
Normal file
15
test/degreesToRads/degreesToRads.test.js
Normal file
@ -0,0 +1,15 @@
|
||||
const test = require('tape');
|
||||
const degreesToRads = require('./degreesToRads.js');
|
||||
|
||||
test('Testing degreesToRads', (t) => {
|
||||
//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
|
||||
t.true(typeof degreesToRads === 'function', 'degreesToRads is a Function');
|
||||
t.true(approxeq(degreesToRads(90.0), Math.PI / 2), 'Returns the appropriate value');
|
||||
//t.deepEqual(degreesToRads(args..), 'Expected');
|
||||
//t.equal(degreesToRads(args..), 'Expected');
|
||||
//t.false(degreesToRads(args..), 'Expected');
|
||||
//t.throws(degreesToRads(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -5,9 +5,16 @@ test('Testing delay', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof delay === 'function', 'delay is a Function');
|
||||
delay(
|
||||
function(text) {
|
||||
t.equals(text, 'test', 'Works as expecting, passing arguments properly');
|
||||
},
|
||||
1000,
|
||||
'test'
|
||||
);
|
||||
//t.deepEqual(delay(args..), 'Expected');
|
||||
//t.equal(delay(args..), 'Expected');
|
||||
//t.false(delay(args..), 'Expected');
|
||||
//t.throws(delay(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing getScrollPosition', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof getScrollPosition === 'function', 'getScrollPosition is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(getScrollPosition(args..), 'Expected');
|
||||
//t.equal(getScrollPosition(args..), 'Expected');
|
||||
//t.false(getScrollPosition(args..), 'Expected');
|
||||
//t.throws(getScrollPosition(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing getStyle', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof getStyle === 'function', 'getStyle is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(getStyle(args..), 'Expected');
|
||||
//t.equal(getStyle(args..), 'Expected');
|
||||
//t.false(getStyle(args..), 'Expected');
|
||||
//t.throws(getStyle(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing hasFlags', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof hasFlags === 'function', 'hasFlags is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(hasFlags(args..), 'Expected');
|
||||
//t.equal(hasFlags(args..), 'Expected');
|
||||
//t.false(hasFlags(args..), 'Expected');
|
||||
//t.throws(hasFlags(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing hashBrowser', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof hashBrowser === 'function', 'hashBrowser is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(hashBrowser(args..), 'Expected');
|
||||
//t.equal(hashBrowser(args..), 'Expected');
|
||||
//t.false(hashBrowser(args..), 'Expected');
|
||||
//t.throws(hashBrowser(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing hide', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof hide === 'function', 'hide is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(hide(args..), 'Expected');
|
||||
//t.equal(hide(args..), 'Expected');
|
||||
//t.false(hide(args..), 'Expected');
|
||||
//t.throws(hide(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
9
test/mostPerformant/mostPerformant.js
Normal file
9
test/mostPerformant/mostPerformant.js
Normal file
@ -0,0 +1,9 @@
|
||||
const mostPerformant = (fns, iterations = 10000) => {
|
||||
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;
|
||||
14
test/mostPerformant/mostPerformant.test.js
Normal file
14
test/mostPerformant/mostPerformant.test.js
Normal file
@ -0,0 +1,14 @@
|
||||
const test = require('tape');
|
||||
const mostPerformant = require('./mostPerformant.js');
|
||||
|
||||
test('Testing mostPerformant', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof mostPerformant === 'function', 'mostPerformant is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(mostPerformant(args..), 'Expected');
|
||||
//t.equal(mostPerformant(args..), 'Expected');
|
||||
//t.false(mostPerformant(args..), 'Expected');
|
||||
//t.throws(mostPerformant(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
2
test/none/none.js
Normal file
2
test/none/none.js
Normal file
@ -0,0 +1,2 @@
|
||||
const none = (arr, fn = Boolean) => !arr.some(fn);
|
||||
module.exports = none;
|
||||
17
test/none/none.test.js
Normal file
17
test/none/none.test.js
Normal file
@ -0,0 +1,17 @@
|
||||
const test = require('tape');
|
||||
const none = require('./none.js');
|
||||
|
||||
test('Testing none', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof none === 'function', 'none is a Function');
|
||||
t.true(none([0,undefined,NaN,null,'']), 'Returns true for arrays with no truthy values');
|
||||
t.false(none([0,1]), 'Returns false for arrays with at least one truthy value');
|
||||
t.true(none([4,1,0,3], x => x < 0), 'Returns true with a predicate function');
|
||||
t.false(none([0,1,2], x => x === 1), 'Returns false with predicate function');
|
||||
//t.deepEqual(none(args..), 'Expected');
|
||||
//t.equal(none(args..), 'Expected');
|
||||
//t.false(none(args..), 'Expected');
|
||||
//t.throws(none(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -5,9 +5,10 @@ test('Testing off', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof off === 'function', 'off is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(off(args..), 'Expected');
|
||||
//t.equal(off(args..), 'Expected');
|
||||
//t.false(off(args..), 'Expected');
|
||||
//t.throws(off(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing on', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof on === 'function', 'on is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(on(args..), 'Expected');
|
||||
//t.equal(on(args..), 'Expected');
|
||||
//t.false(on(args..), 'Expected');
|
||||
//t.throws(on(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing onUserInputChange', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof onUserInputChange === 'function', 'onUserInputChange is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(onUserInputChange(args..), 'Expected');
|
||||
//t.equal(onUserInputChange(args..), 'Expected');
|
||||
//t.false(onUserInputChange(args..), 'Expected');
|
||||
//t.throws(onUserInputChange(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing once', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof once === 'function', 'once is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(once(args..), 'Expected');
|
||||
//t.equal(once(args..), 'Expected');
|
||||
//t.false(once(args..), 'Expected');
|
||||
//t.throws(once(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
2
test/radsToDegrees/radsToDegrees.js
Normal file
2
test/radsToDegrees/radsToDegrees.js
Normal file
@ -0,0 +1,2 @@
|
||||
const radsToDegrees = rad => rad * 180.0 / Math.PI;
|
||||
module.exports = radsToDegrees;
|
||||
14
test/radsToDegrees/radsToDegrees.test.js
Normal file
14
test/radsToDegrees/radsToDegrees.test.js
Normal file
@ -0,0 +1,14 @@
|
||||
const test = require('tape');
|
||||
const radsToDegrees = require('./radsToDegrees.js');
|
||||
|
||||
test('Testing radsToDegrees', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof radsToDegrees === 'function', 'radsToDegrees is a Function');
|
||||
t.equal(radsToDegrees(Math.PI / 2), 90, 'Returns the appropriate value');
|
||||
//t.deepEqual(radsToDegrees(args..), 'Expected');
|
||||
//t.equal(radsToDegrees(args..), 'Expected');
|
||||
//t.false(radsToDegrees(args..), 'Expected');
|
||||
//t.throws(radsToDegrees(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -7,7 +7,9 @@ test('Testing randomHexColorCode', (t) => {
|
||||
t.true(typeof randomHexColorCode === 'function', 'randomHexColorCode is a Function');
|
||||
//t.deepEqual(randomHexColorCode(args..), 'Expected');
|
||||
t.equal(randomHexColorCode().length, 7);
|
||||
t.true(randomHexColorCode().startsWith('#'),'The color code starts with "#"');
|
||||
t.true(randomHexColorCode().slice(1).match(/[^0123456789abcdef]/i) === null,'The color code contains only valid hex-digits');
|
||||
//t.false(randomHexColorCode(args..), 'Expected');
|
||||
//t.throws(randomHexColorCode(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing setStyle', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof setStyle === 'function', 'setStyle is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(setStyle(args..), 'Expected');
|
||||
//t.equal(setStyle(args..), 'Expected');
|
||||
//t.false(setStyle(args..), 'Expected');
|
||||
//t.throws(setStyle(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing show', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof show === 'function', 'show is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(show(args..), 'Expected');
|
||||
//t.equal(show(args..), 'Expected');
|
||||
//t.false(show(args..), 'Expected');
|
||||
//t.throws(show(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,13 @@ test('Testing sleep', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sleep === 'function', 'sleep is a Function');
|
||||
async function sleepyWork() {
|
||||
await sleep(1000);
|
||||
t.pass('Works as expected');
|
||||
}
|
||||
//t.deepEqual(sleep(args..), 'Expected');
|
||||
//t.equal(sleep(args..), 'Expected');
|
||||
//t.false(sleep(args..), 'Expected');
|
||||
//t.throws(sleep(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
6
test/stableSort/stableSort.js
Normal file
6
test/stableSort/stableSort.js
Normal file
@ -0,0 +1,6 @@
|
||||
const stableSort = (arr, compare) =>
|
||||
arr
|
||||
.map((item, index) => ({ item, index }))
|
||||
.sort((a, b) => compare(a.item, b.item) || a.index - b.index)
|
||||
.map(({ item }) => item);
|
||||
module.exports = stableSort;
|
||||
17
test/stableSort/stableSort.test.js
Normal file
17
test/stableSort/stableSort.test.js
Normal file
@ -0,0 +1,17 @@
|
||||
const test = require('tape');
|
||||
const stableSort = require('./stableSort.js');
|
||||
|
||||
test('Testing stableSort', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof stableSort === 'function', 'stableSort is a Function');
|
||||
//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;
|
||||
t.deepEqual(stableSort(arr, compare), arr, 'Array is properly sorted');
|
||||
t.end();
|
||||
});
|
||||
@ -5,9 +5,10 @@ test('Testing throttle', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof throttle === 'function', 'throttle is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(throttle(args..), 'Expected');
|
||||
//t.equal(throttle(args..), 'Expected');
|
||||
//t.false(throttle(args..), 'Expected');
|
||||
//t.throws(throttle(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing timeTaken', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof timeTaken === 'function', 'timeTaken is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(timeTaken(args..), 'Expected');
|
||||
//t.equal(timeTaken(args..), 'Expected');
|
||||
//t.false(timeTaken(args..), 'Expected');
|
||||
//t.throws(timeTaken(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing toggleClass', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof toggleClass === 'function', 'toggleClass is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(toggleClass(args..), 'Expected');
|
||||
//t.equal(toggleClass(args..), 'Expected');
|
||||
//t.false(toggleClass(args..), 'Expected');
|
||||
//t.throws(toggleClass(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
6
test/uncurry/uncurry.js
Normal file
6
test/uncurry/uncurry.js
Normal file
@ -0,0 +1,6 @@
|
||||
const uncurry = (fn, n = 1) => (...args) => {
|
||||
const next = acc => args => args.reduce((x, y) => x(y), acc);
|
||||
if (n > args.length) throw new RangeError('Arguments too few!');
|
||||
return next(fn)(args.slice(0, n));
|
||||
};
|
||||
module.exports = uncurry;
|
||||
20
test/uncurry/uncurry.test.js
Normal file
20
test/uncurry/uncurry.test.js
Normal file
@ -0,0 +1,20 @@
|
||||
const test = require('tape');
|
||||
const uncurry = require('./uncurry.js');
|
||||
|
||||
test('Testing uncurry', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof uncurry === 'function', 'uncurry is a 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');
|
||||
//t.deepEqual(uncurry(args..), 'Expected');
|
||||
//t.equal(uncurry(args..), 'Expected');
|
||||
//t.false(uncurry(args..), 'Expected');
|
||||
//t.throws(uncurry(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user