Test cleanup and fixes [o-p]
This commit is contained in:
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const objectFromPairs = require('./objectFromPairs.js');
|
||||
|
||||
|
||||
test('objectFromPairs is a Function', () => {
|
||||
expect(objectFromPairs).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Creates an object from the given key-value pairs.', () => {
|
||||
expect(objectFromPairs([['a', 1], ['b', 2]]), {a: 1).toEqual(b: 2})
|
||||
expect(objectFromPairs([['a', 1], ['b', 2]])).toEqual({a: 1, b: 2});
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const objectToPairs = require('./objectToPairs.js');
|
||||
|
||||
|
||||
test('objectToPairs is a Function', () => {
|
||||
expect(objectToPairs).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Creates an array of key-value pair arrays from an object.', () => {
|
||||
expect(objectToPairs({ a: 1, b: 2 }), [['a',1],['b').toEqual(2]])
|
||||
expect(objectToPairs({ a: 1, b: 2 })).toEqual([['a',1],['b', 2]]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const observeMutations = require('./observeMutations.js');
|
||||
|
||||
|
||||
test('observeMutations is a Function', () => {
|
||||
expect(observeMutations).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const off = require('./off.js');
|
||||
|
||||
|
||||
test('off is a Function', () => {
|
||||
expect(off).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,27 +1,24 @@
|
||||
const expect = require('expect');
|
||||
const offset = require('./offset.js');
|
||||
|
||||
|
||||
test('offset is a Function', () => {
|
||||
expect(offset).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Offset of 0 returns the same array.', () => {
|
||||
expect(offset([1, 2, 3, 4, 5], 0), [1, 2, 3, 4, 5]).toEqual()
|
||||
expect(offset([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
test('Offset > 0 returns the offsetted array.', () => {
|
||||
expect(offset([1, 2, 3, 4, 5], 2), [3, 4, 5, 1, 2]).toEqual()
|
||||
expect(offset([1, 2, 3, 4, 5], 2)).toEqual([3, 4, 5, 1, 2]);
|
||||
});
|
||||
test('Offset < 0 returns the reverse offsetted array.', () => {
|
||||
expect(offset([1, 2, 3, 4, 5], -2), [4, 5, 1, 2, 3]).toEqual()
|
||||
expect(offset([1, 2, 3, 4, 5], -2)).toEqual([4, 5, 1, 2, 3]);
|
||||
});
|
||||
test('Offset greater than the length of the array returns the same array.', () => {
|
||||
expect(offset([1, 2, 3, 4, 5], 6),[1, 2, 3, 4, 5]).toEqual()
|
||||
expect(offset([1, 2, 3, 4, 5], 6)).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
test('Offset less than the negative length of the array returns the same array.', () => {
|
||||
expect(offset([1, 2, 3, 4, 5], -6), [1, 2, 3, 4, 5]).toEqual()
|
||||
expect(offset([1, 2, 3, 4, 5], -6)).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
test('Offsetting empty array returns an empty array.', () => {
|
||||
expect(offset([], 3), []).toEqual()
|
||||
expect(offset([], 3)).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const omit = require('./omit.js');
|
||||
|
||||
|
||||
test('omit is a Function', () => {
|
||||
expect(omit).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Omits the key-value pairs corresponding to the given keys from an object', () => {
|
||||
expect(omit({ a: 1, b: '2', c: 3 }, ['b']), { 'a': 1, 'c': 3 }).toEqual()
|
||||
expect(omit({ a: 1, b: '2', c: 3 }, ['b'])).toEqual({ 'a': 1, 'c': 3 });
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const omitBy = require('./omitBy.js');
|
||||
|
||||
|
||||
test('omitBy is a Function', () => {
|
||||
expect(omitBy).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Creates an object composed of the properties the given function returns falsey for', () => {
|
||||
expect(omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'), { b: '2' }).toEqual()
|
||||
expect(omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number')).toEqual( { b: '2' });
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const on = require('./on.js');
|
||||
|
||||
|
||||
test('on is a Function', () => {
|
||||
expect(on).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const onUserInputChange = require('./onUserInputChange.js');
|
||||
|
||||
|
||||
test('onUserInputChange is a Function', () => {
|
||||
expect(onUserInputChange).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const once = require('./once.js');
|
||||
|
||||
|
||||
test('once is a Function', () => {
|
||||
expect(once).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
const expect = require('expect');
|
||||
const orderBy = require('./orderBy.js');
|
||||
|
||||
|
||||
test('orderBy is a Function', () => {
|
||||
expect(orderBy).toBeInstanceOf(Function);
|
||||
});
|
||||
const users = [{ name: 'fred', age: 48 }, { name: 'barney', age: 36 }, { name: 'fred', age: 40 }];
|
||||
test('Returns a sorted array of objects ordered by properties and orders.', () => {
|
||||
expect(orderBy(users, ['name', 'age'], ['asc', 'desc']), [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred').toEqual(age: 40}])
|
||||
expect(orderBy(users, ['name', 'age'], ['asc', 'desc'])).toEqual([{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}]);
|
||||
});
|
||||
test('Returns a sorted array of objects ordered by properties and orders.', () => {
|
||||
expect(orderBy(users, ['name', 'age']), [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred').toEqual(age: 48}])
|
||||
expect(orderBy(users, ['name', 'age'])).toEqual( [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const over = require('./over.js');
|
||||
|
||||
|
||||
test('over is a Function', () => {
|
||||
expect(over).toBeInstanceOf(Function);
|
||||
});
|
||||
const minMax = over(Math.min, Math.max);
|
||||
test('Applies given functions over multiple arguments', () => {
|
||||
expect(minMax(1, 2, 3, 4, 5), [1,5]).toEqual()
|
||||
expect(minMax(1, 2, 3, 4, 5)).toEqual([1,5]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const overArgs = require('./overArgs.js');
|
||||
|
||||
|
||||
test('overArgs is a Function', () => {
|
||||
expect(overArgs).toBeInstanceOf(Function);
|
||||
});
|
||||
@ -9,7 +8,5 @@ const overArgs = require('./overArgs.js');
|
||||
const double = n => n * 2;
|
||||
const fn = overArgs((x, y) => [x, y], [square, double]);
|
||||
test('Invokes the provided function with its arguments transformed', () => {
|
||||
expect(fn(9, 3), [81, 6]).toEqual()
|
||||
expect(fn(9, 3)).toEqual([81, 6]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,21 +1,18 @@
|
||||
const expect = require('expect');
|
||||
const pad = require('./pad.js');
|
||||
|
||||
|
||||
test('pad is a Function', () => {
|
||||
expect(pad).toBeInstanceOf(Function);
|
||||
});
|
||||
test('cat is padded on both sides', () => {
|
||||
expect(pad('cat',8), ' cat ').toBe()
|
||||
expect(pad('cat',8)).toBe(' cat ');
|
||||
});
|
||||
test('length of string is 8', () => {
|
||||
expect(pad('cat',8).length, 8).toBe()
|
||||
expect(pad('cat',8).length).toBe(8);
|
||||
});
|
||||
test('pads 42 with "0"', () => {
|
||||
expect(pad(String(42), 6, '0'), '004200').toBe()
|
||||
expect(pad(String(42), 6, '0')).toBe('004200');
|
||||
});
|
||||
test('does not truncates if string exceeds length', () => {
|
||||
expect(pad('foobar', 3), 'foobar').toBe()
|
||||
expect(pad('foobar', 3)).toBe('foobar');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const palindrome = require('./palindrome.js');
|
||||
|
||||
|
||||
test('palindrome is a Function', () => {
|
||||
expect(palindrome).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Given string is a palindrome', () => {
|
||||
expect(palindrome('taco cat')).toBe(true)
|
||||
expect(palindrome('taco cat')).toBeTruthy();
|
||||
});
|
||||
test('Given string is not a palindrome', () => {
|
||||
expect(palindrome('foobar')).toBe(false)
|
||||
expect(palindrome('foobar')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const parseCookie = require('./parseCookie.js');
|
||||
|
||||
|
||||
test('parseCookie is a Function', () => {
|
||||
expect(parseCookie).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Parses the cookie', () => {
|
||||
expect(parseCookie('foo=bar; equation=E%3Dmc%5E2'), { foo: 'bar', equation: 'E=mc^2' }).toEqual()
|
||||
expect(parseCookie('foo=bar; equation=E%3Dmc%5E2')).toEqual({ foo: 'bar', equation: 'E=mc^2' });
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const partial = require('./partial.js');
|
||||
|
||||
|
||||
test('partial is a Function', () => {
|
||||
expect(partial).toBeInstanceOf(Function);
|
||||
});
|
||||
@ -10,7 +9,5 @@ const partial = require('./partial.js');
|
||||
}
|
||||
const greetHello = partial(greet, 'Hello');
|
||||
test('Prepends arguments', () => {
|
||||
expect(greetHello('John'), 'Hello John!').toBe()
|
||||
expect(greetHello('John')).toBe('Hello John!');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const partialRight = require('./partialRight.js');
|
||||
|
||||
|
||||
test('partialRight is a Function', () => {
|
||||
expect(partialRight).toBeInstanceOf(Function);
|
||||
});
|
||||
@ -10,7 +9,5 @@ const partialRight = require('./partialRight.js');
|
||||
}
|
||||
const greetJohn = partialRight(greet, 'John');
|
||||
test('Appends arguments', () => {
|
||||
expect(greetJohn('Hello'), 'Hello John!').toBe()
|
||||
expect(greetJohn('Hello')).toBe('Hello John!');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const partition = require('./partition.js');
|
||||
|
||||
|
||||
test('partition is a Function', () => {
|
||||
expect(partition).toBeInstanceOf(Function);
|
||||
});
|
||||
const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }];
|
||||
test('Groups the elements into two arrays, depending on the provided function's truthiness for each element.', () => {
|
||||
expect(partition(users, o => o.active), [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36).toEqual('active': false }]])
|
||||
test('Groups the elements into two arrays, depending on the provided function\'s truthiness for each element.', () => {
|
||||
expect(partition(users, o => o.active)).toEqual([[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const percentile = require('./percentile.js');
|
||||
|
||||
|
||||
test('percentile is a Function', () => {
|
||||
expect(percentile).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.', () => {
|
||||
expect(percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6)).toBe(55)
|
||||
expect(percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6)).toBe(55);
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const permutations = require('./permutations.js');
|
||||
|
||||
|
||||
test('permutations is a Function', () => {
|
||||
expect(permutations).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Generates all permutations of an array', () => {
|
||||
expect(permutations([1, 33, 5]), [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ]).toEqual()
|
||||
expect(permutations([1, 33, 5])).toEqual([ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const pick = require('./pick.js');
|
||||
|
||||
|
||||
test('pick is a Function', () => {
|
||||
expect(pick).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Picks the key-value pairs corresponding to the given keys from an object.', () => {
|
||||
expect(pick({ a: 1, b: '2', c: 3 }, ['a', 'c']), { 'a': 1).toEqual('c': 3 })
|
||||
expect(pick({ a: 1, b: '2', c: 3 }, ['a', 'c'])).toEqual({ 'a': 1, 'c': 3 });
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const pickBy = require('./pickBy.js');
|
||||
|
||||
|
||||
test('pickBy is a Function', () => {
|
||||
expect(pickBy).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Creates an object composed of the properties the given function returns truthy for.', () => {
|
||||
expect(pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'), { 'a': 1, 'c': 3 }).toEqual()
|
||||
expect(pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number')).toEqual({ 'a': 1, 'c': 3 });
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,19 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const pipeAsyncFunctions = require('./pipeAsyncFunctions.js');
|
||||
|
||||
|
||||
test('pipeAsyncFunctions is a Function', () => {
|
||||
expect(pipeAsyncFunctions).toBeInstanceOf(Function);
|
||||
});
|
||||
t.equal(
|
||||
await pipeAsyncFunctions(
|
||||
test('pipeAsyncFunctions result should be 15', () => {
|
||||
expect(await pipeAsyncFunctions(
|
||||
(x) => x + 1,
|
||||
(x) => new Promise((resolve) => setTimeout(() => resolve(x + 2), 0)),
|
||||
(x) => x + 3,
|
||||
async (x) => await x + 4,
|
||||
)
|
||||
(5),
|
||||
15,
|
||||
'pipeAsyncFunctions result should be 15'
|
||||
);
|
||||
|
||||
(5)).toBe(15);
|
||||
});
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const pipeFunctions = require('./pipeFunctions.js');
|
||||
|
||||
|
||||
test('pipeFunctions is a Function', () => {
|
||||
expect(pipeFunctions).toBeInstanceOf(Function);
|
||||
});
|
||||
@ -9,7 +8,5 @@ const pipeFunctions = require('./pipeFunctions.js');
|
||||
const multiply = (x, y) => x * y;
|
||||
const multiplyAndAdd5 = pipeFunctions(multiply, add5);
|
||||
test('Performs left-to-right function composition', () => {
|
||||
expect(multiplyAndAdd5(5, 2), 15).toBe()
|
||||
expect(multiplyAndAdd5(5, 2)).toBe(15);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,21 +1,20 @@
|
||||
const expect = require('expect');
|
||||
const pluralize = require('./pluralize.js');
|
||||
|
||||
|
||||
test('pluralize is a Function', () => {
|
||||
expect(pluralize).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Produces the plural of the word', () => {
|
||||
expect(pluralize(0, 'apple'), 'apples').toBe()
|
||||
expect(pluralize(0, 'apple')).toBe('apples');
|
||||
});
|
||||
test('Produces the singular of the word', () => {
|
||||
expect(pluralize(1, 'apple'), 'apple').toBe()
|
||||
expect(pluralize(1, 'apple')).toBe('apple');
|
||||
});
|
||||
test('Produces the plural of the word', () => {
|
||||
expect(pluralize(2, 'apple'), 'apples').toBe()
|
||||
expect(pluralize(2, 'apple')).toBe('apples');
|
||||
});
|
||||
test('Prodices the defined plural of the word', () => {
|
||||
expect(pluralize(2, 'person', 'people'), 'people').toBe()
|
||||
expect(pluralize(2, 'person', 'people')).toBe('people');
|
||||
});
|
||||
const PLURALS = {
|
||||
person: 'people',
|
||||
@ -23,7 +22,5 @@ const pluralize = require('./pluralize.js');
|
||||
};
|
||||
const autoPluralize = pluralize(PLURALS);
|
||||
test('Works with a dictionary', () => {
|
||||
expect(autoPluralize(2, 'person'), 'people').toBe()
|
||||
expect(autoPluralize(2, 'person')).toBe('people');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const powerset = require('./powerset.js');
|
||||
|
||||
|
||||
test('powerset is a Function', () => {
|
||||
expect(powerset).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the powerset of a given array of numbers.', () => {
|
||||
expect(powerset([1, 2]), [[], [1], [2], [2).toEqual(1]])
|
||||
expect(powerset([1, 2])).toEqual([[], [1], [2], [2, 1]]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const prefix = require('./prefix.js');
|
||||
|
||||
|
||||
test('prefix is a Function', () => {
|
||||
expect(prefix).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const prettyBytes = require('./prettyBytes.js');
|
||||
|
||||
|
||||
test('prettyBytes is a Function', () => {
|
||||
expect(prettyBytes).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Converts a number in bytes to a human-readable string.', () => {
|
||||
expect(prettyBytes(1000)).toBe('1 KB')
|
||||
expect(prettyBytes(1000)).toBe('1 KB');
|
||||
});
|
||||
test('Converts a number in bytes to a human-readable string.', () => {
|
||||
expect(prettyBytes(-27145424323.5821, 5)).toBe('-27.145 GB')
|
||||
expect(prettyBytes(-27145424323.5821, 5)).toBe('-27.145 GB');
|
||||
});
|
||||
test('Converts a number in bytes to a human-readable string.', () => {
|
||||
expect(prettyBytes(123456789, 3, false)).toBe('123MB')
|
||||
expect(prettyBytes(123456789, 3, false)).toBe('123MB');
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const primes = require('./primes.js');
|
||||
|
||||
|
||||
test('primes is a Function', () => {
|
||||
expect(primes).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Generates primes up to a given number, using the Sieve of Eratosthenes.', () => {
|
||||
expect(primes(10), [2, 3, 5).toEqual(7])
|
||||
expect(primes(10)).toEqual([2, 3, 5, 7]);
|
||||
});
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const promisify = require('./promisify.js');
|
||||
|
||||
|
||||
test('promisify is a Function', () => {
|
||||
expect(promisify).toBeInstanceOf(Function);
|
||||
});
|
||||
@ -9,7 +8,7 @@ const promisify = require('./promisify.js');
|
||||
test('Returns a promise', () => {
|
||||
expect(x() instanceof Promise).toBeTruthy();
|
||||
});
|
||||
test('Runs the function provided', () => {
|
||||
const delay = promisify((d, cb) => setTimeout(cb, d));
|
||||
delay(200).then(() =>
|
||||
|
||||
|
||||
delay(200).then(() => expect(true).toBeTruthy());
|
||||
});
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
const expect = require('expect');
|
||||
const pull = require('./pull.js');
|
||||
|
||||
|
||||
test('pull is a Function', () => {
|
||||
expect(pull).toBeInstanceOf(Function);
|
||||
});
|
||||
let myArray = ['a', 'b', 'c', 'a', 'b', 'c'];
|
||||
pull(myArray, 'a', 'c');
|
||||
test('Pulls the specified values', () => {
|
||||
expect(myArray, ['b','b']).toEqual()
|
||||
expect(myArray).toEqual(['b','b'])
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
const expect = require('expect');
|
||||
const pullAtIndex = require('./pullAtIndex.js');
|
||||
|
||||
|
||||
test('pullAtIndex is a Function', () => {
|
||||
expect(pullAtIndex).toBeInstanceOf(Function);
|
||||
});
|
||||
let myArray = ['a', 'b', 'c', 'd'];
|
||||
let pulled = pullAtIndex(myArray, [1, 3]);
|
||||
test('Pulls the given values', () => {
|
||||
expect(myArray, [ 'a', 'c' ]).toEqual()
|
||||
expect(myArray).toEqual([ 'a', 'c' ]);
|
||||
});
|
||||
test('Pulls the given values', () => {
|
||||
expect(pulled, [ 'b', 'd' ]).toEqual()
|
||||
expect(pulled).toEqual([ 'b', 'd' ]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
const expect = require('expect');
|
||||
const pullAtValue = require('./pullAtValue.js');
|
||||
|
||||
|
||||
test('pullAtValue is a Function', () => {
|
||||
expect(pullAtValue).toBeInstanceOf(Function);
|
||||
});
|
||||
let myArray = ['a', 'b', 'c', 'd'];
|
||||
let pulled = pullAtValue(myArray, ['b', 'd']);
|
||||
test('Pulls the specified values', () => {
|
||||
expect(myArray, [ 'a', 'c' ]).toEqual()
|
||||
expect(myArray).toEqual([ 'a', 'c' ]);
|
||||
});
|
||||
test('Pulls the specified values', () => {
|
||||
expect(pulled, [ 'b', 'd' ]).toEqual()
|
||||
expect(pulled).toEqual([ 'b', 'd' ]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
const expect = require('expect');
|
||||
const pullBy = require('./pullBy.js');
|
||||
|
||||
|
||||
test('pullBy is a Function', () => {
|
||||
expect(pullBy).toBeInstanceOf(Function);
|
||||
});
|
||||
var myArray = [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }];
|
||||
pullBy(myArray, [{ x: 1 }, { x: 3 }], o => o.x);
|
||||
test('Pulls the specified values', () => {
|
||||
expect(myArray, [{ x: 2 }]).toEqual()
|
||||
expect(myArray).toEqual([{ x: 2 }]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user