diff --git a/test/average/average.test.js b/test/average/average.test.js index ae62e1dae..c38a2ee5c 100644 --- a/test/average/average.test.js +++ b/test/average/average.test.js @@ -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(); }); \ No newline at end of file diff --git a/test/averageBy/averageBy.js b/test/averageBy/averageBy.js new file mode 100644 index 000000000..510263fa7 --- /dev/null +++ b/test/averageBy/averageBy.js @@ -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; \ No newline at end of file diff --git a/test/averageBy/averageBy.test.js b/test/averageBy/averageBy.test.js new file mode 100644 index 000000000..60675dfb7 --- /dev/null +++ b/test/averageBy/averageBy.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/chunk/chunk.test.js b/test/chunk/chunk.test.js index c1d635f42..a4dc0051a 100644 --- a/test/chunk/chunk.test.js +++ b/test/chunk/chunk.test.js @@ -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(); }); \ No newline at end of file diff --git a/test/colorize/colorize.js b/test/colorize/colorize.js new file mode 100644 index 000000000..25c23fad7 --- /dev/null +++ b/test/colorize/colorize.js @@ -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` +}); \ No newline at end of file diff --git a/test/colorize/colorize.test.js b/test/colorize/colorize.test.js new file mode 100644 index 000000000..a20fe2a3f --- /dev/null +++ b/test/colorize/colorize.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/countBy/countBy.js b/test/countBy/countBy.js new file mode 100644 index 000000000..661df57cb --- /dev/null +++ b/test/countBy/countBy.js @@ -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; +}, {}); \ No newline at end of file diff --git a/test/countBy/countBy.test.js b/test/countBy/countBy.test.js new file mode 100644 index 000000000..24ca39f7e --- /dev/null +++ b/test/countBy/countBy.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/findLast/findLast.js b/test/findLast/findLast.js new file mode 100644 index 000000000..cbd294f72 --- /dev/null +++ b/test/findLast/findLast.js @@ -0,0 +1 @@ +module.exports = findLast = (arr, fn) => arr.filter(fn).slice(-1); \ No newline at end of file diff --git a/test/findLast/findLast.test.js b/test/findLast/findLast.test.js new file mode 100644 index 000000000..036d5f313 --- /dev/null +++ b/test/findLast/findLast.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/functions/functions.js b/test/functions/functions.js new file mode 100644 index 000000000..d0760b8b0 --- /dev/null +++ b/test/functions/functions.js @@ -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'); \ No newline at end of file diff --git a/test/functions/functions.test.js b/test/functions/functions.test.js new file mode 100644 index 000000000..8590341fb --- /dev/null +++ b/test/functions/functions.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/head/head.test.js b/test/head/head.test.js index f871184cf..7cf67cd9c 100644 --- a/test/head/head.test.js +++ b/test/head/head.test.js @@ -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(); }); \ No newline at end of file diff --git a/test/isPrimitive/isPrimitive.test.js b/test/isPrimitive/isPrimitive.test.js index 9a84bf949..2cebc77ff 100644 --- a/test/isPrimitive/isPrimitive.test.js +++ b/test/isPrimitive/isPrimitive.test.js @@ -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(); }); \ No newline at end of file diff --git a/test/last/last.test.js b/test/last/last.test.js index d17d65c90..528a363ab 100644 --- a/test/last/last.test.js +++ b/test/last/last.test.js @@ -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(); }); \ No newline at end of file diff --git a/test/mapKeys/mapKeys.js b/test/mapKeys/mapKeys.js new file mode 100644 index 000000000..6105240a7 --- /dev/null +++ b/test/mapKeys/mapKeys.js @@ -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; +}, {}); \ No newline at end of file diff --git a/test/mapKeys/mapKeys.test.js b/test/mapKeys/mapKeys.test.js new file mode 100644 index 000000000..a2b7ea63a --- /dev/null +++ b/test/mapKeys/mapKeys.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/mapValues/mapValues.js b/test/mapValues/mapValues.js new file mode 100644 index 000000000..80977c929 --- /dev/null +++ b/test/mapValues/mapValues.js @@ -0,0 +1,5 @@ +module.exports = mapValues = (obj, fn) => +Object.keys(obj).reduce((acc, k) => { +acc[k] = fn(obj[k], k, obj); +return acc; +}, {}); \ No newline at end of file diff --git a/test/mapValues/mapValues.test.js b/test/mapValues/mapValues.test.js new file mode 100644 index 000000000..e30e06c66 --- /dev/null +++ b/test/mapValues/mapValues.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/maxBy/maxBy.js b/test/maxBy/maxBy.js new file mode 100644 index 000000000..546503bd7 --- /dev/null +++ b/test/maxBy/maxBy.js @@ -0,0 +1 @@ +module.exports = maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); \ No newline at end of file diff --git a/test/maxBy/maxBy.test.js b/test/maxBy/maxBy.test.js new file mode 100644 index 000000000..765bb73ec --- /dev/null +++ b/test/maxBy/maxBy.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/merge/merge.js b/test/merge/merge.js new file mode 100644 index 000000000..0b454216f --- /dev/null +++ b/test/merge/merge.js @@ -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; +}, {}), +{} +); \ No newline at end of file diff --git a/test/merge/merge.test.js b/test/merge/merge.test.js new file mode 100644 index 000000000..28ade12bd --- /dev/null +++ b/test/merge/merge.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/minBy/minBy.js b/test/minBy/minBy.js new file mode 100644 index 000000000..7d0db026a --- /dev/null +++ b/test/minBy/minBy.js @@ -0,0 +1 @@ +module.exports = minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); \ No newline at end of file diff --git a/test/minBy/minBy.test.js b/test/minBy/minBy.test.js new file mode 100644 index 000000000..130b2de7e --- /dev/null +++ b/test/minBy/minBy.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/parseCookie/parseCookie.js b/test/parseCookie/parseCookie.js new file mode 100644 index 000000000..d05ea6cf4 --- /dev/null +++ b/test/parseCookie/parseCookie.js @@ -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; +}, {}); \ No newline at end of file diff --git a/test/parseCookie/parseCookie.test.js b/test/parseCookie/parseCookie.test.js new file mode 100644 index 000000000..76a02bbe2 --- /dev/null +++ b/test/parseCookie/parseCookie.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/quickSort/quickSort.test.js b/test/quickSort/quickSort.test.js index 691226205..1252196cd 100644 --- a/test/quickSort/quickSort.test.js +++ b/test/quickSort/quickSort.test.js @@ -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(); }); \ No newline at end of file diff --git a/test/serializeCookie/serializeCookie.js b/test/serializeCookie/serializeCookie.js new file mode 100644 index 000000000..16467650a --- /dev/null +++ b/test/serializeCookie/serializeCookie.js @@ -0,0 +1 @@ +module.exports = serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; \ No newline at end of file diff --git a/test/serializeCookie/serializeCookie.test.js b/test/serializeCookie/serializeCookie.test.js new file mode 100644 index 000000000..7e4e3a88a --- /dev/null +++ b/test/serializeCookie/serializeCookie.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/sumBy/sumBy.js b/test/sumBy/sumBy.js new file mode 100644 index 000000000..f12789d24 --- /dev/null +++ b/test/sumBy/sumBy.js @@ -0,0 +1,2 @@ +module.exports = sumBy = (arr, fn) => +arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); \ No newline at end of file diff --git a/test/sumBy/sumBy.test.js b/test/sumBy/sumBy.test.js new file mode 100644 index 000000000..23c6140fe --- /dev/null +++ b/test/sumBy/sumBy.test.js @@ -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(); +}); \ No newline at end of file diff --git a/test/transform/transform.js b/test/transform/transform.js new file mode 100644 index 000000000..d6cf8a9ab --- /dev/null +++ b/test/transform/transform.js @@ -0,0 +1 @@ +module.exports = transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); \ No newline at end of file diff --git a/test/transform/transform.test.js b/test/transform/transform.test.js new file mode 100644 index 000000000..d32739d4a --- /dev/null +++ b/test/transform/transform.test.js @@ -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(); +}); \ No newline at end of file