Test cleanup and fixes [s-t]
This commit is contained in:
@ -1,19 +1,16 @@
|
||||
const expect = require('expect');
|
||||
const sample = require('./sample.js');
|
||||
|
||||
|
||||
test('sample is a Function', () => {
|
||||
test('sample is a Function', () => {
|
||||
expect(sample).toBeInstanceOf(Function);
|
||||
});
|
||||
const arr = [3,7,9,11];
|
||||
test('Returns a random element from the array', () => {
|
||||
const arr = [3,7,9,11];
|
||||
test('Returns a random element from the array', () => {
|
||||
expect(arr.includes(sample(arr))).toBeTruthy();
|
||||
});
|
||||
test('Works for single-element arrays', () => {
|
||||
expect(sample([1]), 1).toBe()
|
||||
test('Works for single-element arrays', () => {
|
||||
expect(sample([1])).toBe(1);
|
||||
});
|
||||
test('Returns undefined for empty array', () => {
|
||||
expect(sample([]), undefined).toBe()
|
||||
test('Returns undefined for empty array', () => {
|
||||
expect(sample([])).toBe(undefined);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,25 +1,22 @@
|
||||
const expect = require('expect');
|
||||
const sampleSize = require('./sampleSize.js');
|
||||
|
||||
|
||||
test('sampleSize is a Function', () => {
|
||||
test('sampleSize is a Function', () => {
|
||||
expect(sampleSize).toBeInstanceOf(Function);
|
||||
});
|
||||
const arr = [3,7,9,11];
|
||||
test('Returns a single element without n specified', () => {
|
||||
expect(sampleSize(arr).length, 1).toBe()
|
||||
const arr = [3,7,9,11];
|
||||
test('Returns a single element without n specified', () => {
|
||||
expect(sampleSize(arr).length).toBe(1);
|
||||
});
|
||||
test('Returns a random sample of specified size from an array', () => {
|
||||
test('Returns a random sample of specified size from an array', () => {
|
||||
expect(sampleSize(arr, 2).every(x => arr.includes(x))).toBeTruthy();
|
||||
});
|
||||
test('Returns all elements in an array if n >= length', () => {
|
||||
expect(sampleSize(arr, 5).length, 4).toBe()
|
||||
test('Returns all elements in an array if n >= length', () => {
|
||||
expect(sampleSize(arr, 5).length).toBe(4)
|
||||
});
|
||||
test('Returns an empty array if original array is empty', () => {
|
||||
expect(sampleSize([], 2), []).toEqual()
|
||||
test('Returns an empty array if original array is empty', () => {
|
||||
expect(sampleSize([], 2)).toEqual([]);
|
||||
});
|
||||
test('Returns an empty array if n = 0', () => {
|
||||
expect(sampleSize(arr, 0), []).toEqual()
|
||||
test('Returns an empty array if n = 0', () => {
|
||||
expect(sampleSize(arr, 0)).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const scrollToTop = require('./scrollToTop.js');
|
||||
|
||||
|
||||
test('scrollToTop is a Function', () => {
|
||||
test('scrollToTop is a Function', () => {
|
||||
expect(scrollToTop).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const sdbm = require('./sdbm.js');
|
||||
|
||||
|
||||
test('sdbm is a Function', () => {
|
||||
test('sdbm is a Function', () => {
|
||||
expect(sdbm).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Hashes the input string into a whole number.', () => {
|
||||
expect(sdbm('name')).toBe(-3521204949)
|
||||
test('Hashes the input string into a whole number.', () => {
|
||||
expect(sdbm('name')).toBe(-3521204949);
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const serializeCookie = require('./serializeCookie.js');
|
||||
|
||||
|
||||
test('serializeCookie is a Function', () => {
|
||||
test('serializeCookie is a Function', () => {
|
||||
expect(serializeCookie).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Serializes the cookie', () => {
|
||||
expect(serializeCookie('foo', 'bar'), 'foo=bar').toBe()
|
||||
test('Serializes the cookie', () => {
|
||||
expect(serializeCookie('foo', 'bar')).toBe('foo=bar');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const setStyle = require('./setStyle.js');
|
||||
|
||||
|
||||
test('setStyle is a Function', () => {
|
||||
test('setStyle is a Function', () => {
|
||||
expect(setStyle).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const shallowClone = require('./shallowClone.js');
|
||||
|
||||
|
||||
test('shallowClone is a Function', () => {
|
||||
test('shallowClone is a Function', () => {
|
||||
expect(shallowClone).toBeInstanceOf(Function);
|
||||
});
|
||||
const a = { foo: 'bar', obj: { a: 1, b: 2 } };
|
||||
const b = shallowClone(a);
|
||||
t.notEqual(a, b, 'Shallow cloning works');
|
||||
test('Does not clone deeply', () => {
|
||||
expect(a.obj, b.obj).toBe()
|
||||
const a = { foo: 'bar', obj: { a: 1, b: 2 } };
|
||||
const b = shallowClone(a);
|
||||
t.notEqual(a, b, 'Shallow cloning works');
|
||||
test('Does not clone deeply', () => {
|
||||
expect(a.obj).toBe(b.obj);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const show = require('./show.js');
|
||||
|
||||
|
||||
test('show is a Function', () => {
|
||||
test('show is a Function', () => {
|
||||
expect(show).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
const expect = require('expect');
|
||||
const shuffle = require('./shuffle.js');
|
||||
|
||||
|
||||
test('shuffle is a Function', () => {
|
||||
test('shuffle is a Function', () => {
|
||||
expect(shuffle).toBeInstanceOf(Function);
|
||||
});
|
||||
const arr = [1,2,3,4,5,6];
|
||||
t.notEqual(shuffle(arr), arr, 'Shuffles the array');
|
||||
test('New array contains all original elements', () => {
|
||||
const arr = [1,2,3,4,5,6];
|
||||
test('Shuffles the array', () => {
|
||||
expect(shuffle(arr)).not.toEqual(arr);
|
||||
});
|
||||
test('New array contains all original elements', () => {
|
||||
expect(shuffle(arr).every(x => arr.includes(x))).toBeTruthy();
|
||||
});
|
||||
test('Works for empty arrays', () => {
|
||||
expect(shuffle([]),[]).toEqual()
|
||||
test('Works for empty arrays', () => {
|
||||
expect(shuffle([])).toEqual([]);
|
||||
});
|
||||
test('Works for single-element arrays', () => {
|
||||
expect(shuffle([1]),[1]).toEqual()
|
||||
test('Works for single-element arrays', () => {
|
||||
expect(shuffle([1])).toEqual([1]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const similarity = require('./similarity.js');
|
||||
|
||||
|
||||
test('similarity is a Function', () => {
|
||||
test('similarity is a Function', () => {
|
||||
expect(similarity).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns an array of elements that appear in both arrays.', () => {
|
||||
expect(similarity([1, 2, 3], [1, 2, 4]), [1).toEqual(2])
|
||||
test('Returns an array of elements that appear in both arrays.', () => {
|
||||
expect(similarity([1, 2, 3], [1, 2, 4])).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const size = require('./size.js');
|
||||
|
||||
|
||||
test('size is a Function', () => {
|
||||
test('size is a Function', () => {
|
||||
expect(size).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Get size of arrays, objects or strings.', () => {
|
||||
expect(size([1, 2, 3, 4, 5])).toBe(5)
|
||||
test('Get size of arrays, objects or strings.', () => {
|
||||
expect(size([1, 2, 3, 4, 5])).toBe(5);
|
||||
});
|
||||
test('Get size of arrays, objects or strings.', () => {
|
||||
expect(size({ one: 1, two: 2, three: 3 })).toBe(3)
|
||||
test('Get size of arrays, objects or strings.', () => {
|
||||
expect(size({ one: 1, two: 2, three: 3 })).toBe(3);
|
||||
});
|
||||
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const sleep = require('./sleep.js');
|
||||
|
||||
|
||||
test('sleep is a Function', () => {
|
||||
test('sleep is a Function', () => {
|
||||
expect(sleep).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Works as expected', () => {
|
||||
async function sleepyWork() {
|
||||
await sleep(1000);
|
||||
|
||||
expect(true).toBeTruthy();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const smoothScroll = require('./smoothScroll.js');
|
||||
|
||||
|
||||
test('smoothScroll is a Function', () => {
|
||||
test('smoothScroll is a Function', () => {
|
||||
expect(smoothScroll).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const solveRPN = require('./solveRPN.js');
|
||||
|
||||
|
||||
test('solveRPN is a Function', () => {
|
||||
test('solveRPN is a Function', () => {
|
||||
expect(solveRPN).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const sortCharactersInString = require('./sortCharactersInString.js');
|
||||
|
||||
|
||||
test('sortCharactersInString is a Function', () => {
|
||||
test('sortCharactersInString is a Function', () => {
|
||||
expect(sortCharactersInString).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Alphabetically sorts the characters in a string.', () => {
|
||||
expect(sortCharactersInString('cabbage')).toBe('aabbceg')
|
||||
test('Alphabetically sorts the characters in a string.', () => {
|
||||
expect(sortCharactersInString('cabbage')).toBe('aabbceg');
|
||||
});
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const sortedIndex = require('./sortedIndex.js');
|
||||
|
||||
|
||||
test('sortedIndex is a Function', () => {
|
||||
test('sortedIndex is a Function', () => {
|
||||
expect(sortedIndex).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the lowest index at which value should be inserted into array in order to maintain its sort order.', () => {
|
||||
expect(sortedIndex([5, 3, 2, 1], 4)).toBe(1)
|
||||
test('Returns the lowest index at which value should be inserted into array in order to maintain its sort order.', () => {
|
||||
expect(sortedIndex([5, 3, 2, 1], 4)).toBe(1);
|
||||
});
|
||||
test('Returns the lowest index at which value should be inserted into array in order to maintain its sort order.', () => {
|
||||
expect(sortedIndex([30, 50], 40)).toBe(1)
|
||||
test('Returns the lowest index at which value should be inserted into array in order to maintain its sort order.', () => {
|
||||
expect(sortedIndex([30, 50], 40)).toBe(1);
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const sortedIndexBy = require('./sortedIndexBy.js');
|
||||
|
||||
|
||||
test('sortedIndexBy is a Function', () => {
|
||||
test('sortedIndexBy is a Function', () => {
|
||||
expect(sortedIndexBy).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the lowest index to insert the element without messing up the list order', () => {
|
||||
expect(sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x), 0).toBe()
|
||||
test('Returns the lowest index to insert the element without messing up the list order', () => {
|
||||
expect(sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x)).toBe(0);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const sortedLastIndex = require('./sortedLastIndex.js');
|
||||
|
||||
|
||||
test('sortedLastIndex is a Function', () => {
|
||||
test('sortedLastIndex is a Function', () => {
|
||||
expect(sortedLastIndex).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the highest index to insert the element without messing up the list order', () => {
|
||||
expect(sortedLastIndex([10, 20, 30, 30, 40], 30), 4).toBe()
|
||||
test('Returns the highest index to insert the element without messing up the list order', () => {
|
||||
expect(sortedLastIndex([10, 20, 30, 30, 40], 30)).toBe(4);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const sortedLastIndexBy = require('./sortedLastIndexBy.js');
|
||||
|
||||
|
||||
test('sortedLastIndexBy is a Function', () => {
|
||||
test('sortedLastIndexBy is a Function', () => {
|
||||
expect(sortedLastIndexBy).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the highest index to insert the element without messing up the list order', () => {
|
||||
expect(sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x), 1).toBe()
|
||||
test('Returns the highest index to insert the element without messing up the list order', () => {
|
||||
expect(sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x)).toBe(1);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const speechSynthesis = require('./speechSynthesis.js');
|
||||
|
||||
|
||||
test('speechSynthesis is a Function', () => {
|
||||
test('speechSynthesis is a Function', () => {
|
||||
expect(speechSynthesis).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const splitLines = require('./splitLines.js');
|
||||
|
||||
|
||||
test('splitLines is a Function', () => {
|
||||
test('splitLines is a Function', () => {
|
||||
expect(splitLines).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Splits a multiline string into an array of lines.', () => {
|
||||
expect(splitLines('This\nis a\nmultiline\nstring.\n'), ['This', 'is a', 'multiline', 'string.' ).toEqual(''])
|
||||
test('Splits a multiline string into an array of lines.', () => {
|
||||
expect(splitLines('This\nis a\nmultiline\nstring.\n')).toEqual(['This', 'is a', 'multiline', 'string.', '']);
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const spreadOver = require('./spreadOver.js');
|
||||
|
||||
|
||||
test('spreadOver is a Function', () => {
|
||||
test('spreadOver is a Function', () => {
|
||||
expect(spreadOver).toBeInstanceOf(Function);
|
||||
});
|
||||
const arrayMax = spreadOver(Math.max);
|
||||
test('Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.', () => {
|
||||
expect(arrayMax([1, 2, 3])).toBe(3)
|
||||
const arrayMax = spreadOver(Math.max);
|
||||
test('Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.', () => {
|
||||
expect(arrayMax([1, 2, 3])).toBe(3);
|
||||
});
|
||||
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
const expect = require('expect');
|
||||
const stableSort = require('./stableSort.js');
|
||||
|
||||
|
||||
test('stableSort is a Function', () => {
|
||||
test('stableSort is a Function', () => {
|
||||
expect(stableSort).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
const compare = () => 0;
|
||||
test('Array is properly sorted', () => {
|
||||
expect(stableSort(arr, compare), arr).toEqual()
|
||||
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
const compare = () => 0;
|
||||
test('Array is properly sorted', () => {
|
||||
expect(stableSort(arr, compare)).toEqual(arr);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const standardDeviation = require('./standardDeviation.js');
|
||||
|
||||
|
||||
test('standardDeviation is a Function', () => {
|
||||
test('standardDeviation is a Function', () => {
|
||||
expect(standardDeviation).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the standard deviation of an array of numbers', () => {
|
||||
expect(standardDeviation([10, 2, 38, 23, 38, 23, 21])).toBe(13.284434142114991)
|
||||
test('Returns the standard deviation of an array of numbers', () => {
|
||||
expect(standardDeviation([10, 2, 38, 23, 38, 23, 21])).toBeCloseTo(13.284434142114991,5);
|
||||
});
|
||||
test('Returns the standard deviation of an array of numbers', () => {
|
||||
expect(standardDeviation([10, 2, 38, 23, 38, 23, 21], true)).toBe(12.29899614287479)
|
||||
test('Returns the standard deviation of an array of numbers', () => {
|
||||
expect(standardDeviation([10, 2, 38, 23, 38, 23, 21], true)).toBeCloseTo(12.29899614287479,5);
|
||||
});
|
||||
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const stringPermutations = require('./stringPermutations.js');
|
||||
|
||||
|
||||
test('stringPermutations is a Function', () => {
|
||||
test('stringPermutations is a Function', () => {
|
||||
expect(stringPermutations).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Generates all stringPermutations of a string', () => {
|
||||
expect(stringPermutations('abc'), ['abc','acb','bac','bca','cab').toEqual('cba'])
|
||||
test('Generates all stringPermutations of a string', () => {
|
||||
expect(stringPermutations('abc'), ['abc','acb','bac','bca','cab').toEqual('cba']);
|
||||
});
|
||||
test('Works for single-letter strings', () => {
|
||||
expect(stringPermutations('a')).toEqual(['a'])
|
||||
test('Works for single-letter strings', () => {
|
||||
expect(stringPermutations('a')).toEqual(['a']);
|
||||
});
|
||||
test('Works for empty strings', () => {
|
||||
expect(stringPermutations('')).toEqual([''])
|
||||
test('Works for empty strings', () => {
|
||||
expect(stringPermutations('')).toEqual(['']);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const stripHTMLTags = require('./stripHTMLTags.js');
|
||||
|
||||
|
||||
test('stripHTMLTags is a Function', () => {
|
||||
test('stripHTMLTags is a Function', () => {
|
||||
expect(stripHTMLTags).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Removes HTML tags', () => {
|
||||
expect(stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p><img /><br>'), 'lorem ipsum').toBe()
|
||||
test('Removes HTML tags', () => {
|
||||
expect(stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p><img /><br>')).toBe('lorem ipsum');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const sum = require('./sum.js');
|
||||
|
||||
|
||||
test('sum is a Function', () => {
|
||||
test('sum is a Function', () => {
|
||||
expect(sum).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the sum of two or more numbers/arrays.', () => {
|
||||
expect(sum(...[1, 2, 3, 4])).toBe(10)
|
||||
test('Returns the sum of two or more numbers/arrays.', () => {
|
||||
expect(sum(...[1, 2, 3, 4])).toBe(10);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const sumBy = require('./sumBy.js');
|
||||
|
||||
|
||||
test('sumBy is a Function', () => {
|
||||
test('sumBy is a Function', () => {
|
||||
expect(sumBy).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const sumPower = require('./sumPower.js');
|
||||
|
||||
|
||||
test('sumPower is a Function', () => {
|
||||
test('sumPower is a Function', () => {
|
||||
expect(sumPower).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the sum of the powers of all the numbers from start to end', () => {
|
||||
expect(sumPower(10)).toBe(385)
|
||||
test('Returns the sum of the powers of all the numbers from start to end', () => {
|
||||
expect(sumPower(10)).toBe(385);
|
||||
});
|
||||
test('Returns the sum of the powers of all the numbers from start to end', () => {
|
||||
expect(sumPower(10, 3)).toBe(3025)
|
||||
test('Returns the sum of the powers of all the numbers from start to end', () => {
|
||||
expect(sumPower(10, 3)).toBe(3025);
|
||||
});
|
||||
test('Returns the sum of the powers of all the numbers from start to end', () => {
|
||||
expect(sumPower(10, 3, 5)).toBe(2925)
|
||||
test('Returns the sum of the powers of all the numbers from start to end', () => {
|
||||
expect(sumPower(10, 3, 5)).toBe(2925);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const symmetricDifference = require('./symmetricDifference.js');
|
||||
|
||||
|
||||
test('symmetricDifference is a Function', () => {
|
||||
test('symmetricDifference is a Function', () => {
|
||||
expect(symmetricDifference).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the symmetric difference between two arrays.', () => {
|
||||
expect(symmetricDifference([1, 2, 3], [1, 2, 4]), [3).toEqual(4])
|
||||
test('Returns the symmetric difference between two arrays.', () => {
|
||||
expect(symmetricDifference([1, 2, 3], [1, 2, 4])).toEqual([3, 4]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const symmetricDifferenceBy = require('./symmetricDifferenceBy.js');
|
||||
|
||||
|
||||
test('symmetricDifferenceBy is a Function', () => {
|
||||
test('symmetricDifferenceBy is a Function', () => {
|
||||
expect(symmetricDifferenceBy).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the symmetric difference between two arrays, after applying the provided function to each array element of both', () => {
|
||||
expect(symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor), [ 1.2, 3.4 ]).toEqual()
|
||||
test('Returns the symmetric difference between two arrays, after applying the provided function to each array element of both', () => {
|
||||
expect(symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor)).toEqual([ 1.2, 3.4 ]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const symmetricDifferenceWith = require('./symmetricDifferenceWith.js');
|
||||
|
||||
|
||||
test('symmetricDifferenceWith is a Function', () => {
|
||||
test('symmetricDifferenceWith is a Function', () => {
|
||||
expect(symmetricDifferenceWith).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(symmetricDifferenceWith(
|
||||
test('Returns the symmetric difference between two arrays, using a provided function as a comparator', () => {
|
||||
expect(symmetricDifferenceWith(
|
||||
[1, 1.2, 1.5, 3, 0],
|
||||
[1.9, 3, 0, 3.9],
|
||||
(a, b) => Math.round(a) === Math.round(b)
|
||||
), [1, 1.2, 3.9], 'Returns the symmetric difference between two arrays, using a provided function as a comparator');
|
||||
|
||||
|
||||
(a, b) => Math.round(a) === Math.round(b))).toEqual([1, 1.2, 3.9]);
|
||||
});
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const tail = require('./tail.js');
|
||||
|
||||
|
||||
test('tail is a Function', () => {
|
||||
test('tail is a Function', () => {
|
||||
expect(tail).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns tail', () => {
|
||||
expect(tail([1, 2, 3]), [2).toEqual(3])
|
||||
test('Returns tail', () => {
|
||||
expect(tail([1, 2, 3]), [2).toEqual(3]);
|
||||
});
|
||||
test('Returns tail', () => {
|
||||
expect(tail([1])).toEqual([1])
|
||||
test('Returns tail', () => {
|
||||
expect(tail([1])).toEqual([1]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const take = require('./take.js');
|
||||
|
||||
|
||||
test('take is a Function', () => {
|
||||
test('take is a Function', () => {
|
||||
expect(take).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns an array with n elements removed from the beginning.', () => {
|
||||
test('Returns an array with n elements removed from the beginning.', () => {
|
||||
expect(take([1, 2, 3], 5), [1, 2).toEqual(3])
|
||||
});
|
||||
test('Returns an array with n elements removed from the beginning.', () => {
|
||||
test('Returns an array with n elements removed from the beginning.', () => {
|
||||
expect(take([1, 2, 3], 0)).toEqual([])
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const takeRight = require('./takeRight.js');
|
||||
|
||||
|
||||
test('takeRight is a Function', () => {
|
||||
test('takeRight is a Function', () => {
|
||||
expect(takeRight).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns an array with n elements removed from the end', () => {
|
||||
expect(takeRight([1, 2, 3], 2), [2).toEqual(3])
|
||||
test('Returns an array with n elements removed from the end', () => {
|
||||
expect(takeRight([1, 2, 3], 2)).toEqual([2, 3]);
|
||||
});
|
||||
test('Returns an array with n elements removed from the end', () => {
|
||||
test('Returns an array with n elements removed from the end', () => {
|
||||
expect(takeRight([1, 2, 3])).toEqual([3])
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const takeRightWhile = require('./takeRightWhile.js');
|
||||
|
||||
|
||||
test('takeRightWhile is a Function', () => {
|
||||
test('takeRightWhile is a Function', () => {
|
||||
expect(takeRightWhile).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Removes elements until the function returns true', () => {
|
||||
expect(takeRightWhile([1, 2, 3, 4], n => n < 3), [3, 4]).toEqual()
|
||||
test('Removes elements until the function returns true', () => {
|
||||
expect(takeRightWhile([1, 2, 3, 4], n => n < 3)).toEqual([3, 4]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const takeWhile = require('./takeWhile.js');
|
||||
|
||||
|
||||
test('takeWhile is a Function', () => {
|
||||
test('takeWhile is a Function', () => {
|
||||
expect(takeWhile).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Removes elements until the function returns true', () => {
|
||||
expect(takeWhile([1, 2, 3, 4], n => n >= 3), [1, 2]).toEqual()
|
||||
test('Removes elements until the function returns true', () => {
|
||||
expect(takeWhile([1, 2, 3, 4], n => n >= 3)).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const throttle = require('./throttle.js');
|
||||
|
||||
|
||||
test('throttle is a Function', () => {
|
||||
test('throttle is a Function', () => {
|
||||
expect(throttle).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const timeTaken = require('./timeTaken.js');
|
||||
|
||||
|
||||
test('timeTaken is a Function', () => {
|
||||
test('timeTaken is a Function', () => {
|
||||
expect(timeTaken).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
const expect = require('expect');
|
||||
const times = require('./times.js');
|
||||
|
||||
|
||||
test('times is a Function', () => {
|
||||
test('times is a Function', () => {
|
||||
expect(times).toBeInstanceOf(Function);
|
||||
});
|
||||
var output = '';
|
||||
times(5, i => (output += i));
|
||||
test('Runs a function the specified amount of times', () => {
|
||||
expect(output, '01234').toBe()
|
||||
var output = '';
|
||||
times(5, i => (output += i));
|
||||
test('Runs a function the specified amount of times', () => {
|
||||
expect(output).toBe('01234');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,32 +1,36 @@
|
||||
const expect = require('expect');
|
||||
const toCamelCase = require('./toCamelCase.js');
|
||||
|
||||
|
||||
test('toCamelCase is a Function', () => {
|
||||
test('toCamelCase is a Function', () => {
|
||||
expect(toCamelCase).toBeInstanceOf(Function);
|
||||
});
|
||||
test('toCamelCase('some_database_field_name') returns someDatabaseFieldName', () => {
|
||||
expect(toCamelCase('some_database_field_name')).toBe('someDatabaseFieldName')
|
||||
test('toCamelCase('some_database_field_name') returns someDatabaseFieldName', () => {
|
||||
expect(toCamelCase('some_database_field_name')).toBe('someDatabaseFieldName');
|
||||
});
|
||||
test('toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized', () => {
|
||||
expect(toCamelCase('Some label that needs to be camelized')).toBe('someLabelThatNeedsToBeCamelized')
|
||||
test('toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized', () => {
|
||||
expect(toCamelCase('Some label that needs to be camelized')).toBe('someLabelThatNeedsToBeCamelized');
|
||||
});
|
||||
test('toCamelCase('some-javascript-property') return someJavascriptProperty', () => {
|
||||
expect(toCamelCase('some-javascript-property')).toBe('someJavascriptProperty')
|
||||
test('toCamelCase('some-javascript-property') return someJavascriptProperty', () => {
|
||||
expect(toCamelCase('some-javascript-property')).toBe('someJavascriptProperty');
|
||||
});
|
||||
test('toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens', () => {
|
||||
expect(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens')).toBe('someMixedStringWithSpacesUnderscoresAndHyphens')
|
||||
test('toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens', () => {
|
||||
expect(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens')).toBe('someMixedStringWithSpacesUnderscoresAndHyphens');
|
||||
});
|
||||
t.throws(() => toCamelCase(), 'toCamelCase() throws a error');
|
||||
t.throws(() => toCamelCase([]), 'toCamelCase([]) throws a error');
|
||||
t.throws(() => toCamelCase({}), 'toCamelCase({}) throws a error');
|
||||
t.throws(() => toCamelCase(123), 'toCamelCase(123) throws a error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
toCamelCase('some-mixed_string with spaces_underscores-and-hyphens');
|
||||
let end = new Date().getTime();
|
||||
test('toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run', () => {
|
||||
test('toCamelCase() throws a error', () => {
|
||||
expect(toCamelCase()).toThrow();
|
||||
});
|
||||
test('toCamelCase([]) throws a error', () => {
|
||||
expect(toCamelCase([])).toThrow();
|
||||
});
|
||||
test('toCamelCase({}) throws a error', () => {
|
||||
expect(toCamelCase({})).toThrow();
|
||||
});
|
||||
test('toCamelCase(123) throws a error', () => {
|
||||
expect(toCamelCase(123)).toThrow();
|
||||
});
|
||||
let start = new Date().getTime();
|
||||
toCamelCase('some-mixed_string with spaces_underscores-and-hyphens');
|
||||
let end = new Date().getTime();
|
||||
test('toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const toCurrency = require('./toCurrency.js');
|
||||
|
||||
|
||||
test('toCurrency is a Function', () => {
|
||||
test('toCurrency is a Function', () => {
|
||||
expect(toCurrency).toBeInstanceOf(Function);
|
||||
});
|
||||
test('currency: Euro | currencyLangFormat: Local', () => {
|
||||
expect(toCurrency(123456.789, 'EUR'), '€ 123,456.79').toBe()
|
||||
test('currency: Euro | currencyLangFormat: Local', () => {
|
||||
expect(toCurrency(123456.789, 'EUR'), '€ 123,456.79').stringMatching(/€\s*123,456.79/g);
|
||||
});
|
||||
test(' currency: US Dollar | currencyLangFormat: English (United States)', () => {
|
||||
expect(toCurrency(123456.789, 'USD', 'en-us'), '$123,456.79').toBe()
|
||||
test(' currency: US Dollar | currencyLangFormat: English (United States)', () => {
|
||||
expect(toCurrency(123456.789, 'USD', 'en-us')).stringMatching(/\$\s*123,456.79/g);
|
||||
});
|
||||
test('currency: Japanese Yen | currencyLangFormat: Local', () => {
|
||||
expect(toCurrency(322342436423.2435, 'JPY'), 'JP¥ 322,342,436,423').toBe()
|
||||
test('currency: Japanese Yen | currencyLangFormat: Local', () => {
|
||||
expect(toCurrency(322342436423.2435, 'JPY'), 'JP¥ 322,342,436,423').stringMatching(/J*P*¥\s*322,342,436,423/g);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const toDecimalMark = require('./toDecimalMark.js');
|
||||
|
||||
|
||||
test('toDecimalMark is a Function', () => {
|
||||
test('toDecimalMark is a Function', () => {
|
||||
expect(toDecimalMark).toBeInstanceOf(Function);
|
||||
});
|
||||
test('convert a float-point arithmetic to the Decimal mark form', () => {
|
||||
expect(toDecimalMark(12305030388.9087), "12,305,030).toBe(388.909")
|
||||
test('convert a float-point arithmetic to the Decimal mark form', () => {
|
||||
expect(toDecimalMark(12305030388.9087)).toBe("12,305,030,388.909");
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const toHash = require('./toHash.js');
|
||||
|
||||
|
||||
test('toHash is a Function', () => {
|
||||
test('toHash is a Function', () => {
|
||||
expect(toHash).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,34 +1,36 @@
|
||||
const expect = require('expect');
|
||||
const toKebabCase = require('./toKebabCase.js');
|
||||
|
||||
|
||||
test('toKebabCase is a Function', () => {
|
||||
test('toKebabCase is a Function', () => {
|
||||
expect(toKebabCase).toBeInstanceOf(Function);
|
||||
});
|
||||
test('toKebabCase('camelCase') returns camel-case', () => {
|
||||
expect(toKebabCase('camelCase')).toBe('camel-case')
|
||||
test('toKebabCase(\'camelCase\') returns camel-case', () => {
|
||||
expect(toKebabCase('camelCase')).toBe('camel-case');
|
||||
});
|
||||
test('toKebabCase('some text') returns some-text', () => {
|
||||
expect(toKebabCase('some text')).toBe('some-text')
|
||||
test('toKebabCase(\'some text\') returns some-text', () => {
|
||||
expect(toKebabCase('some text')).toBe('some-text');
|
||||
});
|
||||
test('toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens', () => {
|
||||
expect(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens')).toBe('some-mixed-string-with-spaces-underscores-and-hyphens')
|
||||
test('toKebabCase(\'some-mixed-string With spaces-underscores-and-hyphens\') returns some-mixed-string-with-spaces-underscores-and-hyphens', () => {
|
||||
expect(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens')).toBe('some-mixed-string-with-spaces-underscores-and-hyphens');
|
||||
});
|
||||
test('toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', () => {
|
||||
test('toKebabCase(\'IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML\') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', () => {
|
||||
expect(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML')).toBe('i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html')
|
||||
});
|
||||
test('toKebabCase() return undefined', () => {
|
||||
expect(toKebabCase(), undefined).toBe()
|
||||
test('toKebabCase() returns undefined', () => {
|
||||
expect(toKebabCase()).toBe(undefined)
|
||||
});
|
||||
t.throws(() => toKebabCase([]), 'toKebabCase([]) throws an error');
|
||||
t.throws(() => toKebabCase({}), 'toKebabCase({}) throws an error');
|
||||
t.throws(() => toKebabCase(123), 'toKebabCase(123) throws an error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML');
|
||||
let end = new Date().getTime();
|
||||
test('toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run', () => {
|
||||
test('toKebabCase([]) throws an erro', () => {
|
||||
expect(toKebabCase([])).toThrow();
|
||||
});
|
||||
test('toKebabCase({}) throws an erro', () => {
|
||||
expect(toKebabCase({})).toThrow();
|
||||
});
|
||||
test('toKebabCase(123) throws an erro', () => {
|
||||
expect(toKebabCase(123)).toThrow();
|
||||
});
|
||||
let start = new Date().getTime();
|
||||
toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML');
|
||||
let end = new Date().getTime();
|
||||
test('toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
const expect = require('expect');
|
||||
const toOrdinalSuffix = require('./toOrdinalSuffix.js');
|
||||
|
||||
|
||||
test('toOrdinalSuffix is a Function', () => {
|
||||
test('toOrdinalSuffix is a Function', () => {
|
||||
expect(toOrdinalSuffix).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix('123'), '123rd').toBe()
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix('123')).toBe('123rd');
|
||||
});
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix(5), '5th').toBe()
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix(5)).toBe('5th');
|
||||
});
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix(1), '1st').toBe()
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix(1)).toBe('1st');
|
||||
});
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix(0), '0th').toBe()
|
||||
test('Adds an ordinal suffix to a number', () => {
|
||||
expect(toOrdinalSuffix(0)).toBe('0th');
|
||||
});
|
||||
|
||||
|
||||
@ -1,46 +1,42 @@
|
||||
const expect = require('expect');
|
||||
const toSafeInteger = require('./toSafeInteger.js');
|
||||
|
||||
|
||||
test('toSafeInteger is a Function', () => {
|
||||
test('toSafeInteger is a Function', () => {
|
||||
expect(toSafeInteger).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Number(toSafeInteger(3.2)) is a number', () => {
|
||||
test('Number(toSafeInteger(3.2)) is a number', () => {
|
||||
expect(Number(toSafeInteger(3.2))).toBeTruthy();
|
||||
});
|
||||
test('Converts a value to a safe integer', () => {
|
||||
expect(toSafeInteger(3.2)).toBe(3)
|
||||
test('Converts a value to a safe integer', () => {
|
||||
expect(toSafeInteger(3.2)).toBe(3);
|
||||
});
|
||||
test('toSafeInteger('4.2') returns 4', () => {
|
||||
expect(toSafeInteger('4.2')).toBe(4)
|
||||
test('toSafeInteger('4.2') returns 4', () => {
|
||||
expect(toSafeInteger('4.2')).toBe(4);
|
||||
});
|
||||
test('toSafeInteger(4.6) returns 5', () => {
|
||||
expect(toSafeInteger(4.6)).toBe(5)
|
||||
test('toSafeInteger(4.6) returns 5', () => {
|
||||
expect(toSafeInteger(4.6)).toBe(5);
|
||||
});
|
||||
test('toSafeInteger([]) returns 0', () => {
|
||||
expect(toSafeInteger([])).toBe(0)
|
||||
test('toSafeInteger([]) returns 0', () => {
|
||||
expect(toSafeInteger([])).toBe(0);
|
||||
});
|
||||
test('isNaN(toSafeInteger([1.5, 3124])) is true', () => {
|
||||
expect(isNaN(toSafeInteger([1.5, 3124]))).toBeTruthy()
|
||||
test('isNaN(toSafeInteger([1.5, 3124])) is true', () => {
|
||||
expect(isNaN(toSafeInteger([1.5, 3124]))).toBeTruthy();
|
||||
});
|
||||
test('isNaN(toSafeInteger('string')) is true', () => {
|
||||
expect(isNaN(toSafeInteger('string'))).toBeTruthy()
|
||||
test('isNaN(toSafeInteger('string')) is true', () => {
|
||||
expect(isNaN(toSafeInteger('string'))).toBeTruthy();
|
||||
});
|
||||
test('isNaN(toSafeInteger({})) is true', () => {
|
||||
expect(isNaN(toSafeInteger({}))).toBeTruthy()
|
||||
test('isNaN(toSafeInteger({})) is true', () => {
|
||||
expect(isNaN(toSafeInteger({}))).toBeTruthy();
|
||||
});
|
||||
test('isNaN(toSafeInteger()) is true', () => {
|
||||
expect(isNaN(toSafeInteger())).toBeTruthy()
|
||||
test('isNaN(toSafeInteger()) is true', () => {
|
||||
expect(isNaN(toSafeInteger())).toBeTruthy();
|
||||
});
|
||||
test('toSafeInteger(Infinity) returns 9007199254740991', () => {
|
||||
expect(toSafeInteger(Infinity)).toBe(9007199254740991)
|
||||
test('toSafeInteger(Infinity) returns 9007199254740991', () => {
|
||||
expect(toSafeInteger(Infinity)).toBe(9007199254740991);
|
||||
});
|
||||
|
||||
let start = new Date().getTime();
|
||||
toSafeInteger(3.2);
|
||||
let end = new Date().getTime();
|
||||
test('toSafeInteger(3.2) takes less than 2s to run', () => {
|
||||
let start = new Date().getTime();
|
||||
toSafeInteger(3.2);
|
||||
let end = new Date().getTime();
|
||||
test('toSafeInteger(3.2) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,34 +1,36 @@
|
||||
const expect = require('expect');
|
||||
const toSnakeCase = require('./toSnakeCase.js');
|
||||
|
||||
|
||||
test('toSnakeCase is a Function', () => {
|
||||
test('toSnakeCase is a Function', () => {
|
||||
expect(toSnakeCase).toBeInstanceOf(Function);
|
||||
});
|
||||
test('toSnakeCase('camelCase') returns camel_case', () => {
|
||||
expect(toSnakeCase('camelCase')).toBe('camel_case')
|
||||
test('toSnakeCase('\camelCase\') returns camel_case', () => {
|
||||
expect(toSnakeCase('camelCase')).toBe('camel_case');
|
||||
});
|
||||
test('toSnakeCase('some text') returns some_text', () => {
|
||||
expect(toSnakeCase('some text')).toBe('some_text')
|
||||
test('toSnakeCase(\'some text\') returns some_text', () => {
|
||||
expect(toSnakeCase('some text')).toBe('some_text');
|
||||
});
|
||||
test('toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens', () => {
|
||||
expect(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens')).toBe('some_mixed_string_with_spaces_underscores_and_hyphens')
|
||||
test('toSnakeCase(\'some-mixed_string With spaces_underscores-and-hyphens\') returns some_mixed_string_with_spaces_underscores_and_hyphens', () => {
|
||||
expect(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens')).toBe('some_mixed_string_with_spaces_underscores_and_hyphens');
|
||||
});
|
||||
test('toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', () => {
|
||||
test('toSnakeCase(\'IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML\') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', () => {
|
||||
expect(toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML')).toBe('i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html')
|
||||
});
|
||||
test('toSnakeCase() returns undefined', () => {
|
||||
expect(toSnakeCase(), undefined).toBe()
|
||||
test('toSnakeCase() returns undefined', () => {
|
||||
expect(toSnakeCase()).toBe(undefined);
|
||||
});
|
||||
t.throws(() => toSnakeCase([]), 'toSnakeCase([]) throws an error');
|
||||
t.throws(() => toSnakeCase({}), 'toSnakeCase({}) throws an error');
|
||||
t.throws(() => toSnakeCase(123), 'toSnakeCase(123) throws an error');
|
||||
|
||||
let start = new Date().getTime();
|
||||
toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML');
|
||||
let end = new Date().getTime();
|
||||
test('toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run', () => {
|
||||
test('toSnakeCase([]) throws an error', () => {
|
||||
expect(toSnakeCase([])).toThrow();
|
||||
});
|
||||
test('toSnakeCase({}) throws an error', () => {
|
||||
expect(toSnakeCase({})).toThrow();
|
||||
});
|
||||
test('toSnakeCase(123) throws an error', () => {
|
||||
expect(toSnakeCase(123)).toThrow();
|
||||
});
|
||||
let start = new Date().getTime();
|
||||
toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML');
|
||||
let end = new Date().getTime();
|
||||
test('toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run', () => {
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const toggleClass = require('./toggleClass.js');
|
||||
|
||||
|
||||
test('toggleClass is a Function', () => {
|
||||
test('toggleClass is a Function', () => {
|
||||
expect(toggleClass).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
const expect = require('expect');
|
||||
const tomorrow = require('./tomorrow.js');
|
||||
|
||||
|
||||
test('tomorrow is a Function', () => {
|
||||
test('tomorrow is a Function', () => {
|
||||
expect(tomorrow).toBeInstanceOf(Function);
|
||||
});
|
||||
const t1 = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1);
|
||||
const t2 = new Date(tomorrow());
|
||||
test('Returns the correct year', () => {
|
||||
expect(t1.getFullYear(), t2.getFullYear()).toBe()
|
||||
const t1 = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1);
|
||||
const t2 = new Date(tomorrow());
|
||||
test('Returns the correct year', () => {
|
||||
expect(t1.getFullYear()).toBe(t2.getFullYear());
|
||||
});
|
||||
test('Returns the correct month', () => {
|
||||
expect(t1.getMonth(), t2.getMonth()).toBe()
|
||||
test('Returns the correct month', () => {
|
||||
expect(t1.getMonth()).toBe(t2.getMonth());
|
||||
});
|
||||
test('Returns the correct date', () => {
|
||||
expect(t1.getDate(), t2.getDate()).toBe()
|
||||
test('Returns the correct date', () => {
|
||||
expect(t1.getDate()).toBe(t2.getDate());
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
const expect = require('expect');
|
||||
const transform = require('./transform.js');
|
||||
|
||||
|
||||
test('transform is a Function', () => {
|
||||
test('transform is a Function', () => {
|
||||
expect(transform).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(transform(
|
||||
test('Transforms an object', () => {
|
||||
expect(transform(
|
||||
{ a: 1, b: 2, c: 1 },
|
||||
(r, v, k) => {
|
||||
(r[v] || (r[v] = [])).push(k);
|
||||
return r;
|
||||
},
|
||||
{}
|
||||
), { '1': ['a', 'c'], '2': ['b'] }, 'Transforms an object');
|
||||
|
||||
|
||||
},{}).toEqual({ '1': ['a', 'c'], '2': ['b'] });
|
||||
});
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const truncateString = require('./truncateString.js');
|
||||
|
||||
|
||||
test('truncateString is a Function', () => {
|
||||
test('truncateString is a Function', () => {
|
||||
expect(truncateString).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Truncates a "boomerang" up to a specified length.', () => {
|
||||
expect(truncateString('boomerang', 7), 'boom...').toBe()
|
||||
test('Truncates a "boomerang" up to a specified length.', () => {
|
||||
expect(truncateString('boomerang', 7)).toBe('boom...');
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const truthCheckCollection = require('./truthCheckCollection.js');
|
||||
|
||||
|
||||
test('truthCheckCollection is a Function', () => {
|
||||
test('truthCheckCollection is a Function', () => {
|
||||
expect(truthCheckCollection).toBeInstanceOf(Function);
|
||||
});
|
||||
test('second argument is truthy on all elements of a collection', () => {
|
||||
expect(truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex')).toBe(true)
|
||||
test('second argument is truthy on all elements of a collection', () => {
|
||||
expect(truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex')).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user