Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
@ -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",
|
||||
|
||||
8
test/JSONToDate/JSONToDate.test.js
Normal file
8
test/JSONToDate/JSONToDate.test.js
Normal file
@ -0,0 +1,8 @@
|
||||
const expect = require('expect');
|
||||
const JSONToDate = require('./JSONToDate.js');
|
||||
|
||||
|
||||
test('JSONToDate is a Function', () => {
|
||||
expect(JSONToDate).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
10
test/JSONToFile/JSONToFile.test.js
Normal file
10
test/JSONToFile/JSONToFile.test.js
Normal file
@ -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');
|
||||
|
||||
|
||||
9
test/RGBToHex/RGBToHex.test.js
Normal file
9
test/RGBToHex/RGBToHex.test.js
Normal file
@ -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.");
|
||||
|
||||
@ -2,7 +2,7 @@ const URLJoin = (...args) =>
|
||||
args
|
||||
.join('/')
|
||||
.replace(/[\/]+/g, '/')
|
||||
.replace(/^(.+):\//, '$1://')
|
||||
.replace(/^(.+):\
|
||||
.replace(/^file:/, 'file:/')
|
||||
.replace(/\/(\?|&|#[^!])/g, '$1')
|
||||
.replace(/\?/g, '&')
|
||||
11
test/URLJoin/URLJoin.test.js
Normal file
11
test/URLJoin/URLJoin.test.js
Normal file
@ -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:
|
||||
|
||||
|
||||
10
test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js
Normal file
10
test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js
Normal file
@ -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');
|
||||
|
||||
|
||||
14
test/UUIDGeneratorNode/UUIDGeneratorNode.test.js
Normal file
14
test/UUIDGeneratorNode/UUIDGeneratorNode.test.js
Normal file
@ -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();
|
||||
});
|
||||
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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()
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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()
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -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()
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@ -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()
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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()
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
});
|
||||
|
||||
|
||||
@ -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');
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@ -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');
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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");
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ cleanObj(obj[key], keysToKeep, childIndicator);
|
||||
} else if (!keysToKeep.includes(key)) {
|
||||
delete obj[key];
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
module.exports = cleanObj;
|
||||
@ -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}});
|
||||
});
|
||||
t.deepEqual(cleanObj(testObj, ['a'], 'children'), { a: 1, children : { a: 1}}, "Removes any properties except the ones specified from a JSON object");
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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('');
|
||||
});
|
||||
|
||||
test('coalesce is a Function', () => {
|
||||
expect(coalesce).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(coalesce(null, undefined, '', NaN, 'Waldo'), '', "Returns the first non-null/undefined argument");
|
||||
|
||||
|
||||
@ -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');
|
||||
});
|
||||
t.deepEqual(customCoalesce(undefined, null, NaN, '', 'Waldo'), 'Waldo', "Returns a customized coalesce function");
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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){
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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 ]);
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
t.equal(multiplyAndAdd5(5, 2), 15, "Performs right-to-left function composition");
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
test('countVowels is a Function', () => {
|
||||
expect(countVowels).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
test('counter is a Function', () => {
|
||||
expect(counter).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
|
||||
@ -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]);
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
|
||||
10
test/defaults/defaults.test.js
Normal file
10
test/defaults/defaults.test.js
Normal file
@ -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');
|
||||
|
||||
|
||||
10
test/defer/defer.test.js
Normal file
10
test/defer/defer.test.js
Normal file
@ -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');
|
||||
|
||||
|
||||
13
test/degreesToRads/degreesToRads.test.js
Normal file
13
test/degreesToRads/degreesToRads.test.js
Normal file
@ -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();
|
||||
});
|
||||
|
||||
|
||||
18
test/delay/delay.test.js
Normal file
18
test/delay/delay.test.js
Normal file
@ -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'
|
||||
);
|
||||
|
||||
|
||||
10
test/detectDeviceType/detectDeviceType.test.js
Normal file
10
test/detectDeviceType/detectDeviceType.test.js
Normal file
@ -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');
|
||||
|
||||
|
||||
9
test/difference/difference.test.js
Normal file
9
test/difference/difference.test.js
Normal file
@ -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");
|
||||
|
||||
11
test/differenceBy/differenceBy.test.js
Normal file
11
test/differenceBy/differenceBy.test.js
Normal file
@ -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');
|
||||
|
||||
|
||||
9
test/differenceWith/differenceWith.test.js
Normal file
9
test/differenceWith/differenceWith.test.js
Normal file
@ -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");
|
||||
|
||||
9
test/digitize/digitize.test.js
Normal file
9
test/digitize/digitize.test.js
Normal file
@ -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");
|
||||
|
||||
12
test/distance/distance.test.js
Normal file
12
test/distance/distance.test.js
Normal file
@ -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()
|
||||
});
|
||||
|
||||
|
||||
12
test/drop/drop.test.js
Normal file
12
test/drop/drop.test.js
Normal file
@ -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');
|
||||
|
||||
|
||||
11
test/dropRight/dropRight.test.js
Normal file
11
test/dropRight/dropRight.test.js
Normal file
@ -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");
|
||||
|
||||
10
test/dropRightWhile/dropRightWhile.test.js
Normal file
10
test/dropRightWhile/dropRightWhile.test.js
Normal file
@ -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.');
|
||||
|
||||
|
||||
10
test/dropWhile/dropWhile.test.js
Normal file
10
test/dropWhile/dropWhile.test.js
Normal file
@ -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.');
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
11
test/elo/elo.test.js
Normal file
11
test/elo/elo.test.js
Normal file
@ -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");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user