Migrated tests to jest
Used jest-codemods to migrate, will have to pass everything by hand before we can merge.
This commit is contained in:
3656
package-lock.json
generated
3656
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@
|
||||
"chalk": "^2.4.1",
|
||||
"fs-extra": "^6.0.0",
|
||||
"html-minifier": "^3.5.15",
|
||||
"jest": "^23.1.0",
|
||||
"jsdom": "^11.10.0",
|
||||
"markdown-it": "^8.4.1",
|
||||
"mini.css": "^2.3.7",
|
||||
@ -32,7 +33,8 @@
|
||||
"extractor": "node ./scripts/extract.js",
|
||||
"packager": "node ./scripts/module.js",
|
||||
"localizer": "node ./scripts/localize.js",
|
||||
"test": "tape test/**/*.test.js | tap-spec"
|
||||
"test": "tape test/**/*.test.js | tap-spec",
|
||||
"test2": "jest ./jesttest/**/*.test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
const test = require('tape');
|
||||
const JSONToDate = require('./JSONToDate.js');
|
||||
|
||||
test('Testing JSONToDate', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof JSONToDate === 'function', 'JSONToDate is a Function');
|
||||
//t.deepEqual(JSONToDate(args..), 'Expected');
|
||||
//t.equal(JSONToDate(args..), 'Expected');
|
||||
//t.false(JSONToDate(args..), 'Expected');
|
||||
//t.throws(JSONToDate(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const JSONToFile = require('./JSONToFile.js');
|
||||
|
||||
test('Testing JSONToFile', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof JSONToFile === 'function', 'JSONToFile is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(JSONToFile(args..), 'Expected');
|
||||
//t.equal(JSONToFile(args..), 'Expected');
|
||||
//t.false(JSONToFile(args..), 'Expected');
|
||||
//t.throws(JSONToFile(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const RGBToHex = require('./RGBToHex.js');
|
||||
|
||||
test('Testing RGBToHex', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof RGBToHex === 'function', 'RGBToHex is a Function');
|
||||
t.equal(RGBToHex(255, 165, 1), 'ffa501', "Converts the values of RGB components to a color code.");
|
||||
//t.deepEqual(RGBToHex(args..), 'Expected');
|
||||
//t.equal(RGBToHex(args..), 'Expected');
|
||||
//t.false(RGBToHex(args..), 'Expected');
|
||||
//t.throws(RGBToHex(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
const test = require('tape');
|
||||
const URLJoin = require('./URLJoin.js');
|
||||
|
||||
test('Testing URLJoin', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof URLJoin === 'function', 'URLJoin is a Function');
|
||||
t.equal(URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'), 'http://www.google.com/a/b/cd?foo=123&bar=foo', 'Returns proper URL');
|
||||
t.equal(URLJoin('file://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'), 'file:///www.google.com/a/b/cd?foo=123&bar=foo', 'Returns proper URL');
|
||||
//t.deepEqual(URLJoin(args..), 'Expected');
|
||||
//t.equal(URLJoin(args..), 'Expected');
|
||||
//t.false(URLJoin(args..), 'Expected');
|
||||
//t.throws(URLJoin(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const UUIDGeneratorBrowser = require('./UUIDGeneratorBrowser.js');
|
||||
|
||||
test('Testing UUIDGeneratorBrowser', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof UUIDGeneratorBrowser === 'function', 'UUIDGeneratorBrowser is a Function');
|
||||
t.pass('Tested 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
//t.equal(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
//t.false(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
//t.throws(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const UUIDGeneratorNode = require('./UUIDGeneratorNode.js');
|
||||
|
||||
test('Testing UUIDGeneratorNode', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof UUIDGeneratorNode === 'function', 'UUIDGeneratorNode is a Function');
|
||||
const uuid = UUIDGeneratorNode();
|
||||
t.deepEqual([uuid[8], uuid[13], uuid[18], uuid[23]], ['-', '-', '-', '-'], 'Contains dashes in the proper places');
|
||||
t.true(/^[0-9A-Fa-f-]+$/.test(uuid), 'Only contains hexadecimal digits');
|
||||
//t.deepEqual(UUIDGeneratorNode(args..), 'Expected');
|
||||
//t.equal(UUIDGeneratorNode(args..), 'Expected');
|
||||
//t.false(UUIDGeneratorNode(args..), 'Expected');
|
||||
//t.throws(UUIDGeneratorNode(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,21 +1,16 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const all = require('./all.js');
|
||||
|
||||
test('Testing all', (t) => {
|
||||
test('Testing all', () => {
|
||||
//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();
|
||||
expect(typeof all === 'function').toBeTruthy();
|
||||
expect(all([4,1,2,3])).toBeTruthy();
|
||||
expect(all([0,1])).toBeFalsy();
|
||||
expect(all([NaN,1])).toBeFalsy();
|
||||
expect(all([undefined,1])).toBeFalsy();
|
||||
expect(all([null,1])).toBeFalsy();
|
||||
expect(all(['',1])).toBeFalsy();
|
||||
expect(all([4,1,2,3], x => x >= 1)).toBeTruthy();
|
||||
expect(all([0,1], x => x >= 1)).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -1,18 +1,13 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const any = require('./any.js');
|
||||
|
||||
test('Testing any', (t) => {
|
||||
test('Testing any', () => {
|
||||
//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();
|
||||
expect(typeof any === 'function').toBeTruthy();
|
||||
expect(any([0,1,2,3])).toBeTruthy();
|
||||
expect(any([0,0])).toBeFalsy();
|
||||
expect(any([NaN,0,undefined,null,''])).toBeFalsy();
|
||||
expect(any([4,1,0,3], x => x >= 1)).toBeTruthy();
|
||||
expect(any([0,1], x => x < 0)).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -1,17 +1,12 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const approximatelyEqual = require('./approximatelyEqual.js');
|
||||
|
||||
test('Testing approximatelyEqual', (t) => {
|
||||
test('Testing approximatelyEqual', () => {
|
||||
//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();
|
||||
expect(typeof approximatelyEqual === 'function').toBeTruthy();
|
||||
expect(approximatelyEqual(Math.PI / 2.0 , 1.5708)).toBeTruthy();
|
||||
expect(approximatelyEqual(0.1 + 0.2, 0.3)).toBeTruthy();
|
||||
expect(approximatelyEqual(0.5, 0.5)).toBeTruthy();
|
||||
expect(approximatelyEqual(0.501, 0.5, 0.1)).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const arrayToHtmlList = require('./arrayToHtmlList.js');
|
||||
|
||||
test('Testing arrayToHtmlList', (t) => {
|
||||
test('Testing arrayToHtmlList', () => {
|
||||
//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();
|
||||
expect(typeof arrayToHtmlList === 'function').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const ary = require('./ary.js');
|
||||
|
||||
test('Testing ary', (t) => {
|
||||
test('Testing ary', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof ary === 'function', 'ary is a Function');
|
||||
expect(typeof ary === 'function').toBeTruthy();
|
||||
const firstTwoMax = ary(Math.max, 2);
|
||||
t.deepEquals([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)), [6, 8, 10], 'Discards arguments with index >=n');
|
||||
//t.deepEqual(ary(args..), 'Expected');
|
||||
//t.equal(ary(args..), 'Expected');
|
||||
//t.false(ary(args..), 'Expected');
|
||||
//t.throws(ary(args..), 'Expected');
|
||||
t.end();
|
||||
expect([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x))).toEqual([6, 8, 10]);
|
||||
});
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const atob = require('./atob.js');
|
||||
|
||||
test('Testing atob', (t) => {
|
||||
test('Testing atob', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof atob === 'function', 'atob is a Function');
|
||||
t.equals(atob('Zm9vYmFy'), 'foobar', 'atob("Zm9vYmFy") equals "foobar"');
|
||||
t.equals(atob('Z'), '', 'atob("Z") returns ""');
|
||||
//t.deepEqual(atob(args..), 'Expected');
|
||||
//t.equal(atob(args..), 'Expected');
|
||||
//t.false(atob(args..), 'Expected');
|
||||
//t.throws(atob(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof atob === 'function').toBeTruthy();
|
||||
expect(atob('Zm9vYmFy')).toBe('foobar');
|
||||
expect(atob('Z')).toBe('');
|
||||
});
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const attempt = require('./attempt.js');
|
||||
|
||||
test('Testing attempt', (t) => {
|
||||
test('Testing attempt', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof attempt === 'function', 'attempt is a Function');
|
||||
t.equals(attempt(() => 0), 0, 'Returns a value');
|
||||
t.true(attempt(() => {throw new Error();}) instanceof Error, 'Returns an error');
|
||||
//t.deepEqual(attempt(args..), 'Expected');
|
||||
//t.equal(attempt(args..), 'Expected');
|
||||
//t.false(attempt(args..), 'Expected');
|
||||
//t.throws(attempt(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof attempt === 'function').toBeTruthy();
|
||||
expect(attempt(() => 0)).toBe(0);
|
||||
expect(attempt(() => {throw new Error();}) instanceof Error).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,24 +1,23 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const average = require('./average.js');
|
||||
|
||||
test('Testing average', (t) => {
|
||||
test('Testing average', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof average === 'function', 'average is a Function');
|
||||
t.true(average(true) === 1, 'average(true) returns 0');
|
||||
t.true(average(false) === 0, 'average(false) returns 1');
|
||||
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');
|
||||
t.true(isNaN(average(undefined)), 'average(1, 2, 3) returns NaN');
|
||||
t.true(isNaN(average('String')), 'average(String) returns NaN');
|
||||
t.true(isNaN(average({ a: 123})), 'average({ a: 123}) returns NaN');
|
||||
t.true(isNaN(average([undefined, 0, 'string'])), 'average([undefined, 0, string]) returns NaN');
|
||||
expect(typeof average === 'function').toBeTruthy();
|
||||
expect(average(true) === 1).toBeTruthy();
|
||||
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);
|
||||
expect(isNaN(average(undefined))).toBeTruthy();
|
||||
expect(isNaN(average('String'))).toBeTruthy();
|
||||
expect(isNaN(average({ a: 123}))).toBeTruthy();
|
||||
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();
|
||||
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();
|
||||
let end = new Date().getTime();
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const averageBy = require('./averageBy.js');
|
||||
|
||||
test('Testing averageBy', (t) => {
|
||||
test('Testing averageBy', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof averageBy === 'function', 'averageBy is a Function');
|
||||
t.equals(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 5, 'Produces the right result with a function');
|
||||
t.equals(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 5, 'Produces the right result with a property name');
|
||||
//t.deepEqual(averageBy(args..), 'Expected');
|
||||
//t.equal(averageBy(args..), 'Expected');
|
||||
//t.false(averageBy(args..), 'Expected');
|
||||
//t.throws(averageBy(args..), 'Expected');
|
||||
t.end();
|
||||
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);
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const bifurcate = require('./bifurcate.js');
|
||||
|
||||
test('Testing bifurcate', (t) => {
|
||||
test('Testing bifurcate', () => {
|
||||
//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();
|
||||
expect(typeof bifurcate === 'function').toBeTruthy();
|
||||
expect(bifurcate([ 'beep', 'boop', 'foo', 'bar' ], [ true, true, false, true ])).toEqual([ ['beep', 'boop', 'bar'], ['foo'] ]);
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const bifurcateBy = require('./bifurcateBy.js');
|
||||
|
||||
test('Testing bifurcateBy', (t) => {
|
||||
test('Testing bifurcateBy', () => {
|
||||
//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();
|
||||
expect(typeof bifurcateBy === 'function').toBeTruthy();
|
||||
expect(bifurcateBy([ 'beep', 'boop', 'foo', 'bar' ], x => x[0] === 'b')).toEqual([ ['beep', 'boop', 'bar'], ['foo'] ]);
|
||||
});
|
||||
|
||||
@ -1,16 +1,13 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const binarySearch = require('./binarySearch.js');
|
||||
|
||||
test('Testing binarySearch', (t) => {
|
||||
test('Testing binarySearch', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof binarySearch === 'function', 'binarySearch is a Function');
|
||||
expect(typeof binarySearch === 'function').toBeTruthy();
|
||||
//t.deepEqual(binarySearch(args..), 'Expected');
|
||||
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");
|
||||
//t.false(binarySearch(args..), 'Expected');
|
||||
//t.throws(binarySearch(args..), 'Expected');
|
||||
t.end();
|
||||
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);
|
||||
});
|
||||
@ -1,19 +1,14 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const bind = require('./bind.js');
|
||||
|
||||
test('Testing bind', (t) => {
|
||||
test('Testing bind', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof bind === 'function', 'bind is a Function');
|
||||
expect(typeof bind === 'function').toBeTruthy();
|
||||
function greet(greeting, punctuation) {
|
||||
return greeting + ' ' + this.user + punctuation;
|
||||
}
|
||||
const freddy = { user: 'fred' };
|
||||
const freddyBound = bind(greet, freddy);
|
||||
t.equals(freddyBound('hi', '!'),'hi fred!', 'Binds to an object context');
|
||||
//t.deepEqual(bind(args..), 'Expected');
|
||||
//t.equal(bind(args..), 'Expected');
|
||||
//t.false(bind(args..), 'Expected');
|
||||
//t.throws(bind(args..), 'Expected');
|
||||
t.end();
|
||||
expect(freddyBound('hi', '!')).toBe('hi fred!');
|
||||
});
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const bindAll = require('./bindAll.js');
|
||||
|
||||
test('Testing bindAll', (t) => {
|
||||
test('Testing bindAll', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof bindAll === 'function', 'bindAll is a Function');
|
||||
expect(typeof bindAll === 'function').toBeTruthy();
|
||||
var view = {
|
||||
label: 'docs',
|
||||
'click': function() {
|
||||
@ -12,10 +12,5 @@ test('Testing bindAll', (t) => {
|
||||
}
|
||||
};
|
||||
bindAll(view, 'click');
|
||||
t.equal(view.click(), 'clicked docs', 'Binds to an object context');
|
||||
//t.deepEqual(bindAll(args..), 'Expected');
|
||||
//t.equal(bindAll(args..), 'Expected');
|
||||
//t.false(bindAll(args..), 'Expected');
|
||||
//t.throws(bindAll(args..), 'Expected');
|
||||
t.end();
|
||||
expect(view.click()).toBe('clicked docs');
|
||||
});
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const bindKey = require('./bindKey.js');
|
||||
|
||||
test('Testing bindKey', (t) => {
|
||||
test('Testing bindKey', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof bindKey === 'function', 'bindKey is a Function');
|
||||
expect(typeof bindKey === 'function').toBeTruthy();
|
||||
const freddy = {
|
||||
user: 'fred',
|
||||
greet: function(greeting, punctuation) {
|
||||
@ -12,10 +12,5 @@ test('Testing bindKey', (t) => {
|
||||
}
|
||||
};
|
||||
const freddyBound = bindKey(freddy, 'greet');
|
||||
t.equal(freddyBound('hi', '!'), 'hi fred!', 'Binds function to an object context');
|
||||
//t.deepEqual(bindKey(args..), 'Expected');
|
||||
//t.equal(bindKey(args..), 'Expected');
|
||||
//t.false(bindKey(args..), 'Expected');
|
||||
//t.throws(bindKey(args..), 'Expected');
|
||||
t.end();
|
||||
expect(freddyBound('hi', '!')).toBe('hi fred!');
|
||||
});
|
||||
|
||||
@ -1,18 +1,13 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const binomialCoefficient = require('./binomialCoefficient.js');
|
||||
|
||||
test('Testing binomialCoefficient', (t) => {
|
||||
test('Testing binomialCoefficient', () => {
|
||||
//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();
|
||||
expect(typeof binomialCoefficient === 'function').toBeTruthy();
|
||||
expect(binomialCoefficient(8, 2)).toBe(28);
|
||||
expect(binomialCoefficient(0, 0)).toBe(1);
|
||||
expect(binomialCoefficient(5, 3)).toBe(10);
|
||||
expect(Number.isNaN(binomialCoefficient(NaN, 3))).toBeTruthy();
|
||||
expect(Number.isNaN(binomialCoefficient(5, NaN))).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const bottomVisible = require('./bottomVisible.js');
|
||||
|
||||
test('Testing bottomVisible', (t) => {
|
||||
test('Testing bottomVisible', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof bottomVisible === 'function', 'bottomVisible is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(bottomVisible(args..), 'Expected');
|
||||
//t.equal(bottomVisible(args..), 'Expected');
|
||||
//t.false(bottomVisible(args..), 'Expected');
|
||||
//t.throws(bottomVisible(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof bottomVisible === 'function').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const btoa = require('./btoa.js');
|
||||
|
||||
test('Testing btoa', (t) => {
|
||||
test('Testing btoa', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof btoa === 'function', 'btoa is a Function');
|
||||
t.equals(btoa('foobar'), 'Zm9vYmFy', 'btoa("foobar") equals "Zm9vYmFy"');
|
||||
//t.deepEqual(btoa(args..), 'Expected');
|
||||
//t.equal(btoa(args..), 'Expected');
|
||||
//t.false(btoa(args..), 'Expected');
|
||||
//t.throws(btoa(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof btoa === 'function').toBeTruthy();
|
||||
expect(btoa('foobar')).toBe('Zm9vYmFy');
|
||||
});
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const test = require('tape');
|
||||
// Custom implementation of Blob for the requirements of this snippet.
|
||||
import expect from 'expect';
|
||||
const Blob = class{
|
||||
constructor(s) {
|
||||
return {
|
||||
@ -10,21 +9,11 @@ const Blob = class{
|
||||
// const byteSize = require('./byteSize.js');
|
||||
// Override
|
||||
const byteSize = str => new Blob([str]).size;
|
||||
test('Testing byteSize', (t) => {
|
||||
test('Testing byteSize', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof byteSize === 'function', 'byteSize is a 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');
|
||||
// Blob is not part of Node apparently?
|
||||
//t.equal(byteSize('Hello World'), 11, 'Works for text');
|
||||
//t.equal(byteSize('😀'), 4, 'Works for emojis');
|
||||
// Works only in browser
|
||||
// t.equal(byteSize('Hello World'), 11, "Returns the length of a string in bytes");
|
||||
//t.deepEqual(byteSize(args..), 'Expected');
|
||||
//t.equal(byteSize(args..), 'Expected');
|
||||
//t.false(byteSize(args..), 'Expected');
|
||||
//t.throws(byteSize(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof byteSize === 'function').toBeTruthy();
|
||||
expect(byteSize('a')).toBe(1);
|
||||
expect(byteSize('Hello World')).toBe(11);
|
||||
expect(byteSize('😀')).toBe(4);
|
||||
});
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const call = require('./call.js');
|
||||
|
||||
test('Testing call', (t) => {
|
||||
test('Testing call', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof call === 'function', 'call is a Function');
|
||||
expect(typeof call === 'function').toBeTruthy();
|
||||
//t.deepEqual(call(args..), 'Expected');
|
||||
t.looseEqual(call('map', x => x * 2)([1, 2, 3]), [2, 4, 6], 'Calls function on given object');
|
||||
//t.false(call(args..), 'Expected');
|
||||
//t.throws(call(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,17 +1,12 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const capitalize = require('./capitalize.js');
|
||||
|
||||
test('Testing capitalize', (t) => {
|
||||
test('Testing capitalize', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof capitalize === 'function', 'capitalize is a 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");
|
||||
//t.deepEqual(capitalize(args..), 'Expected');
|
||||
//t.equal(capitalize(args..), 'Expected');
|
||||
//t.false(capitalize(args..), 'Expected');
|
||||
//t.throws(capitalize(args..), 'Expected');
|
||||
t.end();
|
||||
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');
|
||||
});
|
||||
@ -1,16 +1,11 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const capitalizeEveryWord = require('./capitalizeEveryWord.js');
|
||||
|
||||
test('Testing capitalizeEveryWord', (t) => {
|
||||
test('Testing capitalizeEveryWord', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof capitalizeEveryWord === 'function', 'capitalizeEveryWord is a 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");
|
||||
//t.deepEqual(capitalizeEveryWord(args..), 'Expected');
|
||||
//t.equal(capitalizeEveryWord(args..), 'Expected');
|
||||
//t.false(capitalizeEveryWord(args..), 'Expected');
|
||||
//t.throws(capitalizeEveryWord(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof capitalizeEveryWord === 'function').toBeTruthy();
|
||||
expect(capitalizeEveryWord('hello world!')).toBe('Hello World!');
|
||||
expect(capitalizeEveryWord('$# @!')).toBe('$# @!');
|
||||
expect(capitalizeEveryWord('a')).toBe('A');
|
||||
});
|
||||
@ -1,18 +1,13 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const castArray = require('./castArray.js');
|
||||
|
||||
test('Testing castArray', (t) => {
|
||||
test('Testing castArray', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof castArray === 'function', 'castArray is a 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');
|
||||
//t.deepEqual(castArray(args..), 'Expected');
|
||||
//t.equal(castArray(args..), 'Expected');
|
||||
//t.false(castArray(args..), 'Expected');
|
||||
//t.throws(castArray(args..), 'Expected');
|
||||
t.end();
|
||||
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([{}]);
|
||||
});
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const chainAsync = require('./chainAsync.js');
|
||||
|
||||
test('Testing chainAsync', (t) => {
|
||||
test('Testing chainAsync', () => {
|
||||
//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');
|
||||
expect(typeof chainAsync === 'function').toBeTruthy();
|
||||
chainAsync([
|
||||
next => {
|
||||
next();
|
||||
@ -14,14 +14,6 @@ test('Testing chainAsync', (t) => {
|
||||
next();
|
||||
})();
|
||||
},
|
||||
next => {
|
||||
t.pass("Calls all functions in an array");
|
||||
}
|
||||
next => {}
|
||||
]);
|
||||
// // Ensure we wait for the 2nd assertion to be made
|
||||
// t.plan(2);
|
||||
|
||||
//t.false(chainAsync(args..), 'Expected');
|
||||
//t.throws(chainAsync(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
|
||||
@ -1,22 +1,21 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const chunk = require('./chunk.js');
|
||||
|
||||
test('Testing chunk', (t) => {
|
||||
test('Testing chunk', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof chunk === 'function', 'chunk is a 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');
|
||||
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();
|
||||
|
||||
let start = new Date().getTime();
|
||||
chunk('This is a string', 2);
|
||||
let end = new Date().getTime();
|
||||
t.true((end - start) < 2000, 'chunk(This is a string, 2) takes less than 2s to run');
|
||||
t.end();
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const clampNumber = require('./clampNumber.js');
|
||||
|
||||
test('Testing clampNumber', (t) => {
|
||||
test('Testing clampNumber', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof clampNumber === 'function', 'clampNumber is a Function');
|
||||
t.equal(clampNumber(2, 3, 5), 3, "Clamps num within the inclusive range specified by the boundary values a and b");
|
||||
//t.deepEqual(clampNumber(args..), 'Expected');
|
||||
//t.equal(clampNumber(args..), 'Expected');
|
||||
//t.false(clampNumber(args..), 'Expected');
|
||||
//t.throws(clampNumber(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof clampNumber === 'function').toBeTruthy();
|
||||
expect(clampNumber(2, 3, 5)).toBe(3);
|
||||
});
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const cleanObj = require('./cleanObj.js');
|
||||
|
||||
test('Testing cleanObj', (t) => {
|
||||
test('Testing cleanObj', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof cleanObj === 'function', 'cleanObj is a Function');
|
||||
expect(typeof cleanObj === 'function').toBeTruthy();
|
||||
const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } };
|
||||
t.deepEqual(cleanObj(testObj, ['a'], 'children'), { a: 1, children : { a: 1}}, "Removes any properties except the ones specified from a JSON object");
|
||||
//t.deepEqual(cleanObj(args..), 'Expected');
|
||||
//t.equal(cleanObj(args..), 'Expected');
|
||||
//t.false(cleanObj(args..), 'Expected');
|
||||
//t.throws(cleanObj(args..), 'Expected');
|
||||
t.end();
|
||||
expect(cleanObj(testObj, ['a'], 'children')).toEqual({ a: 1, children : { a: 1}});
|
||||
});
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const cloneRegExp = require('./cloneRegExp.js');
|
||||
|
||||
test('Testing cloneRegExp', (t) => {
|
||||
test('Testing cloneRegExp', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof cloneRegExp === 'function', 'cloneRegExp is a Function');
|
||||
expect(typeof cloneRegExp === 'function').toBeTruthy();
|
||||
const rgTest = /./g;
|
||||
t.notEqual(cloneRegExp(rgTest), rgTest, 'Clones regular expressions properly');
|
||||
//t.deepEqual(cloneRegExp(args..), 'Expected');
|
||||
//t.equal(cloneRegExp(args..), 'Expected');
|
||||
//t.false(cloneRegExp(args..), 'Expected');
|
||||
//t.throws(cloneRegExp(args..), 'Expected');
|
||||
t.end();
|
||||
expect(cloneRegExp(rgTest)).not.toBe(rgTest);
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const coalesce = require('./coalesce.js');
|
||||
|
||||
test('Testing coalesce', (t) => {
|
||||
test('Testing coalesce', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof coalesce === 'function', 'coalesce is a Function');
|
||||
t.deepEqual(coalesce(null, undefined, '', NaN, 'Waldo'), '', "Returns the first non-null/undefined argument");
|
||||
//t.deepEqual(coalesce(args..), 'Expected');
|
||||
//t.equal(coalesce(args..), 'Expected');
|
||||
//t.false(coalesce(args..), 'Expected');
|
||||
//t.throws(coalesce(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof coalesce === 'function').toBeTruthy();
|
||||
expect(coalesce(null, undefined, '', NaN, 'Waldo')).toEqual('');
|
||||
});
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const coalesceFactory = require('./coalesceFactory.js');
|
||||
|
||||
test('Testing coalesceFactory', (t) => {
|
||||
test('Testing coalesceFactory', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof coalesceFactory === 'function', 'coalesceFactory is a Function');
|
||||
expect(typeof coalesceFactory === 'function').toBeTruthy();
|
||||
const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_));
|
||||
t.deepEqual(customCoalesce(undefined, null, NaN, '', 'Waldo'), 'Waldo', "Returns a customized coalesce function");
|
||||
//t.deepEqual(coalesceFactory(args..), 'Expected');
|
||||
//t.equal(coalesceFactory(args..), 'Expected');
|
||||
//t.false(coalesceFactory(args..), 'Expected');
|
||||
//t.throws(coalesceFactory(args..), 'Expected');
|
||||
t.end();
|
||||
expect(customCoalesce(undefined, null, NaN, '', 'Waldo')).toEqual('Waldo');
|
||||
});
|
||||
@ -1,24 +1,19 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const collatz = require('./collatz.js');
|
||||
|
||||
test('Testing collatz', (t) => {
|
||||
test('Testing collatz', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof collatz === 'function', 'collatz is a Function');
|
||||
expect(typeof collatz === 'function').toBeTruthy();
|
||||
//t.deepEqual(collatz(args..), 'Expected');
|
||||
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');
|
||||
expect(collatz(8)).toBe(4);
|
||||
expect(collatz(9)).toBe(28);
|
||||
|
||||
let n = 9;
|
||||
while(true){
|
||||
if (n === 1){
|
||||
t.pass('Eventually reaches 1');
|
||||
break;
|
||||
}
|
||||
n = collatz(n);
|
||||
}
|
||||
|
||||
//t.false(collatz(args..), 'Expected');
|
||||
//t.throws(collatz(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
|
||||
@ -1,18 +1,13 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const collectInto = require('./collectInto.js');
|
||||
|
||||
test('Testing collectInto', (t) => {
|
||||
test('Testing collectInto', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof collectInto === 'function', 'collectInto is a Function');
|
||||
expect(typeof collectInto === 'function').toBeTruthy();
|
||||
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){ t.deepEqual(val, [1,2,3], 'Works with multiple promises');}, function(reason){});
|
||||
//t.deepEqual(collectInto(args..), 'Expected');
|
||||
//t.equal(collectInto(args..), 'Expected');
|
||||
//t.false(collectInto(args..), 'Expected');
|
||||
//t.throws(collectInto(args..), 'Expected');
|
||||
t.end();
|
||||
Pall(p1, p2, p3).then(function(val){ expect(val).toEqual([1,2,3]);}, function(reason){});
|
||||
});
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const colorize = require('./colorize.js');
|
||||
|
||||
test('Testing colorize', (t) => {
|
||||
test('Testing colorize', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof colorize === 'function', 'colorize is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(colorize(args..), 'Expected');
|
||||
//t.equal(colorize(args..), 'Expected');
|
||||
//t.false(colorize(args..), 'Expected');
|
||||
//t.throws(colorize(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof colorize === 'function').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const compact = require('./compact.js');
|
||||
|
||||
test('Testing compact', (t) => {
|
||||
test('Testing compact', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof compact === 'function', 'compact is a 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");
|
||||
//t.deepEqual(compact(args..), 'Expected');
|
||||
//t.equal(compact(args..), 'Expected');
|
||||
//t.false(compact(args..), 'Expected');
|
||||
//t.throws(compact(args..), 'Expected');
|
||||
t.end();
|
||||
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 ]);
|
||||
});
|
||||
@ -1,17 +1,12 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const compose = require('./compose.js');
|
||||
|
||||
test('Testing compose', (t) => {
|
||||
test('Testing compose', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof compose === 'function', 'compose is a Function');
|
||||
expect(typeof compose === 'function').toBeTruthy();
|
||||
const add5 = x => x + 5;
|
||||
const multiply = (x, y) => x * y;
|
||||
const multiplyAndAdd5 = compose(add5, multiply);
|
||||
t.equal(multiplyAndAdd5(5, 2), 15, "Performs right-to-left function composition");
|
||||
//t.deepEqual(compose(args..), 'Expected');
|
||||
//t.equal(compose(args..), 'Expected');
|
||||
//t.false(compose(args..), 'Expected');
|
||||
//t.throws(compose(args..), 'Expected');
|
||||
t.end();
|
||||
expect(multiplyAndAdd5(5, 2)).toBe(15);
|
||||
});
|
||||
@ -1,17 +1,12 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const composeRight = require('./composeRight.js');
|
||||
|
||||
test('Testing composeRight', (t) => {
|
||||
test('Testing composeRight', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof composeRight === 'function', 'composeRight is a Function');
|
||||
expect(typeof composeRight === 'function').toBeTruthy();
|
||||
const add = (x, y) => x + y;
|
||||
const square = x => x * x;
|
||||
const addAndSquare = composeRight(add, square);
|
||||
t.equal(addAndSquare(1, 2), 9, "Performs left-to-right function composition");
|
||||
//t.deepEqual(composeRight(args..), 'Expected');
|
||||
//t.equal(composeRight(args..), 'Expected');
|
||||
//t.false(composeRight(args..), 'Expected');
|
||||
//t.throws(composeRight(args..), 'Expected');
|
||||
t.end();
|
||||
expect(addAndSquare(1, 2)).toBe(9);
|
||||
});
|
||||
|
||||
@ -1,23 +1,18 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const converge = require('./converge.js');
|
||||
|
||||
test('Testing converge', (t) => {
|
||||
test('Testing converge', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof converge === 'function', 'converge is a Function');
|
||||
expect(typeof converge === 'function').toBeTruthy();
|
||||
const average = converge((a, b) => a / b, [
|
||||
arr => arr.reduce((a, v) => a + v, 0),
|
||||
arr => arr.length,
|
||||
]);
|
||||
t.equal(average([1, 2, 3, 4, 5, 6, 7]), 4, 'Produces the average of the array');
|
||||
expect(average([1, 2, 3, 4, 5, 6, 7])).toBe(4);
|
||||
const strangeConcat = converge((a, b) => a + b, [
|
||||
x => x.toUpperCase(),
|
||||
x => x.toLowerCase()]
|
||||
);
|
||||
t.equal(strangeConcat('Yodel'), "YODELyodel", 'Produces the strange concatenation');
|
||||
//t.deepEqual(converge(args..), 'Expected');
|
||||
//t.equal(converge(args..), 'Expected');
|
||||
//t.false(converge(args..), 'Expected');
|
||||
//t.throws(converge(args..), 'Expected');
|
||||
t.end();
|
||||
expect(strangeConcat('Yodel')).toBe("YODELyodel");
|
||||
});
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const copyToClipboard = require('./copyToClipboard.js');
|
||||
|
||||
test('Testing copyToClipboard', (t) => {
|
||||
test('Testing copyToClipboard', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof copyToClipboard === 'function', 'copyToClipboard is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(copyToClipboard(args..), 'Expected');
|
||||
//t.equal(copyToClipboard(args..), 'Expected');
|
||||
//t.false(copyToClipboard(args..), 'Expected');
|
||||
//t.throws(copyToClipboard(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof copyToClipboard === 'function').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const countBy = require('./countBy.js');
|
||||
|
||||
test('Testing countBy', (t) => {
|
||||
test('Testing countBy', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof countBy === 'function', 'countBy is a 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');
|
||||
//t.deepEqual(countBy(args..), 'Expected');
|
||||
//t.equal(countBy(args..), 'Expected');
|
||||
//t.false(countBy(args..), 'Expected');
|
||||
//t.throws(countBy(args..), 'Expected');
|
||||
t.end();
|
||||
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});
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const countOccurrences = require('./countOccurrences.js');
|
||||
|
||||
test('Testing countOccurrences', (t) => {
|
||||
test('Testing countOccurrences', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof countOccurrences === 'function', 'countOccurrences is a Function');
|
||||
t.deepEqual(countOccurrences([1, 1, 2, 1, 2, 3], 1), 3, "Counts the occurrences of a value in an array");
|
||||
//t.deepEqual(countOccurrences(args..), 'Expected');
|
||||
//t.equal(countOccurrences(args..), 'Expected');
|
||||
//t.false(countOccurrences(args..), 'Expected');
|
||||
//t.throws(countOccurrences(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof countOccurrences === 'function').toBeTruthy();
|
||||
expect(countOccurrences([1, 1, 2, 1, 2, 3], 1)).toEqual(3);
|
||||
});
|
||||
@ -1,13 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const countVowels = require('./countVowels.js');
|
||||
|
||||
test('Testing countVowels', (t) => {
|
||||
test('Testing countVowels', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof countVowels === 'function', 'countVowels is a Function');
|
||||
//t.deepEqual(countVowels(args..), 'Expected');
|
||||
//t.equal(countVowels(args..), 'Expected');
|
||||
//t.false(countVowels(args..), 'Expected');
|
||||
//t.throws(countVowels(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof countVowels === 'function').toBeTruthy();
|
||||
});
|
||||
@ -1,13 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const counter = require('./counter.js');
|
||||
|
||||
test('Testing counter', (t) => {
|
||||
test('Testing counter', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof counter === 'function', 'counter is a Function');
|
||||
//t.deepEqual(counter(args..), 'Expected');
|
||||
//t.equal(counter(args..), 'Expected');
|
||||
//t.false(counter(args..), 'Expected');
|
||||
//t.throws(counter(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof counter === 'function').toBeTruthy();
|
||||
});
|
||||
@ -1,14 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const createElement = require('./createElement.js');
|
||||
|
||||
test('Testing createElement', (t) => {
|
||||
test('Testing createElement', () => {
|
||||
//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();
|
||||
expect(typeof createElement === 'function').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const createEventHub = require('./createEventHub.js');
|
||||
|
||||
test('Testing createEventHub', (t) => {
|
||||
test('Testing createEventHub', () => {
|
||||
//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();
|
||||
expect(typeof createEventHub === 'function').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const currentURL = require('./currentURL.js');
|
||||
|
||||
test('Testing currentURL', (t) => {
|
||||
test('Testing currentURL', () => {
|
||||
//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();
|
||||
expect(typeof currentURL === 'function').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const curry = require('./curry.js');
|
||||
|
||||
test('Testing curry', (t) => {
|
||||
test('Testing curry', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof curry === 'function', 'curry is a 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");
|
||||
//t.deepEqual(curry(args..), 'Expected');
|
||||
//t.equal(curry(args..), 'Expected');
|
||||
//t.false(curry(args..), 'Expected');
|
||||
//t.throws(curry(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof curry === 'function').toBeTruthy();
|
||||
expect(curry(Math.pow)(2)(10)).toBe(1024);
|
||||
expect(curry(Math.min, 3)(10)(50)(2)).toBe(2);
|
||||
});
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const debounce = require('./debounce.js');
|
||||
|
||||
test('Testing debounce', (t) => {
|
||||
test('Testing debounce', () => {
|
||||
//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();
|
||||
expect(typeof debounce === 'function').toBeTruthy();
|
||||
debounce(() => {}, 250);
|
||||
});
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const decapitalize = require('./decapitalize.js');
|
||||
|
||||
test('Testing decapitalize', (t) => {
|
||||
test('Testing decapitalize', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof decapitalize === 'function', 'decapitalize is a Function');
|
||||
t.equal(decapitalize('FooBar'), 'fooBar', 'Works with default parameter');
|
||||
t.equal(decapitalize('FooBar', true), 'fOOBAR', 'Works with second parameter set to true');
|
||||
//t.deepEqual(decapitalize(args..), 'Expected');
|
||||
//t.equal(decapitalize(args..), 'Expected');
|
||||
//t.false(decapitalize(args..), 'Expected');
|
||||
//t.throws(decapitalize(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof decapitalize === 'function').toBeTruthy();
|
||||
expect(decapitalize('FooBar')).toBe('fooBar');
|
||||
expect(decapitalize('FooBar', true)).toBe('fOOBAR');
|
||||
});
|
||||
|
||||
@ -1,21 +1,16 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const deepClone = require('./deepClone.js');
|
||||
|
||||
test('Testing deepClone', (t) => {
|
||||
test('Testing deepClone', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof deepClone === 'function', 'deepClone is a Function');
|
||||
expect(typeof deepClone === 'function').toBeTruthy();
|
||||
const a = { foo: 'bar', obj: { a: 1, b: 2 } };
|
||||
const b = deepClone(a);
|
||||
const c = [{foo: "bar"}];
|
||||
const d = deepClone(c);
|
||||
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");
|
||||
//t.deepEqual(deepClone(args..), 'Expected');
|
||||
//t.equal(deepClone(args..), 'Expected');
|
||||
//t.false(deepClone(args..), 'Expected');
|
||||
//t.throws(deepClone(args..), 'Expected');
|
||||
t.end();
|
||||
expect(a).not.toBe(b);
|
||||
expect(a.obj).not.toBe(b.obj);
|
||||
expect(c).not.toBe(d);
|
||||
expect(c[0]).not.toBe(d[0]);
|
||||
});
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
const test = require('tape');
|
||||
const expect = require('expect');
|
||||
const deepFlatten = require('./deepFlatten.js');
|
||||
|
||||
test('Testing deepFlatten', (t) => {
|
||||
test('Testing deepFlatten', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof deepFlatten === 'function', 'deepFlatten is a Function');
|
||||
t.deepEqual(deepFlatten([1, [2], [[3], 4], 5]), [1, 2, 3, 4, 5], "Deep flattens an array");
|
||||
//t.deepEqual(deepFlatten(args..), 'Expected');
|
||||
//t.equal(deepFlatten(args..), 'Expected');
|
||||
//t.false(deepFlatten(args..), 'Expected');
|
||||
//t.throws(deepFlatten(args..), 'Expected');
|
||||
t.end();
|
||||
expect(typeof deepFlatten === 'function').toBeTruthy();
|
||||
expect(deepFlatten([1, [2], [[3], 4], 5])).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const defaults = require('./defaults.js');
|
||||
|
||||
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();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const defer = require('./defer.js');
|
||||
|
||||
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();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
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();
|
||||
});
|
||||
@ -1,20 +0,0 @@
|
||||
const test = require('tape');
|
||||
const delay = require('./delay.js');
|
||||
|
||||
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();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const detectDeviceType = require('./detectDeviceType.js');
|
||||
|
||||
test('Testing detectDeviceType', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof detectDeviceType === 'function', 'detectDeviceType is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(detectDeviceType(args..), 'Expected');
|
||||
//t.equal(detectDeviceType(args..), 'Expected');
|
||||
//t.false(detectDeviceType(args..), 'Expected');
|
||||
//t.throws(detectDeviceType(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const difference = require('./difference.js');
|
||||
|
||||
test('Testing difference', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof difference === 'function', 'difference is a Function');
|
||||
t.deepEqual(difference([1, 2, 3], [1, 2, 4]), [3], "Returns the difference between two arrays");
|
||||
//t.deepEqual(difference(args..), 'Expected');
|
||||
//t.equal(difference(args..), 'Expected');
|
||||
//t.false(difference(args..), 'Expected');
|
||||
//t.throws(difference(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
const test = require('tape');
|
||||
const differenceBy = require('./differenceBy.js');
|
||||
|
||||
test('Testing differenceBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof differenceBy === 'function', 'differenceBy is a 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');
|
||||
//t.deepEqual(differenceBy(args..), 'Expected');
|
||||
//t.equal(differenceBy(args..), 'Expected');
|
||||
//t.false(differenceBy(args..), 'Expected');
|
||||
//t.throws(differenceBy(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const differenceWith = require('./differenceWith.js');
|
||||
|
||||
test('Testing differenceWith', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof differenceWith === 'function', 'differenceWith is a 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");
|
||||
//t.deepEqual(differenceWith(args..), 'Expected');
|
||||
//t.equal(differenceWith(args..), 'Expected');
|
||||
//t.false(differenceWith(args..), 'Expected');
|
||||
//t.throws(differenceWith(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const digitize = require('./digitize.js');
|
||||
|
||||
test('Testing digitize', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof digitize === 'function', 'digitize is a Function');
|
||||
t.deepEqual(digitize(123), [1, 2, 3], "Converts a number to an array of digits");
|
||||
//t.deepEqual(digitize(args..), 'Expected');
|
||||
//t.equal(digitize(args..), 'Expected');
|
||||
//t.false(digitize(args..), 'Expected');
|
||||
//t.throws(digitize(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const distance = require('./distance.js');
|
||||
|
||||
test('Testing distance', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof distance === 'function', 'distance is a Function');
|
||||
t.equals(distance(1, 1, 2, 3), 2.23606797749979, 'Calculates the distance between two points');
|
||||
//t.deepEqual(distance(args..), 'Expected');
|
||||
//t.equal(distance(args..), 'Expected');
|
||||
//t.false(distance(args..), 'Expected');
|
||||
//t.throws(distance(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const drop = require('./drop.js');
|
||||
|
||||
test('Testing drop', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof drop === 'function', 'drop is a 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');
|
||||
//t.deepEqual(drop(args..), 'Expected');
|
||||
//t.equal(drop(args..), 'Expected');
|
||||
//t.false(drop(args..), 'Expected');
|
||||
//t.throws(drop(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const dropRight = require('./dropRight.js');
|
||||
|
||||
test('Testing dropRight', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof dropRight === 'function', 'dropRight is a 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");
|
||||
//t.deepEqual(dropRight(args..), 'Expected');
|
||||
//t.equal(dropRight(args..), 'Expected');
|
||||
//t.false(dropRight(args..), 'Expected');
|
||||
//t.throws(dropRight(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const dropRightWhile = require('./dropRightWhile.js');
|
||||
|
||||
test('Testing dropRightWhile', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof dropRightWhile === 'function', 'dropRightWhile is a 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.');
|
||||
//t.deepEqual(dropRightWhile(args..), 'Expected');
|
||||
//t.equal(dropRightWhile(args..), 'Expected');
|
||||
//t.false(dropRightWhile(args..), 'Expected');
|
||||
//t.throws(dropRightWhile(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const dropWhile = require('./dropWhile.js');
|
||||
|
||||
test('Testing dropWhile', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof dropWhile === 'function', 'dropWhile is a Function');
|
||||
t.deepEqual(dropWhile([1, 2, 3, 4], n => n >= 3), [3,4], 'Removes elements in an array until the passed function returns true.');
|
||||
//t.deepEqual(dropWhile(args..), 'Expected');
|
||||
//t.equal(dropWhile(args..), 'Expected');
|
||||
//t.false(dropWhile(args..), 'Expected');
|
||||
//t.throws(dropWhile(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const elementIsVisibleInViewport = require('./elementIsVisibleInViewport.js');
|
||||
|
||||
test('Testing elementIsVisibleInViewport', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof elementIsVisibleInViewport === 'function', 'elementIsVisibleInViewport is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(elementIsVisibleInViewport(args..), 'Expected');
|
||||
//t.equal(elementIsVisibleInViewport(args..), 'Expected');
|
||||
//t.false(elementIsVisibleInViewport(args..), 'Expected');
|
||||
//t.throws(elementIsVisibleInViewport(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const elo = require('./elo.js');
|
||||
|
||||
test('Testing elo', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof elo === 'function', 'elo is a 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");
|
||||
//t.deepEqual(elo(args..), 'Expected');
|
||||
//t.equal(elo(args..), 'Expected');
|
||||
//t.false(elo(args..), 'Expected');
|
||||
//t.throws(elo(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,18 +0,0 @@
|
||||
const test = require('tape');
|
||||
const equals = require('./equals.js');
|
||||
|
||||
test('Testing equals', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof equals === 'function', 'equals is a 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' }");
|
||||
t.true(equals([1, 2, 3], [1, 2, 3]), '[1,2,3] is equal to [1,2,3]');
|
||||
t.false(equals({ a: [2, 3], b: [4] }, { a: [2, 3], b: [6] }), '{ a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] }');
|
||||
t.false(equals([1, 2, 3], [1, 2, 4]), '[1,2,3] is not equal to [1,2,4]');
|
||||
t.true(equals([1, 2, 3], { 0: 1, 1: 2, 2: 3 }), '[1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match.');
|
||||
//t.deepEqual(equals(args..), 'Expected');
|
||||
//t.equal(equals(args..), 'Expected');
|
||||
//t.false(equals(args..), 'Expected');
|
||||
//t.throws(equals(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const escapeHTML = require('./escapeHTML.js');
|
||||
|
||||
test('Testing escapeHTML', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof escapeHTML === 'function', 'escapeHTML is a Function');
|
||||
t.equal(escapeHTML('<a href="#">Me & you</a>'), '<a href="#">Me & you</a>', "Escapes a string for use in HTML");
|
||||
//t.deepEqual(escapeHTML(args..), 'Expected');
|
||||
//t.equal(escapeHTML(args..), 'Expected');
|
||||
//t.false(escapeHTML(args..), 'Expected');
|
||||
//t.throws(escapeHTML(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const escapeRegExp = require('./escapeRegExp.js');
|
||||
|
||||
test('Testing escapeRegExp', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof escapeRegExp === 'function', 'escapeRegExp is a Function');
|
||||
t.equal(escapeRegExp('(test)'), '\\(test\\)', "Escapes a string to use in a regular expression");
|
||||
//t.deepEqual(escapeRegExp(args..), 'Expected');
|
||||
//t.equal(escapeRegExp(args..), 'Expected');
|
||||
//t.false(escapeRegExp(args..), 'Expected');
|
||||
//t.throws(escapeRegExp(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const everyNth = require('./everyNth.js');
|
||||
|
||||
test('Testing everyNth', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof everyNth === 'function', 'everyNth is a Function');
|
||||
t.deepEqual(everyNth([1, 2, 3, 4, 5, 6], 2), [ 2, 4, 6 ], "Returns every nth element in an array");
|
||||
//t.deepEqual(everyNth(args..), 'Expected');
|
||||
//t.equal(everyNth(args..), 'Expected');
|
||||
//t.false(everyNth(args..), 'Expected');
|
||||
//t.throws(everyNth(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
const test = require('tape');
|
||||
const extendHex = require('./extendHex.js');
|
||||
|
||||
test('Testing extendHex', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof extendHex === 'function', 'extendHex is a 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");
|
||||
//t.deepEqual(extendHex(args..), 'Expected');
|
||||
//t.equal(extendHex(args..), 'Expected');
|
||||
//t.false(extendHex(args..), 'Expected');
|
||||
//t.throws(extendHex(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,18 +0,0 @@
|
||||
const test = require('tape');
|
||||
const factorial = require('./factorial.js');
|
||||
|
||||
test('Testing factorial', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof factorial === 'function', 'factorial is a 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");
|
||||
//t.deepEqual(factorial(args..), 'Expected');
|
||||
//t.equal(factorial(args..), 'Expected');
|
||||
//t.false(factorial(args..), 'Expected');
|
||||
//t.throws(factorial(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,13 +0,0 @@
|
||||
const test = require('tape');
|
||||
const factors = require('./factors.js');
|
||||
|
||||
test('Testing factors', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof factors === 'function', 'factors is a Function');
|
||||
//t.deepEqual(factors(args..), 'Expected');
|
||||
//t.equal(factors(args..), 'Expected');
|
||||
//t.false(factors(args..), 'Expected');
|
||||
//t.throws(factors(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const fibonacci = require('./fibonacci.js');
|
||||
|
||||
test('Testing fibonacci', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof fibonacci === 'function', 'fibonacci is a Function');
|
||||
t.deepEqual(fibonacci(6), [0, 1, 1, 2, 3, 5], "Generates an array, containing the Fibonacci sequence");
|
||||
//t.deepEqual(fibonacci(args..), 'Expected');
|
||||
//t.equal(fibonacci(args..), 'Expected');
|
||||
//t.false(fibonacci(args..), 'Expected');
|
||||
//t.throws(fibonacci(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,13 +0,0 @@
|
||||
const test = require('tape');
|
||||
const fibonacciCountUntilNum = require('./fibonacciCountUntilNum.js');
|
||||
|
||||
test('Testing fibonacciCountUntilNum', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof fibonacciCountUntilNum === 'function', 'fibonacciCountUntilNum is a Function');
|
||||
//t.deepEqual(fibonacciCountUntilNum(args..), 'Expected');
|
||||
//t.equal(fibonacciCountUntilNum(args..), 'Expected');
|
||||
//t.false(fibonacciCountUntilNum(args..), 'Expected');
|
||||
//t.throws(fibonacciCountUntilNum(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,13 +0,0 @@
|
||||
const test = require('tape');
|
||||
const fibonacciUntilNum = require('./fibonacciUntilNum.js');
|
||||
|
||||
test('Testing fibonacciUntilNum', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof fibonacciUntilNum === 'function', 'fibonacciUntilNum is a Function');
|
||||
//t.deepEqual(fibonacciUntilNum(args..), 'Expected');
|
||||
//t.equal(fibonacciUntilNum(args..), 'Expected');
|
||||
//t.false(fibonacciUntilNum(args..), 'Expected');
|
||||
//t.throws(fibonacciUntilNum(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const filterNonUnique = require('./filterNonUnique.js');
|
||||
|
||||
test('Testing filterNonUnique', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof filterNonUnique === 'function', 'filterNonUnique is a Function');
|
||||
t.deepEqual(filterNonUnique([1, 2, 2, 3, 4, 4, 5]), [1,3,5], "Filters out the non-unique values in an array");
|
||||
//t.deepEqual(filterNonUnique(args..), 'Expected');
|
||||
//t.equal(filterNonUnique(args..), 'Expected');
|
||||
//t.false(filterNonUnique(args..), 'Expected');
|
||||
//t.throws(filterNonUnique(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,21 +0,0 @@
|
||||
const test = require('tape');
|
||||
const findKey = require('./findKey.js');
|
||||
|
||||
test('Testing findKey', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof findKey === 'function', 'findKey is a 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');
|
||||
//t.deepEqual(findKey(args..), 'Expected');
|
||||
//t.equal(findKey(args..), 'Expected');
|
||||
//t.false(findKey(args..), 'Expected');
|
||||
//t.throws(findKey(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const findLast = require('./findLast.js');
|
||||
|
||||
test('Testing findLast', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof findLast === 'function', 'findLast is a Function');
|
||||
t.equal(findLast([1, 2, 3, 4], n => n % 2 === 1), 3, 'Finds last element for which the given function returns true');
|
||||
//t.deepEqual(findLast(args..), 'Expected');
|
||||
//t.equal(findLast(args..), 'Expected');
|
||||
//t.false(findLast(args..), 'Expected');
|
||||
//t.throws(findLast(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const findLastIndex = require('./findLastIndex.js');
|
||||
|
||||
test('Testing findLastIndex', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof findLastIndex === 'function', 'findLastIndex is a Function');
|
||||
t.equal(findLastIndex([1, 2, 3, 4], n => n % 2 === 1), 2, 'Finds last index for which the given function returns true');
|
||||
//t.deepEqual(findLastIndex(args..), 'Expected');
|
||||
//t.equal(findLastIndex(args..), 'Expected');
|
||||
//t.false(findLastIndex(args..), 'Expected');
|
||||
//t.throws(findLastIndex(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,21 +0,0 @@
|
||||
const test = require('tape');
|
||||
const findLastKey = require('./findLastKey.js');
|
||||
|
||||
test('Testing findLastKey', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof findLastKey === 'function', 'findLastKey is a 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');
|
||||
//t.deepEqual(findLastKey(args..), 'Expected');
|
||||
//t.equal(findLastKey(args..), 'Expected');
|
||||
//t.false(findLastKey(args..), 'Expected');
|
||||
//t.throws(findLastKey(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
const test = require('tape');
|
||||
const flatten = require('./flatten.js');
|
||||
|
||||
test('Testing flatten', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof flatten === 'function', 'flatten is a 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");
|
||||
//t.deepEqual(flatten(args..), 'Expected');
|
||||
//t.equal(flatten(args..), 'Expected');
|
||||
//t.false(flatten(args..), 'Expected');
|
||||
//t.throws(flatten(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
const test = require('tape');
|
||||
const flattenObject = require('./flattenObject.js');
|
||||
|
||||
test('Testing flattenObject', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof flattenObject === 'function', 'flattenObject is a 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');
|
||||
//t.deepEqual(flattenObject(args..), 'Expected');
|
||||
//t.equal(flattenObject(args..), 'Expected');
|
||||
//t.false(flattenObject(args..), 'Expected');
|
||||
//t.throws(flattenObject(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,18 +0,0 @@
|
||||
const test = require('tape');
|
||||
const flip = require('./flip.js');
|
||||
|
||||
test('Testing flip', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof flip === 'function', 'flip is a 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');
|
||||
//t.deepEqual(flip(args..), 'Expected');
|
||||
//t.equal(flip(args..), 'Expected');
|
||||
//t.false(flip(args..), 'Expected');
|
||||
//t.throws(flip(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const forEachRight = require('./forEachRight.js');
|
||||
|
||||
test('Testing forEachRight', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof forEachRight === 'function', 'forEachRight is a Function');
|
||||
let output = '';
|
||||
forEachRight([1, 2, 3, 4], val => output+=val);
|
||||
t.equal(output, '4321', 'Iterates over the array in reverse');
|
||||
//t.deepEqual(forEachRight(args..), 'Expected');
|
||||
//t.equal(forEachRight(args..), 'Expected');
|
||||
//t.false(forEachRight(args..), 'Expected');
|
||||
//t.throws(forEachRight(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const forOwn = require('./forOwn.js');
|
||||
|
||||
test('Testing forOwn', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof forOwn === 'function', 'forOwn is a Function');
|
||||
let output = [];
|
||||
forOwn({ foo: 'bar', a: 1 }, v => output.push(v)); // 'bar', 1
|
||||
t.deepEqual(output, ['bar', 1], 'Iterates over an element\'s key-value pairs');
|
||||
//t.deepEqual(forOwn(args..), 'Expected');
|
||||
//t.equal(forOwn(args..), 'Expected');
|
||||
//t.false(forOwn(args..), 'Expected');
|
||||
//t.throws(forOwn(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const forOwnRight = require('./forOwnRight.js');
|
||||
|
||||
test('Testing forOwnRight', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof forOwnRight === 'function', 'forOwnRight is a Function');
|
||||
let output = [];
|
||||
forOwnRight({ foo: 'bar', a: 1 }, v => output.push(v)); // 'bar', 1
|
||||
t.deepEqual(output, [1, 'bar'], 'Iterates over an element\'s key-value pairs in reverse');
|
||||
//t.deepEqual(forOwnRight(args..), 'Expected');
|
||||
//t.equal(forOwnRight(args..), 'Expected');
|
||||
//t.false(forOwnRight(args..), 'Expected');
|
||||
//t.throws(forOwnRight(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
const test = require('tape');
|
||||
const formatDuration = require('./formatDuration.js');
|
||||
|
||||
test('Testing formatDuration', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof formatDuration === 'function', 'formatDuration is a 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");
|
||||
//t.deepEqual(formatDuration(args..), 'Expected');
|
||||
//t.equal(formatDuration(args..), 'Expected');
|
||||
//t.false(formatDuration(args..), 'Expected');
|
||||
//t.throws(formatDuration(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
const test = require('tape');
|
||||
const fromCamelCase = require('./fromCamelCase.js');
|
||||
|
||||
test('Testing fromCamelCase', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof fromCamelCase === 'function', 'fromCamelCase is a 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");
|
||||
//t.deepEqual(fromCamelCase(args..), 'Expected');
|
||||
//t.equal(fromCamelCase(args..), 'Expected');
|
||||
//t.false(fromCamelCase(args..), 'Expected');
|
||||
//t.throws(fromCamelCase(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,26 +0,0 @@
|
||||
const test = require('tape');
|
||||
//const functionName = require('./functionName.js');
|
||||
// Custom override for console.debug to check output.
|
||||
let output = '';
|
||||
const console = {};
|
||||
console.debug = (x) => output = x;
|
||||
// Override for testing
|
||||
const functionName = fn => (console.debug(fn.name), fn);
|
||||
test('Testing functionName', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof functionName === 'function', 'functionName is a 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');
|
||||
//t.deepEqual(functionName(args..), 'Expected');
|
||||
//t.equal(functionName(args..), 'Expected');
|
||||
//t.false(functionName(args..), 'Expected');
|
||||
//t.throws(functionName(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,20 +0,0 @@
|
||||
const test = require('tape');
|
||||
const functions = require('./functions.js');
|
||||
|
||||
test('Testing functions', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof functions === 'function', 'functions is a 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');
|
||||
//t.deepEqual(functions(args..), 'Expected');
|
||||
//t.equal(functions(args..), 'Expected');
|
||||
//t.false(functions(args..), 'Expected');
|
||||
//t.throws(functions(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
const test = require('tape');
|
||||
const gcd = require('./gcd.js');
|
||||
|
||||
test('Testing gcd', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof gcd === 'function', 'gcd is a 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");
|
||||
//t.deepEqual(gcd(args..), 'Expected');
|
||||
//t.equal(gcd(args..), 'Expected');
|
||||
//t.false(gcd(args..), 'Expected');
|
||||
//t.throws(gcd(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user