Test cleanup and fixes [u-v]
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const URLJoin = require('./URLJoin.js');
|
||||
|
||||
|
||||
test('URLJoin is a Function', () => {
|
||||
test('URLJoin is a Function', () => {
|
||||
expect(URLJoin).toBeInstanceOf(Function);
|
||||
});
|
||||
t.equal(URLJoin('http:
|
||||
t.equal(URLJoin('file:
|
||||
|
||||
|
||||
test('Returns proper URL', () => {
|
||||
expect(URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo')).toBe('http://www.google.com/a/b/cd?foo=123&bar=foo');
|
||||
});
|
||||
test('Returns proper URL', () => {
|
||||
expect(URLJoin('file://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo')).toBe('file:///www.google.com/a/b/cd?foo=123&bar=foo');
|
||||
});
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const UUIDGeneratorBrowser = require('./UUIDGeneratorBrowser.js');
|
||||
|
||||
|
||||
test('UUIDGeneratorBrowser is a Function', () => {
|
||||
test('UUIDGeneratorBrowser is a Function', () => {
|
||||
expect(UUIDGeneratorBrowser).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,16 +1,13 @@
|
||||
const expect = require('expect');
|
||||
const UUIDGeneratorNode = require('./UUIDGeneratorNode.js');
|
||||
|
||||
|
||||
test('UUIDGeneratorNode is a Function', () => {
|
||||
test('UUIDGeneratorNode is a Function', () => {
|
||||
expect(UUIDGeneratorNode).toBeInstanceOf(Function);
|
||||
});
|
||||
const uuid = UUIDGeneratorNode();
|
||||
test('Contains dashes in the proper places', () => {
|
||||
expect([uuid[8], uuid[13], uuid[18], uuid[23]], ['-', '-', '-', '-']).toEqual()
|
||||
const uuid = UUIDGeneratorNode();
|
||||
test('Contains dashes in the proper places', () => {
|
||||
expect([uuid[8], uuid[13], uuid[18], uuid[23]]).toEqual(['-', '-', '-', '-']);
|
||||
});
|
||||
test('Only contains hexadecimal digits', () => {
|
||||
test('Only contains hexadecimal digits', () => {
|
||||
expect(/^[0-9A-Fa-f-]+$/.test(uuid)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const unary = require('./unary.js');
|
||||
|
||||
|
||||
test('unary is a Function', () => {
|
||||
test('unary is a Function', () => {
|
||||
expect(unary).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Discards arguments after the first one', () => {
|
||||
expect(['6', '8', '10'].map(unary(parseInt)), [6, 8, 10]).toEqual()
|
||||
test('Discards arguments after the first one', () => {
|
||||
expect(['6', '8', '10'].map(unary(parseInt))).toEqual([6, 8, 10]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,22 +1,19 @@
|
||||
const expect = require('expect');
|
||||
const uncurry = require('./uncurry.js');
|
||||
|
||||
|
||||
test('uncurry is a Function', () => {
|
||||
test('uncurry is a Function', () => {
|
||||
expect(uncurry).toBeInstanceOf(Function);
|
||||
});
|
||||
const add = x => y => z => x + y + z;
|
||||
const add1 = uncurry(add);
|
||||
const add2 = uncurry(add, 2);
|
||||
const add3 = uncurry(add, 3);
|
||||
test('Works without a provided value for n', () => {
|
||||
expect(add1(1)(2)(3), 6).toBe()
|
||||
const add = x => y => z => x + y + z;
|
||||
const add1 = uncurry(add);
|
||||
const add2 = uncurry(add, 2);
|
||||
const add3 = uncurry(add, 3);
|
||||
test('Works without a provided value for n', () => {
|
||||
expect(add1(1)(2)(3)).toBe(6);
|
||||
});
|
||||
test('Works without n = 2', () => {
|
||||
expect(add2(1,2)(3), 6).toBe()
|
||||
test('Works with n = 2', () => {
|
||||
expect(add2(1,2)(3)).toBe(6);
|
||||
});
|
||||
test('Works withoutn = 3', () => {
|
||||
expect(add3(1,2,3), 6).toBe()
|
||||
test('Works with n = 3', () => {
|
||||
expect(add3(1,2,3)).toBe(6);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const unescapeHTML = require('./unescapeHTML.js');
|
||||
|
||||
|
||||
test('unescapeHTML is a Function', () => {
|
||||
test('unescapeHTML is a Function', () => {
|
||||
expect(unescapeHTML).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Unescapes escaped HTML characters.', () => {
|
||||
expect(unescapeHTML('<a href="#">Me & you</a>'), '<a href="#">Me & you</a>').toBe()
|
||||
test('Unescapes escaped HTML characters.', () => {
|
||||
expect(unescapeHTML('<a href="#">Me & you</a>')).toBe('<a href="#">Me & you</a>');
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const unflattenObject = require('./unflattenObject.js');
|
||||
|
||||
|
||||
test('unflattenObject is a Function', () => {
|
||||
test('unflattenObject is a Function', () => {
|
||||
expect(unflattenObject).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Unflattens an object with the paths for keys', () => {
|
||||
expect(unflattenObject({ 'a.b.c': 1, d: 1 }), { a: { b: { c: 1 } }, d: 1 }).toEqual()
|
||||
test('Unflattens an object with the paths for keys', () => {
|
||||
expect(unflattenObject({ 'a.b.c': 1, d: 1 })).toEqual({ a: { b: { c: 1 } }, d: 1 });
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const unfold = require('./unfold.js');
|
||||
|
||||
|
||||
test('unfold is a Function', () => {
|
||||
test('unfold is a Function', () => {
|
||||
expect(unfold).toBeInstanceOf(Function);
|
||||
});
|
||||
var f = n => (n > 50 ? false : [-n, n + 10]);
|
||||
test('Works with a given function, producing an array', () => {
|
||||
expect(unfold(f, 10), [-10, -20, -30, -40, -50]).toEqual()
|
||||
var f = n => (n > 50 ? false : [-n, n + 10]);
|
||||
test('Works with a given function, producing an array', () => {
|
||||
expect(unfold(f, 10)).toEqual([-10, -20, -30, -40, -50]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,34 +1,42 @@
|
||||
const expect = require('expect');
|
||||
const union = require('./union.js');
|
||||
|
||||
|
||||
test('union is a Function', () => {
|
||||
test('union is a Function', () => {
|
||||
expect(union).toBeInstanceOf(Function);
|
||||
});
|
||||
test('union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4]', () => {
|
||||
expect(union([1, 2, 3], [4, 3, 2]), [1, 2, 3).toEqual(4])
|
||||
test('union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4]', () => {
|
||||
expect(union([1, 2, 3], [4, 3, 2])).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
test('union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ]', () => {
|
||||
expect(union('str', 'asd'), [ 's', 't', 'r', 'a').toEqual('d' ])
|
||||
test('union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ]', () => {
|
||||
expect(union('str', 'asd')).toEqual([ 's', 't', 'r', 'a', 'd' ]);
|
||||
});
|
||||
test('union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3]', () => {
|
||||
expect(union([[], {}], [1, 2, 3]), [[], {}, 1, 2).toEqual(3])
|
||||
test('union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3]', () => {
|
||||
expect(union([[], {}], [1, 2, 3])).toEqual([[], {}, 1, 2, 3]);
|
||||
});
|
||||
test('union([], []) returns []', () => {
|
||||
expect(union([], [])).toEqual([])
|
||||
test('union([], []) returns []', () => {
|
||||
expect(union([], [])).toEqual([]);
|
||||
});
|
||||
t.throws(() => union(), 'union() throws an error');
|
||||
t.throws(() => union(true, 'str'), 'union(true, str) throws an error');
|
||||
t.throws(() => union('false', true), 'union(false, true) throws an error');
|
||||
t.throws(() => union(123, {}), 'union(123, {}) throws an error');
|
||||
t.throws(() => union([], {}), 'union([], {}) throws an error');
|
||||
t.throws(() => union(undefined, null), 'union(undefined, null) throws an error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
union([1, 2, 3], [4, 3, 2]);
|
||||
let end = new Date().getTime();
|
||||
test('union([1, 2, 3], [4, 3, 2]) takes less than 2s to run', () => {
|
||||
test('union() throws an error', () => {
|
||||
expect(union()).toThrow();
|
||||
});
|
||||
test('union(true, \'str\') throws an error', () => {
|
||||
expect(union(true, 'str')).toThrow();
|
||||
});
|
||||
test('union(\'false\', true) throws an error', () => {
|
||||
expect(union('false', true)).toThrow();
|
||||
});
|
||||
test('union((123, {}) throws an error', () => {
|
||||
expect(union((123, {})).toThrow();
|
||||
});
|
||||
test('union([], {}) throws an error', () => {
|
||||
expect(union([], {})).toThrow();
|
||||
});
|
||||
test('union(undefined, null) throws an error', () => {
|
||||
expect(union(undefined, null)).toThrow();
|
||||
});
|
||||
let start = new Date().getTime();
|
||||
union([1, 2, 3], [4, 3, 2]);
|
||||
let end = new Date().getTime();
|
||||
test('union([1, 2, 3], [4, 3, 2]) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const unionBy = require('./unionBy.js');
|
||||
|
||||
|
||||
test('unionBy is a Function', () => {
|
||||
test('unionBy is a Function', () => {
|
||||
expect(unionBy).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Produces the appropriate results', () => {
|
||||
expect(unionBy([2.1], [1.2, 2.3], Math.floor), [2.1, 1.2]).toEqual()
|
||||
test('Produces the appropriate results', () => {
|
||||
expect(unionBy([2.1], [1.2, 2.3], Math.floor)).toEqual([2.1, 1.2]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const unionWith = require('./unionWith.js');
|
||||
|
||||
|
||||
test('unionWith is a Function', () => {
|
||||
test('unionWith is a Function', () => {
|
||||
expect(unionWith).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Produces the appropriate results', () => {
|
||||
expect(unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)), [1, 1.2, 1.5, 3, 0, 3.9]).toEqual()
|
||||
test('Produces the appropriate results', () => {
|
||||
expect(unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b))).toEqual([1, 1.2, 1.5, 3, 0, 3.9]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -2,43 +2,45 @@ const expect = require('expect');
|
||||
const uniqueElements = require('./uniqueElements.js');
|
||||
|
||||
|
||||
test('uniqueElements is a Function', () => {
|
||||
test('uniqueElements is a Function', () => {
|
||||
expect(uniqueElements).toBeInstanceOf(Function);
|
||||
});
|
||||
test('uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5]', () => {
|
||||
expect(uniqueElements([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4).toEqual(5])
|
||||
test('uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5]', () => {
|
||||
expect(uniqueElements([1, 2, 2, 3, 4, 4, 5])).toEqual([1,2,3,4,5]);
|
||||
});
|
||||
test('uniqueElements([1, 23, 53]) returns [1, 23, 53]', () => {
|
||||
expect(uniqueElements([1, 23, 53]), [1, 23).toEqual(53])
|
||||
test('uniqueElements([1, 23, 53]) returns [1, 23, 53]', () => {
|
||||
expect(uniqueElements([1, 23, 53])).toEqual([1, 23, 53]);
|
||||
});
|
||||
test('uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, '']', () => {
|
||||
expect(uniqueElements([true, 0, 1, false, false, undefined, null, '']), [true, 0, 1, false, undefined, null).toEqual(''])
|
||||
test('uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, '']', () => {
|
||||
expect(uniqueElements([true, 0, 1, false, false, undefined, null, ''])).toEqual([true, 0, 1, false, undefined, null, '']);
|
||||
});
|
||||
test('uniqueElements() returns []', () => {
|
||||
expect(uniqueElements()).toEqual([])
|
||||
test('uniqueElements() returns []', () => {
|
||||
expect(uniqueElements()).toEqual([]);
|
||||
});
|
||||
test('uniqueElements(null) returns []', () => {
|
||||
expect(uniqueElements(null)).toEqual([])
|
||||
test('uniqueElements(null) returns []', () => {
|
||||
expect(uniqueElements(null)).toEqual([]);
|
||||
});
|
||||
test('uniqueElements(undefined) returns []', () => {
|
||||
expect(uniqueElements(undefined)).toEqual([])
|
||||
test('uniqueElements(undefined) returns []', () => {
|
||||
expect(uniqueElements(undefined)).toEqual([]);
|
||||
});
|
||||
test('uniqueElements('strt') returns ['s', 't', 'r']', () => {
|
||||
expect(uniqueElements('strt'), ['s', 't').toEqual('r'])
|
||||
test('uniqueElements(\'strt\') returns ['s', 't', 'r']', () => {
|
||||
expect(uniqueElements('strt')).toEqual(['s', 't', 'r']);
|
||||
});
|
||||
t.throws(() => uniqueElements(1, 1, 2543, 534, 5), 'uniqueElements(1, 1, 2543, 534, 5) throws an error');
|
||||
t.throws(() => uniqueElements({}), 'uniqueElements({}) throws an error');
|
||||
t.throws(() => uniqueElements(true), 'uniqueElements(true) throws an error');
|
||||
t.throws(() => uniqueElements(false), 'uniqueElements(false) throws an error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
uniqueElements([true, 0, 1, false, false, undefined, null, '']);
|
||||
let end = new Date().getTime();
|
||||
test('uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run', () => {
|
||||
test('uniqueElements(1, 1, 2543, 534, 5) throws an error', () => {
|
||||
expect(uniqueElements(1, 1, 2543, 534, 5)).toThrow();
|
||||
});
|
||||
test('uniqueElements({}) throws an error', () => {
|
||||
expect(uniqueElements({})).toThrow();
|
||||
});
|
||||
test('uniqueElements(true) throws an error', () => {
|
||||
expect(uniqueElements(true)).toThrow();
|
||||
});
|
||||
test('uniqueElements(false) throws an error', () => {
|
||||
expect(uniqueElements(false)).toThrow();
|
||||
});
|
||||
let start = new Date().getTime();
|
||||
uniqueElements([true, 0, 1, false, false, undefined, null, '']);
|
||||
let end = new Date().getTime();
|
||||
test('uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
uniqueElements([1, 2, 2, '1', 4, 4, 4, 5, true]);
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const untildify = require('./untildify.js');
|
||||
|
||||
|
||||
test('untildify is a Function', () => {
|
||||
test('untildify is a Function', () => {
|
||||
expect(untildify).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Contains no tildes', () => {
|
||||
test('Contains no tildes', () => {
|
||||
expect(untildify('~/test/dir/file.f').indexOf('~') === -1).toBeTruthy();
|
||||
});
|
||||
test('Does not alter the rest of the path', () => {
|
||||
expect(untildify('~/test/dir/file.f').slice(-16), '/test/dir/file.f').toBe()
|
||||
test('Does not alter the rest of the path', () => {
|
||||
expect(untildify('~/test/dir/file.f').slice(-16)).toBe('/test/dir/file.f');
|
||||
});
|
||||
test('Does not alter paths without tildes', () => {
|
||||
expect(untildify('test/dir/file.f'), 'test/dir/file.f').toBe()
|
||||
test('Does not alter paths without tildes', () => {
|
||||
expect(untildify('test/dir/file.f')).toBe('test/dir/file.f');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const unzip = require('./unzip.js');
|
||||
|
||||
|
||||
test('unzip is a Function', () => {
|
||||
test('unzip is a Function', () => {
|
||||
expect(unzip).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(unzip([['a', 1, true], ['b', 2, false]]), [['a', 'b'], [1, 2], [true, false]], `unzip([['a', 1, true], ['b', 2, false]]) equals [['a', 'b'], [1, 2], [true, false]]`);
|
||||
t.deepEqual(unzip([['a', 1, true], ['b', 2]]), [['a', 'b'], [1, 2], [true]], `unzip([['a', 1, true], ['b', 2]]) equals [['a', 'b'], [1, 2], [true]]`);
|
||||
|
||||
|
||||
test('unzip([[\'a\', 1, true], [\'b\', 2, false]]) equals [[\'a\',\'b\'], [1, 2], [true, false]]', () => {
|
||||
expect(unzip([['a', 1, true], ['b', 2, false]])).toBe([['a', 'b'], [1, 2], [true, false]]);
|
||||
});
|
||||
test('unzip([[\'a\', 1, true], [\'b\', 2]]) equals [[\'a\',\'b\'], [1, 2], [true]]', () => {
|
||||
expect(unzip([['a', 1, true], ['b', 2]])).toBe([['a', 'b'], [1, 2], [true]]);
|
||||
});
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const unzipWith = require('./unzipWith.js');
|
||||
|
||||
|
||||
test('unzipWith is a Function', () => {
|
||||
test('unzipWith is a Function', () => {
|
||||
expect(unzipWith).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)), [3, 30, 300], `unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300]`);
|
||||
|
||||
|
||||
test('unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300]', () => {
|
||||
expect(unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0))).toBe([3, 30, 300]);
|
||||
});
|
||||
|
||||
@ -1,46 +1,42 @@
|
||||
const expect = require('expect');
|
||||
const validateNumber = require('./validateNumber.js');
|
||||
|
||||
|
||||
test('validateNumber is a Function', () => {
|
||||
test('validateNumber is a Function', () => {
|
||||
expect(validateNumber).toBeInstanceOf(Function);
|
||||
});
|
||||
test('validateNumber(9) returns true', () => {
|
||||
test('validateNumber(9) returns true', () => {
|
||||
expect(validateNumber(9)).toBeTruthy();
|
||||
});
|
||||
test('validateNumber(234asd.slice(0, 2)) returns true', () => {
|
||||
test('validateNumber(234asd.slice(0, 2)) returns true', () => {
|
||||
expect(validateNumber('234asd'.slice(0, 2))).toBeTruthy();
|
||||
});
|
||||
test('validateNumber(1232) returns true', () => {
|
||||
test('validateNumber(1232) returns true', () => {
|
||||
expect(validateNumber(1232)).toBeTruthy();
|
||||
});
|
||||
test('validateNumber(1232 + 13423) returns true', () => {
|
||||
test('validateNumber(1232 + 13423) returns true', () => {
|
||||
expect(validateNumber(1232 + 13423)).toBeTruthy();
|
||||
});
|
||||
test('validateNumber(1232 * 2342 * 123) returns true', () => {
|
||||
test('validateNumber(1232 * 2342 * 123) returns true', () => {
|
||||
expect(validateNumber(1232 * 2342 * 123)).toBeTruthy();
|
||||
});
|
||||
test('validateNumber(1232.23423536) returns true', () => {
|
||||
test('validateNumber(1232.23423536) returns true', () => {
|
||||
expect(validateNumber(1232.23423536)).toBeTruthy();
|
||||
});
|
||||
test('validateNumber(234asd) returns false', () => {
|
||||
test('validateNumber(234asd) returns false', () => {
|
||||
expect(validateNumber('234asd')).toBeFalsy();
|
||||
});
|
||||
test('validateNumber(e234d) returns false', () => {
|
||||
test('validateNumber(e234d) returns false', () => {
|
||||
expect(validateNumber('e234d')).toBeFalsy();
|
||||
});
|
||||
test('validateNumber(false) returns false', () => {
|
||||
test('validateNumber(false) returns false', () => {
|
||||
expect(validateNumber(false)).toBeFalsy();
|
||||
});
|
||||
test('validateNumber(true) returns false', () => {
|
||||
test('validateNumber(true) returns false', () => {
|
||||
expect(validateNumber(true)).toBeFalsy();
|
||||
});
|
||||
test('validateNumber(null) returns false', () => {
|
||||
test('validateNumber(null) returns false', () => {
|
||||
expect(validateNumber(null)).toBeFalsy();
|
||||
});
|
||||
test('validateNumber(123 * asd) returns false', () => {
|
||||
test('validateNumber(123 * asd) returns false', () => {
|
||||
expect(validateNumber(123 * 'asd')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user