@ -5,10 +5,20 @@ test('Testing average', (t) => {
|
||||
//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.equal(average(9, 1), 5, 'The average of 1 & 9 is 5');
|
||||
//t.deepEqual(average(args..), 'Expected');
|
||||
//t.equal(average(args..), 'Expected');
|
||||
//t.false(average(args..), 'Expected');
|
||||
//t.throws(average(args..), 'Expected');
|
||||
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');
|
||||
|
||||
let start = new Date().getTime();
|
||||
average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631);
|
||||
let end = new Date().getTime();
|
||||
t.true((end - start) < 2000, 'head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run');
|
||||
t.end();
|
||||
});
|
||||
3
test/averageBy/averageBy.js
Normal file
3
test/averageBy/averageBy.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = averageBy = (arr, fn) =>
|
||||
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
|
||||
arr.length;
|
||||
13
test/averageBy/averageBy.test.js
Normal file
13
test/averageBy/averageBy.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const averageBy = require('./averageBy.js');
|
||||
|
||||
test('Testing averageBy', (t) => {
|
||||
//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.deepEqual(averageBy(args..), 'Expected');
|
||||
//t.equal(averageBy(args..), 'Expected');
|
||||
//t.false(averageBy(args..), 'Expected');
|
||||
//t.throws(averageBy(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -4,11 +4,19 @@ const chunk = require('./chunk.js');
|
||||
test('Testing chunk', (t) => {
|
||||
//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]], "Chunks an array into smaller arrays of a specified size");
|
||||
//t.deepEqual(chunk(args..), 'Expected');
|
||||
//t.equal(chunk(args..), 'Expected');
|
||||
//t.false(chunk(args..), 'Expected');
|
||||
//t.throws(chunk(args..), 'Expected');
|
||||
t.end();
|
||||
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');
|
||||
|
||||
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();
|
||||
});
|
||||
18
test/colorize/colorize.js
Normal file
18
test/colorize/colorize.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = colorize = (...args) => ({
|
||||
black: `\x1b[30m${args.join(' ')}`,
|
||||
red: `\x1b[31m${args.join(' ')}`,
|
||||
green: `\x1b[32m${args.join(' ')}`,
|
||||
yellow: `\x1b[33m${args.join(' ')}`,
|
||||
blue: `\x1b[34m${args.join(' ')}`,
|
||||
magenta: `\x1b[35m${args.join(' ')}`,
|
||||
cyan: `\x1b[36m${args.join(' ')}`,
|
||||
white: `\x1b[37m${args.join(' ')}`,
|
||||
bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`,
|
||||
bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`,
|
||||
bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`,
|
||||
bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`,
|
||||
bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`,
|
||||
bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
|
||||
bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
|
||||
bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
|
||||
});
|
||||
13
test/colorize/colorize.test.js
Normal file
13
test/colorize/colorize.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const colorize = require('./colorize.js');
|
||||
|
||||
test('Testing colorize', (t) => {
|
||||
//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.deepEqual(colorize(args..), 'Expected');
|
||||
//t.equal(colorize(args..), 'Expected');
|
||||
//t.false(colorize(args..), 'Expected');
|
||||
//t.throws(colorize(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
5
test/countBy/countBy.js
Normal file
5
test/countBy/countBy.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = countBy = (arr, fn) =>
|
||||
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {
|
||||
acc[val] = (acc[val] || 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
13
test/countBy/countBy.test.js
Normal file
13
test/countBy/countBy.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const countBy = require('./countBy.js');
|
||||
|
||||
test('Testing countBy', (t) => {
|
||||
//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(args..), 'Expected');
|
||||
//t.equal(countBy(args..), 'Expected');
|
||||
//t.false(countBy(args..), 'Expected');
|
||||
//t.throws(countBy(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
1
test/findLast/findLast.js
Normal file
1
test/findLast/findLast.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = findLast = (arr, fn) => arr.filter(fn).slice(-1);
|
||||
13
test/findLast/findLast.test.js
Normal file
13
test/findLast/findLast.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
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.deepEqual(findLast(args..), 'Expected');
|
||||
//t.equal(findLast(args..), 'Expected');
|
||||
//t.false(findLast(args..), 'Expected');
|
||||
//t.throws(findLast(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
5
test/functions/functions.js
Normal file
5
test/functions/functions.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = functions = (obj, inherited = false) =>
|
||||
(inherited
|
||||
? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]
|
||||
: Object.keys(obj)
|
||||
).filter(key => typeof obj[key] === 'function');
|
||||
13
test/functions/functions.test.js
Normal file
13
test/functions/functions.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
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');
|
||||
//t.deepEqual(functions(args..), 'Expected');
|
||||
//t.equal(functions(args..), 'Expected');
|
||||
//t.false(functions(args..), 'Expected');
|
||||
//t.throws(functions(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -4,11 +4,18 @@ const head = require('./head.js');
|
||||
test('Testing head', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof head === 'function', 'head is a Function');
|
||||
t.equal(head([1, 2, 3]), 1, "Returns head of a list");
|
||||
//t.deepEqual(head(args..), 'Expected');
|
||||
//t.equal(head(args..), 'Expected');
|
||||
//t.false(head(args..), 'Expected');
|
||||
//t.throws(head(args..), 'Expected');
|
||||
t.true(typeof head === 'function', 'head is a Function');
|
||||
t.true(head({ a: 1234}) === undefined, 'head({ a: 1234}) returns undefined');
|
||||
t.equal(head([1, 2, 3]), 1, "head([1, 2, 3]) returns 1");
|
||||
t.equal(head({ 0: false}), false, 'head({ 0: false}) returns false');
|
||||
t.equal(head('String'), 'S', 'head(String) returns S');
|
||||
t.throws(() => head(null), 'head(null) throws an Error');
|
||||
t.throws(() => head(undefined), 'head(undefined) throws an Error');
|
||||
t.throws(() => head(), 'head() throws an Error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]);
|
||||
let end = new Date().getTime();
|
||||
t.true((end - start) < 2000, 'head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run');
|
||||
t.end();
|
||||
});
|
||||
@ -5,17 +5,20 @@ test('Testing isPrimitive', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isPrimitive === 'function', 'isPrimitive is a Function');
|
||||
t.equal(isPrimitive(null), true, "passed value is primitive");
|
||||
t.equal(isPrimitive(50), true, "passed value is primitive");
|
||||
t.equal(isPrimitive('Hello'), true, "passed value is primitive");
|
||||
t.equal(isPrimitive(false), true, "passed value is primitive");
|
||||
t.equal(isPrimitive(Symbol()), true, "passed value is primitive");
|
||||
t.equal(isPrimitive([]), false, "passed value is primitive");
|
||||
|
||||
|
||||
//t.deepEqual(isPrimitive(args..), 'Expected');
|
||||
//t.equal(isPrimitive(args..), 'Expected');
|
||||
//t.false(isPrimitive(args..), 'Expected');
|
||||
//t.throws(isPrimitive(args..), 'Expected');
|
||||
t.true(isPrimitive(null), "isPrimitive(null) is primitive");
|
||||
t.true(isPrimitive(undefined), "isPrimitive(undefined) is primitive");
|
||||
t.true(isPrimitive('string'), "isPrimitive(string) is primitive");
|
||||
t.true(isPrimitive(true), "isPrimitive(true) is primitive");
|
||||
t.true(isPrimitive(50), "isPrimitive(50) is primitive");
|
||||
t.true(isPrimitive('Hello'), "isPrimitive('Hello') is primitive");
|
||||
t.true(isPrimitive(false), "isPrimitive(false) is primitive");
|
||||
t.true(isPrimitive(Symbol()), "isPrimitive(Symbol()) is primitive");
|
||||
t.false(isPrimitive([1, 2, 3]), "isPrimitive([1, 2, 3]) is not primitive");
|
||||
t.false(isPrimitive({ a: 123 }), "isPrimitive({ a: 123 }) is not primitive");
|
||||
|
||||
let start = new Date().getTime();
|
||||
isPrimitive({ a: 123 });
|
||||
let end = new Date().getTime();
|
||||
t.true((end - start) < 2000, 'isPrimitive({ a: 123 }) takes less than 2s to run');
|
||||
t.end();
|
||||
});
|
||||
@ -5,10 +5,17 @@ test('Testing last', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof last === 'function', 'last is a Function');
|
||||
t.equal(last([1, 2, 3]), 3, "Returns the last element in an array");
|
||||
//t.deepEqual(last(args..), 'Expected');
|
||||
//t.equal(last(args..), 'Expected');
|
||||
//t.false(last(args..), 'Expected');
|
||||
//t.throws(last(args..), 'Expected');
|
||||
t.true(last({ a: 1234}) === undefined, 'last({ a: 1234}) returns undefined');
|
||||
t.equal(last([1, 2, 3]), 3, "last([1, 2, 3]) returns 3");
|
||||
t.equal(last({ 0: false}), undefined, 'last({ 0: false}) returns undefined');
|
||||
t.equal(last('String'), 'g', 'last(String) returns g');
|
||||
t.throws(() => last(null), 'last(null) throws an Error');
|
||||
t.throws(() => last(undefined), 'last(undefined) throws an Error');
|
||||
t.throws(() => last(), 'last() throws an Error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]);
|
||||
let end = new Date().getTime();
|
||||
t.true((end - start) < 2000, 'last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run');
|
||||
t.end();
|
||||
});
|
||||
5
test/mapKeys/mapKeys.js
Normal file
5
test/mapKeys/mapKeys.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = mapKeys = (obj, fn) =>
|
||||
Object.keys(obj).reduce((acc, k) => {
|
||||
acc[fn(obj[k], k, obj)] = obj[k];
|
||||
return acc;
|
||||
}, {});
|
||||
13
test/mapKeys/mapKeys.test.js
Normal file
13
test/mapKeys/mapKeys.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const mapKeys = require('./mapKeys.js');
|
||||
|
||||
test('Testing mapKeys', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof mapKeys === 'function', 'mapKeys is a Function');
|
||||
//t.deepEqual(mapKeys(args..), 'Expected');
|
||||
//t.equal(mapKeys(args..), 'Expected');
|
||||
//t.false(mapKeys(args..), 'Expected');
|
||||
//t.throws(mapKeys(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
5
test/mapValues/mapValues.js
Normal file
5
test/mapValues/mapValues.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = mapValues = (obj, fn) =>
|
||||
Object.keys(obj).reduce((acc, k) => {
|
||||
acc[k] = fn(obj[k], k, obj);
|
||||
return acc;
|
||||
}, {});
|
||||
13
test/mapValues/mapValues.test.js
Normal file
13
test/mapValues/mapValues.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const mapValues = require('./mapValues.js');
|
||||
|
||||
test('Testing mapValues', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof mapValues === 'function', 'mapValues is a Function');
|
||||
//t.deepEqual(mapValues(args..), 'Expected');
|
||||
//t.equal(mapValues(args..), 'Expected');
|
||||
//t.false(mapValues(args..), 'Expected');
|
||||
//t.throws(mapValues(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
1
test/maxBy/maxBy.js
Normal file
1
test/maxBy/maxBy.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
||||
13
test/maxBy/maxBy.test.js
Normal file
13
test/maxBy/maxBy.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const maxBy = require('./maxBy.js');
|
||||
|
||||
test('Testing maxBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof maxBy === 'function', 'maxBy is a Function');
|
||||
//t.deepEqual(maxBy(args..), 'Expected');
|
||||
//t.equal(maxBy(args..), 'Expected');
|
||||
//t.false(maxBy(args..), 'Expected');
|
||||
//t.throws(maxBy(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
9
test/merge/merge.js
Normal file
9
test/merge/merge.js
Normal file
@ -0,0 +1,9 @@
|
||||
module.exports = merge = (...objs) =>
|
||||
[...objs].reduce(
|
||||
(acc, obj) =>
|
||||
Object.keys(obj).reduce((a, k) => {
|
||||
acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k];
|
||||
return acc;
|
||||
}, {}),
|
||||
{}
|
||||
);
|
||||
13
test/merge/merge.test.js
Normal file
13
test/merge/merge.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const merge = require('./merge.js');
|
||||
|
||||
test('Testing merge', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof merge === 'function', 'merge is a Function');
|
||||
//t.deepEqual(merge(args..), 'Expected');
|
||||
//t.equal(merge(args..), 'Expected');
|
||||
//t.false(merge(args..), 'Expected');
|
||||
//t.throws(merge(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
1
test/minBy/minBy.js
Normal file
1
test/minBy/minBy.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
||||
13
test/minBy/minBy.test.js
Normal file
13
test/minBy/minBy.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const minBy = require('./minBy.js');
|
||||
|
||||
test('Testing minBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof minBy === 'function', 'minBy is a Function');
|
||||
//t.deepEqual(minBy(args..), 'Expected');
|
||||
//t.equal(minBy(args..), 'Expected');
|
||||
//t.false(minBy(args..), 'Expected');
|
||||
//t.throws(minBy(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
8
test/parseCookie/parseCookie.js
Normal file
8
test/parseCookie/parseCookie.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = parseCookie = str =>
|
||||
str
|
||||
.split(';')
|
||||
.map(v => v.split('='))
|
||||
.reduce((acc, v) => {
|
||||
acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim());
|
||||
return acc;
|
||||
}, {});
|
||||
13
test/parseCookie/parseCookie.test.js
Normal file
13
test/parseCookie/parseCookie.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const parseCookie = require('./parseCookie.js');
|
||||
|
||||
test('Testing parseCookie', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof parseCookie === 'function', 'parseCookie is a Function');
|
||||
//t.deepEqual(parseCookie(args..), 'Expected');
|
||||
//t.equal(parseCookie(args..), 'Expected');
|
||||
//t.false(parseCookie(args..), 'Expected');
|
||||
//t.throws(parseCookie(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
@ -5,9 +5,18 @@ test('Testing quickSort', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof quickSort === 'function', 'quickSort is a Function');
|
||||
//t.deepEqual(quickSort(args..), 'Expected');
|
||||
//t.equal(quickSort(args..), 'Expected');
|
||||
//t.false(quickSort(args..), 'Expected');
|
||||
//t.throws(quickSort(args..), 'Expected');
|
||||
t.deepEqual(quickSort([5, 6, 4, 3, 1, 2]), [1, 2, 3, 4, 5, 6], 'quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6]');
|
||||
t.deepEqual(quickSort([-1, 0, -2]), [-2, -1, 0], 'quickSort([-1, 0, -2]) returns [-2, -1, 0]');
|
||||
t.throws(() => quickSort(), 'quickSort() throws an error');
|
||||
t.throws(() => quickSort(123), 'quickSort(123) throws an error');
|
||||
t.throws(() => quickSort({ 234: string}), 'quickSort({ 234: string}) throws an error');
|
||||
t.throws(() => quickSort(null), 'quickSort(null) throws an error');
|
||||
t.throws(() => quickSort(undefined), 'quickSort(undefined) throws an error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]);
|
||||
let end = new Date().getTime();
|
||||
t.true((end - start) < 2000, 'quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run');
|
||||
|
||||
t.end();
|
||||
});
|
||||
1
test/serializeCookie/serializeCookie.js
Normal file
1
test/serializeCookie/serializeCookie.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`;
|
||||
13
test/serializeCookie/serializeCookie.test.js
Normal file
13
test/serializeCookie/serializeCookie.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const serializeCookie = require('./serializeCookie.js');
|
||||
|
||||
test('Testing serializeCookie', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof serializeCookie === 'function', 'serializeCookie is a Function');
|
||||
//t.deepEqual(serializeCookie(args..), 'Expected');
|
||||
//t.equal(serializeCookie(args..), 'Expected');
|
||||
//t.false(serializeCookie(args..), 'Expected');
|
||||
//t.throws(serializeCookie(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
2
test/sumBy/sumBy.js
Normal file
2
test/sumBy/sumBy.js
Normal file
@ -0,0 +1,2 @@
|
||||
module.exports = sumBy = (arr, fn) =>
|
||||
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0);
|
||||
13
test/sumBy/sumBy.test.js
Normal file
13
test/sumBy/sumBy.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const sumBy = require('./sumBy.js');
|
||||
|
||||
test('Testing sumBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sumBy === 'function', 'sumBy is a Function');
|
||||
//t.deepEqual(sumBy(args..), 'Expected');
|
||||
//t.equal(sumBy(args..), 'Expected');
|
||||
//t.false(sumBy(args..), 'Expected');
|
||||
//t.throws(sumBy(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
1
test/transform/transform.js
Normal file
1
test/transform/transform.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
||||
13
test/transform/transform.test.js
Normal file
13
test/transform/transform.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const transform = require('./transform.js');
|
||||
|
||||
test('Testing transform', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof transform === 'function', 'transform is a Function');
|
||||
//t.deepEqual(transform(args..), 'Expected');
|
||||
//t.equal(transform(args..), 'Expected');
|
||||
//t.false(transform(args..), 'Expected');
|
||||
//t.throws(transform(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user