Test cleanup and fixes [i-l]
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const JSONToDate = require('./JSONToDate.js');
|
||||
|
||||
|
||||
test('JSONToDate is a Function', () => {
|
||||
test('JSONToDate is a Function', () => {
|
||||
expect(JSONToDate).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const JSONToFile = require('./JSONToFile.js');
|
||||
|
||||
|
||||
test('JSONToFile is a Function', () => {
|
||||
test('JSONToFile is a Function', () => {
|
||||
expect(JSONToFile).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
const expect = require('expect');
|
||||
const inRange = require('./inRange.js');
|
||||
|
||||
|
||||
test('inRange is a Function', () => {
|
||||
test('inRange is a Function', () => {
|
||||
expect(inRange).toBeInstanceOf(Function);
|
||||
});
|
||||
test('The given number falls within the given range', () => {
|
||||
expect(inRange(3, 2, 5)).toBe(true)
|
||||
test('The given number falls within the given range', () => {
|
||||
expect(inRange(3, 2, 5)).toBeTruthy();
|
||||
});
|
||||
test('The given number falls within the given range', () => {
|
||||
expect(inRange(3, 4)).toBe(true)
|
||||
test('The given number falls within the given range', () => {
|
||||
expect(inRange(3, 4)).toBeTruthy();
|
||||
});
|
||||
test('The given number does not falls within the given range', () => {
|
||||
expect(inRange(2, 3, 5)).toBe(false)
|
||||
test('The given number does not falls within the given range', () => {
|
||||
expect(inRange(2, 3, 5)).toBeFalsy();
|
||||
});
|
||||
test('The given number does not falls within the given range', () => {
|
||||
expect(inRange(3, 2)).toBe(false)
|
||||
test('The given number does not falls within the given range', () => {
|
||||
expect(inRange(3, 2)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const indexOfAll = require('./indexOfAll.js');
|
||||
|
||||
|
||||
test('indexOfAll is a Function', () => {
|
||||
test('indexOfAll is a Function', () => {
|
||||
expect(indexOfAll).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns all indices of val in an array', () => {
|
||||
expect(indexOfAll([1, 2, 3, 1, 2, 3], 1), [0).toEqual(3])
|
||||
test('Returns all indices of val in an array', () => {
|
||||
expect(indexOfAll([1, 2, 3, 1, 2, 3], 1)).toEqual([0,3]);
|
||||
});
|
||||
test('Returns all indices of val in an array', () => {
|
||||
expect(indexOfAll([1, 2, 3], 4)).toEqual([])
|
||||
test('Returns all indices of val in an array', () => {
|
||||
expect(indexOfAll([1, 2, 3], 4)).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const initial = require('./initial.js');
|
||||
|
||||
|
||||
test('initial is a Function', () => {
|
||||
test('initial is a Function', () => {
|
||||
expect(initial).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns all the elements of an array except the last one', () => {
|
||||
expect(initial([1, 2, 3]), [1).toEqual(2])
|
||||
test('Returns all the elements of an array except the last one', () => {
|
||||
expect(initial([1, 2, 3])).toEqual([1, 2])''
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const initialize2DArray = require('./initialize2DArray.js');
|
||||
|
||||
|
||||
test('initialize2DArray is a Function', () => {
|
||||
test('initialize2DArray is a Function', () => {
|
||||
expect(initialize2DArray).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Initializes a 2D array of given width and height and value', () => {
|
||||
expect(initialize2DArray(2, 2, 0), [[0,0], [0).toEqual(0]])
|
||||
test('Initializes a 2D array of given width and height and value', () => {
|
||||
expect(initialize2DArray(2, 2, 0)).toEqual([[0,0], [0,0]]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const initializeArrayWithRange = require('./initializeArrayWithRange.js');
|
||||
|
||||
|
||||
test('initializeArrayWithRange is a Function', () => {
|
||||
test('initializeArrayWithRange is a Function', () => {
|
||||
expect(initializeArrayWithRange).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Initializes an array containing the numbers in the specified range', () => {
|
||||
expect(initializeArrayWithRange(5), [0, 1, 2, 3, 4).toEqual(5])
|
||||
test('Initializes an array containing the numbers in the specified range', () => {
|
||||
expect(initializeArrayWithRange(5)).toEqual([0, 1, 2, 3, 4, 5]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const initializeArrayWithRangeRight = require('./initializeArrayWithRangeRight.js');
|
||||
|
||||
|
||||
test('initializeArrayWithRangeRight is a Function', () => {
|
||||
test('initializeArrayWithRangeRight is a Function', () => {
|
||||
expect(initializeArrayWithRangeRight).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const initializeArrayWithValues = require('./initializeArrayWithValues.js');
|
||||
|
||||
|
||||
test('initializeArrayWithValues is a Function', () => {
|
||||
test('initializeArrayWithValues is a Function', () => {
|
||||
expect(initializeArrayWithValues).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Initializes and fills an array with the specified values', () => {
|
||||
expect(initializeArrayWithValues(5, 2), [2, 2, 2, 2).toEqual(2])
|
||||
test('Initializes and fills an array with the specified values', () => {
|
||||
expect(initializeArrayWithValues(5, 2)).toEqual([2, 2, 2, 2, 2])
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const initializeNDArray = require('./initializeNDArray.js');
|
||||
|
||||
|
||||
test('initializeNDArray is a Function', () => {
|
||||
test('initializeNDArray is a Function', () => {
|
||||
expect(initializeNDArray).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const intersection = require('./intersection.js');
|
||||
|
||||
|
||||
test('intersection is a Function', () => {
|
||||
test('intersection is a Function', () => {
|
||||
expect(intersection).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns a list of elements that exist in both arrays', () => {
|
||||
expect(intersection([1, 2, 3], [4, 3, 2]), [2).toEqual(3])
|
||||
test('Returns a list of elements that exist in both arrays', () => {
|
||||
expect(intersection([1, 2, 3], [4, 3, 2])).toEqual([2, 3]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const intersectionBy = require('./intersectionBy.js');
|
||||
|
||||
|
||||
test('intersectionBy is a Function', () => {
|
||||
test('intersectionBy is a Function', () => {
|
||||
expect(intersectionBy).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both', () => {
|
||||
expect(intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor), [2.1]).toEqual()
|
||||
test('Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both', () => {
|
||||
expect(intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor)).toEqual([2.1]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const intersectionWith = require('./intersectionWith.js');
|
||||
|
||||
|
||||
test('intersectionWith is a Function', () => {
|
||||
test('intersectionWith is a Function', () => {
|
||||
expect(intersectionWith).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns a list of elements that exist in both arrays, using a provided comparator function', () => {
|
||||
expect(intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)), [1.5, 3, 0]).toEqual()
|
||||
test('Returns a list of elements that exist in both arrays, using a provided comparator function', () => {
|
||||
expect(intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b))).toEqual([1.5, 3, 0]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const invertKeyValues = require('./invertKeyValues.js');
|
||||
|
||||
|
||||
test('invertKeyValues is a Function', () => {
|
||||
test('invertKeyValues is a Function', () => {
|
||||
expect(invertKeyValues).toBeInstanceOf(Function);
|
||||
});
|
||||
test('invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] }', () => {
|
||||
expect(invertKeyValues({ a: 1, b: 2, c: 1 }), { 1: [ 'a', 'c' ]).toEqual(2: [ 'b' ] })
|
||||
test('invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] }', () => {
|
||||
expect(invertKeyValues({ a: 1, b: 2, c: 1 })).toEqual({ 1: [ 'a', 'c' ], 2: [ 'b' ] });
|
||||
});
|
||||
test('invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] }', () => {
|
||||
expect(invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value), { group1: [ 'a', 'c' ]).toEqual(group2: [ 'b' ] })
|
||||
test('invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] }', () => {
|
||||
expect(invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value)).toEqual( { group1: [ 'a', 'c' ], group2: [ 'b' ] });
|
||||
});
|
||||
|
||||
|
||||
@ -1,25 +1,54 @@
|
||||
const expect = require('expect');
|
||||
const is = require('./is.js');
|
||||
|
||||
|
||||
test('is is a Function', () => {
|
||||
test('is is a Function', () => {
|
||||
expect(is).toBeInstanceOf(Function);
|
||||
});
|
||||
t.true(is(Array, [1]), `Works for arrays with data`);
|
||||
t.true(is(Array, []), `Works for empty arrays`);
|
||||
t.false(is(Array, {}), `Works for arrays, not objects`);
|
||||
t.true(is(Object, {}), `Works for objects`);
|
||||
t.true(is(Map, new Map()), `Works for maps`);
|
||||
t.true(is(RegExp, /./g), `Works for regular expressions`);
|
||||
t.true(is(Set, new Set()), `Works for sets`);
|
||||
t.true(is(WeakMap, new WeakMap()), `Works for weak maps`);
|
||||
t.true(is(WeakSet, new WeakSet()), `Works for weak sets`);
|
||||
t.true(is(String, ''), `Works for strings - returns true for primitive`);
|
||||
t.true(is(String, new String('')), `Works for strings - returns true when using constructor`);
|
||||
t.true(is(Number, 1), `Works for numbers - returns true for primitive`);
|
||||
t.true(is(Number, new Number('10')), `Works for numbers - returns true when using constructor`);
|
||||
t.true(is(Boolean, false), `Works for booleans - returns true for primitive`);
|
||||
t.true(is(Boolean, new Boolean(false)), `Works for booleans - returns true when using constructor`);
|
||||
t.true(is(Function, () => null), `Works for functions`);
|
||||
|
||||
|
||||
test('Works for arrays with data', () => {
|
||||
expect(is(Array, [1])).toBeTruthy();
|
||||
});
|
||||
test('Works for empty arrays', () => {
|
||||
expect(is(Array, [])).toBeTruthy()
|
||||
});
|
||||
test('Works for arrays, not objects', () => {
|
||||
expect(is(Array, {})).toBeFalsy();
|
||||
});
|
||||
test('Works for objects', () => {
|
||||
expect(is(Object, {})).toBeTruthy();
|
||||
});
|
||||
test('Works for maps', () => {
|
||||
expect(is(Map, new Map())).toBeTruthy();
|
||||
});
|
||||
test('Works for regular expressions', () => {
|
||||
expect(is(RegExp, /./g)).toBeTruthy();
|
||||
});
|
||||
test('Works for sets', () => {
|
||||
expect(is(Set, new Set())).toBeTruthy();
|
||||
});
|
||||
test('Works for weak maps', () => {
|
||||
expect(is(WeakMap, new WeakMap())).toBeTruthy();
|
||||
});
|
||||
test('Works for weak sets', () => {
|
||||
expect(is(WeakSet, new WeakSet())).toBeTruthy();
|
||||
});
|
||||
test('Works for strings - returns true for primitive', () => {
|
||||
expect(is(String, '')).toBeTruthy();
|
||||
});
|
||||
test('Works for strings - returns true when using constructor', () => {
|
||||
expect(is(String, new String(''))).toBeTruthy();
|
||||
});
|
||||
test('Works for numbers - returns true for primitive', () => {
|
||||
expect(is(Number, 1)).toBeTruthy();
|
||||
});
|
||||
test('Works for numbers - returns true when using constructor', () => {
|
||||
expect(is(Number, new Number('10'))).toBeTruthy()
|
||||
});
|
||||
test('Works for booleans - returns true for primitive', () => {
|
||||
expect(is(Boolean, false)).toBeTruthy()
|
||||
});
|
||||
test('Works for booleans - returns true when using constructor', () => {
|
||||
expect(is(Boolean, new Boolean(false))).toBeTruthy();
|
||||
});
|
||||
test('Works for functions', () => {
|
||||
expect(is(Function, () => null)).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const isAbsoluteURL = require('./isAbsoluteURL.js');
|
||||
|
||||
|
||||
test('isAbsoluteURL is a Function', () => {
|
||||
test('isAbsoluteURL is a Function', () => {
|
||||
expect(isAbsoluteURL).toBeInstanceOf(Function);
|
||||
});
|
||||
t.equal(isAbsoluteURL('https:
|
||||
t.equal(isAbsoluteURL('ftp:
|
||||
test('Given string is not an absolute URL', () => {
|
||||
expect(isAbsoluteURL('/foo/bar')).toBe(false)
|
||||
test('Given string is an absolute URL', () => {
|
||||
expect(isAbsoluteURL('https://google.com')).toBeTruthy();
|
||||
});
|
||||
test('Given string is an absolute URL', () => {
|
||||
expect(isAbsoluteURL('ftp://www.myserver.net')).toBeTruthy();
|
||||
});
|
||||
test('Given string is not an absolute URL', () => {
|
||||
expect(isAbsoluteURL('/foo/bar')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,21 +1,18 @@
|
||||
const expect = require('expect');
|
||||
const isAnagram = require('./isAnagram.js');
|
||||
|
||||
|
||||
test('isAnagram is a Function', () => {
|
||||
test('isAnagram is a Function', () => {
|
||||
expect(isAnagram).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Checks valid anagram', () => {
|
||||
test('Checks valid anagram', () => {
|
||||
expect(isAnagram('iceman', 'cinema')).toBeTruthy();
|
||||
});
|
||||
test('Works with spaces', () => {
|
||||
test('Works with spaces', () => {
|
||||
expect(isAnagram('rail safety', 'fairy tales')).toBeTruthy();
|
||||
});
|
||||
test('Ignores case', () => {
|
||||
test('Ignores case', () => {
|
||||
expect(isAnagram('roast beef', 'eat for BSE')).toBeTruthy();
|
||||
});
|
||||
test('Ignores special characters', () => {
|
||||
test('Ignores special characters', () => {
|
||||
expect(isAnagram('Regera Dowdy', 'E. G. Deadworry')).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isArmstrongNumber = require('./isArmstrongNumber.js');
|
||||
|
||||
|
||||
test('isArmstrongNumber is a Function', () => {
|
||||
test('isArmstrongNumber is a Function', () => {
|
||||
expect(isArmstrongNumber).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isArray = require('./isArray.js');
|
||||
|
||||
|
||||
test('isArray is a Function', () => {
|
||||
test('isArray is a Function', () => {
|
||||
expect(isArray).toBeInstanceOf(Function);
|
||||
});
|
||||
test('passed value is an array', () => {
|
||||
expect(isArray([1])).toBe(true)
|
||||
test('passed value is an array', () => {
|
||||
expect(isArray([1])).toBeTruthy()
|
||||
});
|
||||
test('passed value is not an array', () => {
|
||||
expect(isArray('array')).toBe(false)
|
||||
test('passed value is not an array', () => {
|
||||
expect(isArray('array')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isArrayBuffer = require('./isArrayBuffer.js');
|
||||
|
||||
|
||||
test('isArrayBuffer is a Function', () => {
|
||||
test('isArrayBuffer is a Function', () => {
|
||||
expect(isArrayBuffer).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const isArrayLike = require('./isArrayLike.js');
|
||||
|
||||
|
||||
test('isArrayLike is a Function', () => {
|
||||
test('isArrayLike is a Function', () => {
|
||||
expect(isArrayLike).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns true for a string', () => {
|
||||
expect(isArrayLike('abc'), true).toBe()
|
||||
test('Returns true for a string', () => {
|
||||
expect(isArrayLike('abc')).toBeTruthy()
|
||||
});
|
||||
test('Returns true for an array', () => {
|
||||
expect(isArrayLike([1,2,3]), true).toBe()
|
||||
test('Returns true for an array', () => {
|
||||
expect(isArrayLike([1,2,3])).toBeTruthy();
|
||||
});
|
||||
test('Returns false for null', () => {
|
||||
expect(isArrayLike(null), false).toBe()
|
||||
test('Returns false for null', () => {
|
||||
expect(isArrayLike(null)).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isBoolean = require('./isBoolean.js');
|
||||
|
||||
|
||||
test('isBoolean is a Function', () => {
|
||||
test('isBoolean is a Function', () => {
|
||||
expect(isBoolean).toBeInstanceOf(Function);
|
||||
});
|
||||
test('passed value is not a boolean', () => {
|
||||
expect(isBoolean(null)).toBe(false)
|
||||
test('passed value is not a boolean', () => {
|
||||
expect(isBoolean(null)).toBeFalsy();
|
||||
});
|
||||
test('passed value is not a boolean', () => {
|
||||
expect(isBoolean(false)).toBe(true)
|
||||
test('passed value is not a boolean', () => {
|
||||
expect(isBoolean(false)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isBrowser = require('./isBrowser.js');
|
||||
|
||||
|
||||
test('isBrowser is a Function', () => {
|
||||
test('isBrowser is a Function', () => {
|
||||
expect(isBrowser).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isBrowserTabFocused = require('./isBrowserTabFocused.js');
|
||||
|
||||
|
||||
test('isBrowserTabFocused is a Function', () => {
|
||||
test('isBrowserTabFocused is a Function', () => {
|
||||
expect(isBrowserTabFocused).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const isDivisible = require('./isDivisible.js');
|
||||
|
||||
|
||||
test('isDivisible is a Function', () => {
|
||||
test('isDivisible is a Function', () => {
|
||||
expect(isDivisible).toBeInstanceOf(Function);
|
||||
});
|
||||
test('The number 6 is divisible by 3', () => {
|
||||
expect(isDivisible(6, 3), true).toBe()
|
||||
test('The number 6 is divisible by 3', () => {
|
||||
expect(isDivisible(6, 3)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,39 +1,36 @@
|
||||
const expect = require('expect');
|
||||
const isEmpty = require('./isEmpty.js');
|
||||
|
||||
|
||||
test('isEmpty is a Function', () => {
|
||||
test('isEmpty is a Function', () => {
|
||||
expect(isEmpty).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns true for empty Map', () => {
|
||||
expect(isEmpty(new Map()), true).toBe()
|
||||
test('Returns true for empty Map', () => {
|
||||
expect(isEmpty(new Map())).toBeTruthy();
|
||||
});
|
||||
test('Returns true for empty Set', () => {
|
||||
expect(isEmpty(new Set()), true).toBe()
|
||||
test('Returns true for empty Set', () => {
|
||||
expect(isEmpty(new Set())).toBeTruthy();
|
||||
});
|
||||
test('Returns true for empty array', () => {
|
||||
expect(isEmpty([]), true).toBe()
|
||||
test('Returns true for empty array', () => {
|
||||
expect(isEmpty([])).toBeTruthy();
|
||||
});
|
||||
test('Returns true for empty object', () => {
|
||||
expect(isEmpty({}), true).toBe()
|
||||
test('Returns true for empty object', () => {
|
||||
expect(isEmpty({})).toBeTruthy();
|
||||
});
|
||||
test('Returns true for empty string', () => {
|
||||
expect(isEmpty(''), true).toBe()
|
||||
test('Returns true for empty string', () => {
|
||||
expect(isEmpty('')).toBeTruthy();
|
||||
});
|
||||
test('Returns false for non-empty array', () => {
|
||||
expect(isEmpty([1, 2]), false).toBe()
|
||||
test('Returns false for non-empty array', () => {
|
||||
expect(isEmpty([1, 2])).toBeFalsy();
|
||||
});
|
||||
test('Returns false for non-empty object', () => {
|
||||
expect(isEmpty({ a: 1, b: 2 }), false).toBe()
|
||||
test('Returns false for non-empty object', () => {
|
||||
expect(isEmpty({ a: 1, b: 2 })).toBeFalsy();
|
||||
});
|
||||
test('Returns false for non-empty string', () => {
|
||||
expect(isEmpty('text'), false).toBe()
|
||||
test('Returns false for non-empty string', () => {
|
||||
expect(isEmpty('text')).toBeFalsy();
|
||||
});
|
||||
test('Returns true - type is not considered a collection', () => {
|
||||
expect(isEmpty(123), true).toBe()
|
||||
test('Returns true - type is not considered a collection', () => {
|
||||
expect(isEmpty(123)).toBeTruthy();
|
||||
});
|
||||
test('Returns true - type is not considered a collection', () => {
|
||||
expect(isEmpty(true), true).toBe()
|
||||
test('Returns true - type is not considered a collection', () => {
|
||||
expect(isEmpty(true)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isEven = require('./isEven.js');
|
||||
|
||||
|
||||
test('isEven is a Function', () => {
|
||||
test('isEven is a Function', () => {
|
||||
expect(isEven).toBeInstanceOf(Function);
|
||||
});
|
||||
test('4 is even number', () => {
|
||||
expect(isEven(4), true).toBe()
|
||||
test('4 is even number', () => {
|
||||
expect(isEven(4)).toBeTruthy();
|
||||
});
|
||||
test('5 is not an even number', () => {
|
||||
expect(isEven(5), false).toBeFalsy();
|
||||
test('5 is not an even number', () => {
|
||||
expect(isEven(5)).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
const expect = require('expect');
|
||||
const isFunction = require('./isFunction.js');
|
||||
|
||||
|
||||
test('isFunction is a Function', () => {
|
||||
test('isFunction is a Function', () => {
|
||||
expect(isFunction).toBeInstanceOf(Function);
|
||||
});
|
||||
test('passed value is a function', () => {
|
||||
expect(isFunction(x => x)).toBe(true)
|
||||
test('passed value is a function', () => {
|
||||
expect(isFunction(x => x)).toBeTruthy();
|
||||
});
|
||||
test('passed value is not a function', () => {
|
||||
expect(isFunction('x')).toBe(false)
|
||||
test('passed value is not a function', () => {
|
||||
expect(isFunction('x')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const isLowerCase = require('./isLowerCase.js');
|
||||
|
||||
|
||||
test('isLowerCase is a Function', () => {
|
||||
test('isLowerCase is a Function', () => {
|
||||
expect(isLowerCase).toBeInstanceOf(Function);
|
||||
});
|
||||
test('passed string is a lowercase', () => {
|
||||
expect(isLowerCase('abc')).toBe(true)
|
||||
test('passed string is a lowercase', () => {
|
||||
expect(isLowerCase('abc')).toBeTruthy();
|
||||
});
|
||||
test('passed string is a lowercase', () => {
|
||||
expect(isLowerCase('a3@$')).toBe(true)
|
||||
test('passed string is a lowercase', () => {
|
||||
expect(isLowerCase('a3@$')).toBeTruthy();
|
||||
});
|
||||
test('passed value is not a lowercase', () => {
|
||||
expect(isLowerCase('A3@$')).toBe(false)
|
||||
test('passed value is not a lowercase', () => {
|
||||
expect(isLowerCase('A3@$')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isMap = require('./isMap.js');
|
||||
|
||||
|
||||
test('isMap is a Function', () => {
|
||||
test('isMap is a Function', () => {
|
||||
expect(isMap).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const isNil = require('./isNil.js');
|
||||
|
||||
|
||||
test('isNil is a Function', () => {
|
||||
test('isNil is a Function', () => {
|
||||
expect(isNil).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns true for null', () => {
|
||||
expect(isNil(null), true).toBe()
|
||||
test('Returns true for null', () => {
|
||||
expect(isNil(null)).toBeTruthy();
|
||||
});
|
||||
test('Returns true for undefined', () => {
|
||||
expect(isNil(undefined), true).toBe()
|
||||
test('Returns true for undefined', () => {
|
||||
expect(isNil(undefined)).toBeTruthy();
|
||||
});
|
||||
test('Returns false for an empty string', () => {
|
||||
expect(isNil(''), false).toBe()
|
||||
test('Returns false for an empty string', () => {
|
||||
expect(isNil('')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isNull = require('./isNull.js');
|
||||
|
||||
|
||||
test('isNull is a Function', () => {
|
||||
test('isNull is a Function', () => {
|
||||
expect(isNull).toBeInstanceOf(Function);
|
||||
});
|
||||
test('passed argument is a null', () => {
|
||||
expect(isNull(null)).toBe(true)
|
||||
test('passed argument is a null', () => {
|
||||
expect(isNull(null)).toBeTruthy();
|
||||
});
|
||||
test('passed argument is a null', () => {
|
||||
expect(isNull(NaN)).toBe(false)
|
||||
test('passed argument is a null', () => {
|
||||
expect(isNull(NaN)).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isNumber = require('./isNumber.js');
|
||||
|
||||
|
||||
test('isNumber is a Function', () => {
|
||||
test('isNumber is a Function', () => {
|
||||
expect(isNumber).toBeInstanceOf(Function);
|
||||
});
|
||||
test('passed argument is a number', () => {
|
||||
expect(isNumber(1)).toBe(true)
|
||||
test('passed argument is a number', () => {
|
||||
expect(isNumber(1)).toBeTruthy();
|
||||
});
|
||||
test('passed argument is not a number', () => {
|
||||
expect(isNumber('1')).toBe(false)
|
||||
test('passed argument is not a number', () => {
|
||||
expect(isNumber('1')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,22 +1,19 @@
|
||||
const expect = require('expect');
|
||||
const isObject = require('./isObject.js');
|
||||
|
||||
|
||||
test('isObject is a Function', () => {
|
||||
test('isObject is a Function', () => {
|
||||
expect(isObject).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
test('isObject([1, 2, 3, 4]) is a object', () => {
|
||||
test('isObject([1, 2, 3, 4]) is a object', () => {
|
||||
expect(isObject([1, 2, 3, 4])).toBeTruthy();
|
||||
});
|
||||
test('isObject([]) is a object', () => {
|
||||
test('isObject([]) is a object', () => {
|
||||
expect(isObject([])).toBeTruthy();
|
||||
});
|
||||
test('isObject({ a:1 }) is a object', () => {
|
||||
test('isObject({ a:1 }) is a object', () => {
|
||||
expect(isObject({ a:1 })).toBeTruthy();
|
||||
});
|
||||
test('isObject(true) is not a object', () => {
|
||||
test('isObject(true) is not a object', () => {
|
||||
expect(isObject(true)).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,21 +1,18 @@
|
||||
const expect = require('expect');
|
||||
const isObjectLike = require('./isObjectLike.js');
|
||||
|
||||
|
||||
test('isObjectLike is a Function', () => {
|
||||
test('isObjectLike is a Function', () => {
|
||||
expect(isObjectLike).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns true for an object', () => {
|
||||
expect(isObjectLike({}), true).toBe()
|
||||
test('Returns true for an object', () => {
|
||||
expect(isObjectLike({})).toBeTruthy();
|
||||
});
|
||||
test('Returns true for an array', () => {
|
||||
expect(isObjectLike([1, 2, 3]), true).toBe()
|
||||
test('Returns true for an array', () => {
|
||||
expect(isObjectLike([1, 2, 3])).toBeTruthy();
|
||||
});
|
||||
test('Returns false for a function', () => {
|
||||
expect(isObjectLike(x => x), false).toBe()
|
||||
test('Returns false for a function', () => {
|
||||
expect(isObjectLike(x => x)).toBeFalsy();
|
||||
});
|
||||
test('Returns false for null', () => {
|
||||
expect(isObjectLike(null), false).toBe()
|
||||
test('Returns false for null', () => {
|
||||
expect(isObjectLike(null)).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isPlainObject = require('./isPlainObject.js');
|
||||
|
||||
|
||||
test('isPlainObject is a Function', () => {
|
||||
test('isPlainObject is a Function', () => {
|
||||
expect(isPlainObject).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns true for a plain object', () => {
|
||||
expect(isPlainObject({ a: 1 }), true).toBe()
|
||||
test('Returns true for a plain object', () => {
|
||||
expect(isPlainObject({ a: 1 })).toBeTruthy();
|
||||
});
|
||||
test('Returns false for a Map (example of non-plain object)', () => {
|
||||
expect(isPlainObject(new Map()), false).toBe()
|
||||
test('Returns false for a Map (example of non-plain object)', () => {
|
||||
expect(isPlainObject(new Map())).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const isPrime = require('./isPrime.js');
|
||||
|
||||
|
||||
test('isPrime is a Function', () => {
|
||||
test('isPrime is a Function', () => {
|
||||
expect(isPrime).toBeInstanceOf(Function);
|
||||
});
|
||||
test('passed number is a prime', () => {
|
||||
expect(isPrime(11)).toBe(true)
|
||||
test('passed number is a prime', () => {
|
||||
expect(isPrime(11)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,45 +1,42 @@
|
||||
const expect = require('expect');
|
||||
const isPrimitive = require('./isPrimitive.js');
|
||||
|
||||
|
||||
test('isPrimitive is a Function', () => {
|
||||
test('isPrimitive is a Function', () => {
|
||||
expect(isPrimitive).toBeInstanceOf(Function);
|
||||
});
|
||||
test('isPrimitive(null) is primitive', () => {
|
||||
expect(isPrimitive(null)).toBeTruthy()
|
||||
test('isPrimitive(null) is primitive', () => {
|
||||
expect(isPrimitive(null)).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive(undefined) is primitive', () => {
|
||||
expect(isPrimitive(undefined)).toBeTruthy()
|
||||
test('isPrimitive(undefined) is primitive', () => {
|
||||
expect(isPrimitive(undefined)).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive(string) is primitive', () => {
|
||||
expect(isPrimitive('string')).toBeTruthy()
|
||||
test('isPrimitive(string) is primitive', () => {
|
||||
expect(isPrimitive('string')).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive(true) is primitive', () => {
|
||||
expect(isPrimitive(true)).toBeTruthy()
|
||||
test('isPrimitive(true) is primitive', () => {
|
||||
expect(isPrimitive(true)).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive(50) is primitive', () => {
|
||||
expect(isPrimitive(50)).toBeTruthy()
|
||||
test('isPrimitive(50) is primitive', () => {
|
||||
expect(isPrimitive(50)).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive('Hello') is primitive', () => {
|
||||
expect(isPrimitive('Hello')).toBeTruthy()
|
||||
test('isPrimitive('Hello') is primitive', () => {
|
||||
expect(isPrimitive('Hello')).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive(false) is primitive', () => {
|
||||
expect(isPrimitive(false)).toBeTruthy()
|
||||
test('isPrimitive(false) is primitive', () => {
|
||||
expect(isPrimitive(false)).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive(Symbol()) is primitive', () => {
|
||||
expect(isPrimitive(Symbol())).toBeTruthy()
|
||||
test('isPrimitive(Symbol()) is primitive', () => {
|
||||
expect(isPrimitive(Symbol())).toBeTruthy();
|
||||
});
|
||||
test('isPrimitive([1, 2, 3]) is not primitive', () => {
|
||||
expect(isPrimitive([1, 2, 3])).toBeFalsy()
|
||||
test('isPrimitive([1, 2, 3]) is not primitive', () => {
|
||||
expect(isPrimitive([1, 2, 3])).toBeFalsy();
|
||||
});
|
||||
test('isPrimitive({ a: 123 }) is not primitive', () => {
|
||||
expect(isPrimitive({ a: 123 })).toBeFalsy()
|
||||
test('isPrimitive({ a: 123 }) is not primitive', () => {
|
||||
expect(isPrimitive({ a: 123 })).toBeFalsy();
|
||||
});
|
||||
|
||||
let start = new Date().getTime();
|
||||
isPrimitive({ a: 123
|
||||
let end = new Date().getTime();
|
||||
test('isPrimitive({ a: 123 }) takes less than 2s to run', () => {
|
||||
let start = new Date().getTime();
|
||||
isPrimitive({ a: 123
|
||||
let end = new Date().getTime();
|
||||
test('isPrimitive({ a: 123 }) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,20 +1,16 @@
|
||||
const expect = require('expect');
|
||||
const isPromiseLike = require('./isPromiseLike.js');
|
||||
|
||||
|
||||
test('isPromiseLike is a Function', () => {
|
||||
test('isPromiseLike is a Function', () => {
|
||||
expect(isPromiseLike).toBeInstanceOf(Function);
|
||||
});
|
||||
t.equal(isPromiseLike({
|
||||
test('Returns true for a promise-like object', () => {
|
||||
expect(isPromiseLike({
|
||||
then: function() {
|
||||
return '';
|
||||
}
|
||||
}), true, 'Returns true for a promise-like object');
|
||||
test('Returns false for null', () => {
|
||||
expect(isPromiseLike(null), false).toBe()
|
||||
})).toBeTruthy();
|
||||
});
|
||||
test('Returns false for an empty object', () => {
|
||||
expect(isPromiseLike({}), false).toBe()
|
||||
test('Returns false for an empty object', () => {
|
||||
expect(isPromiseLike({})).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isRegExp = require('./isRegExp.js');
|
||||
|
||||
|
||||
test('isRegExp is a Function', () => {
|
||||
test('isRegExp is a Function', () => {
|
||||
expect(isRegExp).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isSet = require('./isSet.js');
|
||||
|
||||
|
||||
test('isSet is a Function', () => {
|
||||
test('isSet is a Function', () => {
|
||||
expect(isSet).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isSimilar = require('./isSimilar.js');
|
||||
|
||||
|
||||
test('isSimilar is a Function', () => {
|
||||
test('isSimilar is a Function', () => {
|
||||
expect(isSimilar).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,42 +1,39 @@
|
||||
const expect = require('expect');
|
||||
const isSorted = require('./isSorted.js');
|
||||
|
||||
|
||||
test('isSorted is a Function', () => {
|
||||
test('isSorted is a Function', () => {
|
||||
expect(isSorted).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([0, 1, 2]), 1).toBe()
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([0, 1, 2])).toBe(1);
|
||||
});
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([0, 1, 2, 2]), 1).toBe()
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([0, 1, 2, 2])).toBe(1);
|
||||
});
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([-4, -3, -2]), 1).toBe()
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([-4, -3, -2])).toBe(1);
|
||||
});
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([0, 0, 1, 2]), 1).toBe()
|
||||
test('Array is sorted in ascending order', () => {
|
||||
expect(isSorted([0, 0, 1, 2])).toBe(1);
|
||||
});
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([2, 1, 0]), -1).toBe()
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([2, 1, 0])).toBe(-1);
|
||||
});
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([2, 2, 1, 0]), -1).toBe()
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([2, 2, 1, 0])).toBe(-1);
|
||||
});
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([-2, -3, -4]), -1).toBe()
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([-2, -3, -4])).toBe(-1);
|
||||
});
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([2, 1, 0, 0]), -1).toBe()
|
||||
test('Array is sorted in descending order', () => {
|
||||
expect(isSorted([2, 1, 0, 0])).toBe(-1);
|
||||
});
|
||||
test('Array is empty', () => {
|
||||
expect(isSorted([]), undefined).toBe()
|
||||
test('Array is empty', () => {
|
||||
expect(isSorted([])).toBe(undefined);
|
||||
});
|
||||
test('Array is not sorted, direction changed in array', () => {
|
||||
expect(isSorted([1]), 0).toBe()
|
||||
test('Array is not sorted, direction changed in array', () => {
|
||||
expect(isSorted([1])).toBe(0);
|
||||
});
|
||||
test('Array is not sorted, direction changed in array', () => {
|
||||
expect(isSorted([1, 2, 1]), 0).toBe()
|
||||
test('Array is not sorted, direction changed in array', () => {
|
||||
expect(isSorted([1, 2, 1])).toBe(0);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,23 +1,21 @@
|
||||
const expect = require('expect');
|
||||
const isString = require('./isString.js');
|
||||
|
||||
|
||||
test('isString is a Function', () => {
|
||||
test('isString is a Function', () => {
|
||||
expect(isString).toBeInstanceOf(Function);
|
||||
});
|
||||
test('foo is a string', () => {
|
||||
expect(isString('foo'), true).toBe()
|
||||
test('foo is a string', () => {
|
||||
expect(isString('foo')).toBeTruthy();
|
||||
});
|
||||
test('"10" is a string', () => {
|
||||
expect(isString('10'), true).toBe()
|
||||
test('"10" is a string', () => {
|
||||
expect(isString('10')).toBeTruthy();
|
||||
});
|
||||
test('Empty string is a string', () => {
|
||||
expect(isString(''), true).toBe()
|
||||
test('Empty string is a string', () => {
|
||||
expect(isString('')).toBeTruthy();
|
||||
});
|
||||
test('10 is not a string', () => {
|
||||
expect(isString(10), false).toBe()
|
||||
test('10 is not a string', () => {
|
||||
expect(isString(10)).toBeFalsy();
|
||||
});
|
||||
test('true is not string', () => {
|
||||
expect(isString(true), false).toBe()
|
||||
test('true is not string', () => {
|
||||
expect(isString(true)).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const isSymbol = require('./isSymbol.js');
|
||||
|
||||
|
||||
test('isSymbol is a Function', () => {
|
||||
test('isSymbol is a Function', () => {
|
||||
expect(isSymbol).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Checks if the given argument is a symbol', () => {
|
||||
expect(isSymbol(Symbol('x'))).toBe(true)
|
||||
test('Checks if the given argument is a symbol', () => {
|
||||
expect(isSymbol(Symbol('x'))).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
const expect = require('expect');
|
||||
const isTravisCI = require('./isTravisCI.js');
|
||||
|
||||
|
||||
test('isTravisCI is a Function', () => {
|
||||
test('isTravisCI is a Function', () => {
|
||||
expect(isTravisCI).toBeInstanceOf(Function);
|
||||
});
|
||||
if(isTravisCI())
|
||||
test('Running on Travis, correctly evaluates', () => {
|
||||
expect(isTravisCI()).toBeTruthy();
|
||||
});
|
||||
else
|
||||
test('Not running on Travis, correctly evaluates', () => {
|
||||
expect(isTravisCI()).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
if(isTravisCI())
|
||||
test('Running on Travis, correctly evaluates', () => {
|
||||
expect(isTravisCI()).toBeTruthy();
|
||||
});
|
||||
else
|
||||
test('Not running on Travis, correctly evaluates', () => {
|
||||
expect(isTravisCI()).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isTypedArray = require('./isTypedArray.js');
|
||||
|
||||
|
||||
test('isTypedArray is a Function', () => {
|
||||
test('isTypedArray is a Function', () => {
|
||||
expect(isTypedArray).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const isUndefined = require('./isUndefined.js');
|
||||
|
||||
|
||||
test('isUndefined is a Function', () => {
|
||||
test('isUndefined is a Function', () => {
|
||||
expect(isUndefined).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns true for undefined', () => {
|
||||
test('Returns true for undefined', () => {
|
||||
expect(isUndefined(undefined)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const isUpperCase = require('./isUpperCase.js');
|
||||
|
||||
|
||||
test('isUpperCase is a Function', () => {
|
||||
test('isUpperCase is a Function', () => {
|
||||
expect(isUpperCase).toBeInstanceOf(Function);
|
||||
});
|
||||
test('ABC is all upper case', () => {
|
||||
expect(isUpperCase('ABC'), true).toBe()
|
||||
test('ABC is all upper case', () => {
|
||||
expect(isUpperCase('ABC')).toBeTruthy();
|
||||
});
|
||||
test('abc is not all upper case', () => {
|
||||
expect(isUpperCase('abc'), false).toBe()
|
||||
expect(isUpperCase('abc')).toBeFalsy();
|
||||
});
|
||||
test('A3@$ is all uppercase', () => {
|
||||
expect(isUpperCase('A3@$'), true).toBe()
|
||||
expect(isUpperCase('A3@$')).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const isValidJSON = require('./isValidJSON.js');
|
||||
|
||||
|
||||
test('isValidJSON is a Function', () => {
|
||||
test('isValidJSON is a Function', () => {
|
||||
expect(isValidJSON).toBeInstanceOf(Function);
|
||||
});
|
||||
test('{"name":"Adam","age":20} is a valid JSON', () => {
|
||||
expect(isValidJSON('{"name":"Adam","age":20}'), true).toBe()
|
||||
test('{"name":"Adam","age":20} is a valid JSON', () => {
|
||||
expect(isValidJSON('{"name":"Adam","age":20}')).toBeTruthy();
|
||||
});
|
||||
test('{"name":"Adam",age:"20"} is not a valid JSON', () => {
|
||||
expect(isValidJSON('{"name":"Adam",age:"20"}'), false).toBe()
|
||||
test('{"name":"Adam",age:"20"} is not a valid JSON', () => {
|
||||
expect(isValidJSON('{"name":"Adam",age:"20"}')).toBeFalsy();
|
||||
});
|
||||
test('null is a valid JSON', () => {
|
||||
expect(isValidJSON(null), true).toBe()
|
||||
test('null is a valid JSON', () => {
|
||||
expect(isValidJSON(null)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isWeakMap = require('./isWeakMap.js');
|
||||
|
||||
|
||||
test('isWeakMap is a Function', () => {
|
||||
test('isWeakMap is a Function', () => {
|
||||
expect(isWeakMap).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const isWeakSet = require('./isWeakSet.js');
|
||||
|
||||
|
||||
test('isWeakSet is a Function', () => {
|
||||
test('isWeakSet is a Function', () => {
|
||||
expect(isWeakSet).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const join = require('./join.js');
|
||||
|
||||
|
||||
test('join is a Function', () => {
|
||||
test('join is a Function', () => {
|
||||
expect(join).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Joins all elements of an array into a string and returns this string', () => {
|
||||
expect(join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'), "pen,pineapple).toEqual(apple&pen")
|
||||
test('Joins all elements of an array into a string and returns this string', () => {
|
||||
expect(join(['pen', 'pineapple', 'apple', 'pen'], ',', '&')).toEqual('pen,pineapple,apple&pen');
|
||||
});
|
||||
test('Joins all elements of an array into a string and returns this string', () => {
|
||||
expect(join(['pen', 'pineapple', 'apple', 'pen'], ','), "pen,pineapple,apple).toEqual(pen")
|
||||
test('Joins all elements of an array into a string and returns this string', () => {
|
||||
expect(join(['pen', 'pineapple', 'apple', 'pen'], ',')).toEqual('pen,pineapple,apple,pen');
|
||||
});
|
||||
test('Joins all elements of an array into a string and returns this string', () => {
|
||||
expect(join(['pen', 'pineapple', 'apple', 'pen']), "pen,pineapple,apple).toEqual(pen")
|
||||
});
|
||||
|
||||
test('Joins all elements of an array into a string and returns this string', () => {
|
||||
expect(join(['pen', 'pineapple', 'apple', 'pen'])).toEqual('pen,pineapple,apple,pen');
|
||||
});
|
||||
|
||||
@ -1,30 +1,33 @@
|
||||
const expect = require('expect');
|
||||
const last = require('./last.js');
|
||||
|
||||
|
||||
test('last is a Function', () => {
|
||||
test('last is a Function', () => {
|
||||
expect(last).toBeInstanceOf(Function);
|
||||
});
|
||||
test('last({ a: 1234}) returns undefined', () => {
|
||||
test('last({ a: 1234}) returns undefined', () => {
|
||||
expect(last({ a: 1234}) === undefined).toBeTruthy();
|
||||
});
|
||||
test('last([1, 2, 3]) returns 3', () => {
|
||||
expect(last([1, 2, 3])).toBe(3)
|
||||
test('last([1, 2, 3]) returns 3', () => {
|
||||
expect(last([1, 2, 3])).toBe(3);
|
||||
});
|
||||
test('last({ 0: false}) returns undefined', () => {
|
||||
expect(last({ 0: false}), undefined).toBe()
|
||||
test('last({ 0: false}) returns undefined', () => {
|
||||
expect(last({ 0: false})).toBe(undefined);
|
||||
});
|
||||
test('last(String) returns g', () => {
|
||||
expect(last('String'), 'g').toBe()
|
||||
test('last(String) returns g', () => {
|
||||
expect(last('String')).toBe('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();
|
||||
test('last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run', () => {
|
||||
test('last(null) throws an Error', () => {
|
||||
expect(last(null)).toThrow();
|
||||
});
|
||||
test('last(undefined) throws an Error', () => {
|
||||
expect(last(undefined)).toThrow();
|
||||
});
|
||||
test('last() throws an Error', () => {
|
||||
expect(last()).toThrow();
|
||||
});
|
||||
let start = new Date().getTime();
|
||||
last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]);
|
||||
let end = new Date().getTime();
|
||||
test('last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const lcm = require('./lcm.js');
|
||||
|
||||
|
||||
test('lcm is a Function', () => {
|
||||
test('lcm is a Function', () => {
|
||||
expect(lcm).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the least common multiple of two or more numbers.', () => {
|
||||
expect(lcm(12, 7)).toBe(84)
|
||||
test('Returns the least common multiple of two or more numbers.', () => {
|
||||
expect(lcm(12, 7)).toBe(84);
|
||||
});
|
||||
test('Returns the least common multiple of two or more numbers.', () => {
|
||||
expect(lcm(...[1, 3, 4, 5])).toBe(60)
|
||||
test('Returns the least common multiple of two or more numbers.', () => {
|
||||
expect(lcm(...[1, 3, 4, 5])).toBe(60);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const levenshteinDistance = require('./levenshteinDistance.js');
|
||||
|
||||
|
||||
test('levenshteinDistance is a Function', () => {
|
||||
test('levenshteinDistance is a Function', () => {
|
||||
expect(levenshteinDistance).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const longestItem = require('./longestItem.js');
|
||||
|
||||
|
||||
test('longestItem is a Function', () => {
|
||||
test('longestItem is a Function', () => {
|
||||
expect(longestItem).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the longest object', () => {
|
||||
expect(longestItem('this', 'is', 'a', 'testcase')).toEqual('testcase')
|
||||
test('Returns the longest object', () => {
|
||||
expect(longestItem('this', 'is', 'a', 'testcase')).toEqual('testcase');
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
const expect = require('expect');
|
||||
const lowercaseKeys = require('./lowercaseKeys.js');
|
||||
|
||||
|
||||
test('lowercaseKeys is a Function', () => {
|
||||
test('lowercaseKeys is a Function', () => {
|
||||
expect(lowercaseKeys).toBeInstanceOf(Function);
|
||||
});
|
||||
const myObj = { Name: 'Adam', sUrnAME: 'Smith' };
|
||||
const myObjLower = lowercaseKeys(myObj);
|
||||
test('Lowercases object keys', () => {
|
||||
expect(myObjLower, {name: 'Adam', surname: 'Smith'}).toEqual()
|
||||
const myObj = { Name: 'Adam', sUrnAME: 'Smith' };
|
||||
const myObjLower = lowercaseKeys(myObj);
|
||||
test('Lowercases object keys', () => {
|
||||
expect(myObjLower).toEqual( {name: 'Adam', surname: 'Smith'});
|
||||
});
|
||||
test('Does not mutate original object', () => {
|
||||
expect(myObj, { Name: 'Adam', sUrnAME: 'Smith' }).toEqual()
|
||||
test('Does not mutate original object', () => {
|
||||
expect(myObj).toEqual({ Name: 'Adam', sUrnAME: 'Smith' });
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const luhnCheck = require('./luhnCheck.js');
|
||||
|
||||
|
||||
test('luhnCheck is a Function', () => {
|
||||
test('luhnCheck is a Function', () => {
|
||||
expect(luhnCheck).toBeInstanceOf(Function);
|
||||
});
|
||||
test('validates identification number', () => {
|
||||
expect(luhnCheck(6011329933655299)).toBe(false)
|
||||
test('validates identification number', () => {
|
||||
expect(luhnCheck(6011329933655299)).toBeFalsy();
|
||||
});
|
||||
test('validates identification number', () => {
|
||||
expect(luhnCheck('4485275742308327')).toBe(true)
|
||||
test('validates identification number', () => {
|
||||
expect(luhnCheck('4485275742308327')).toBeTruthy();
|
||||
});
|
||||
test('validates identification number', () => {
|
||||
expect(luhnCheck(123456789)).toBe(false)
|
||||
test('validates identification number', () => {
|
||||
expect(luhnCheck(123456789)).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user