Additional tests
This commit is contained in:
@ -21,3 +21,16 @@ test('[1,2,3] is not equal to [1,2,4]', () => {
|
|||||||
test('[1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match.', () => {
|
test('[1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match.', () => {
|
||||||
expect(equals([1, 2, 3], { 0: 1, 1: 2, 2: 3 })).toBeTruthy();
|
expect(equals([1, 2, 3], { 0: 1, 1: 2, 2: 3 })).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
const date = new Date();
|
||||||
|
test('Two of the same date are equal', () => {
|
||||||
|
expect(equals(date, date)).toBeTruthy();
|
||||||
|
});
|
||||||
|
test('null should not be equal to anything', () => {
|
||||||
|
expect(equals(null, 'test')).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('undefined should not be equal to anything', () => {
|
||||||
|
expect(equals(undefined, 'test')).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('{a: ""} should not be equal to {a: "", b: ""}', () => {
|
||||||
|
expect(equals({a: ''}, {a: '', b: ''})).toBeFalsy();
|
||||||
|
});
|
||||||
|
|||||||
@ -4,3 +4,9 @@ const {sumBy} = require('./_30s.js');
|
|||||||
test('sumBy is a Function', () => {
|
test('sumBy is a Function', () => {
|
||||||
expect(sumBy).toBeInstanceOf(Function);
|
expect(sumBy).toBeInstanceOf(Function);
|
||||||
});
|
});
|
||||||
|
test('Works with a callback.', () => {
|
||||||
|
expect(sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n)).toBe(20);
|
||||||
|
});
|
||||||
|
test('Works with a property name.', () => {
|
||||||
|
expect(sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n')).toBe(20);
|
||||||
|
});
|
||||||
@ -10,3 +10,6 @@ test('Returns an array with n elements removed from the beginning.', () => {
|
|||||||
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([]);
|
expect(take([1, 2, 3], 0)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
test('Returns an array with n elements removed from the beginning.', () => {
|
||||||
|
expect(take([1, 2, 3])).toEqual([1]);
|
||||||
|
});
|
||||||
|
|||||||
@ -7,3 +7,6 @@ test('takeWhile is a Function', () => {
|
|||||||
test('Removes elements until the function returns true', () => {
|
test('Removes elements until the function returns true', () => {
|
||||||
expect(takeWhile([1, 2, 3, 4], n => n >= 3)).toEqual([1, 2]);
|
expect(takeWhile([1, 2, 3, 4], n => n >= 3)).toEqual([1, 2]);
|
||||||
});
|
});
|
||||||
|
test('Removes elements until the function returns true', () => {
|
||||||
|
expect(takeWhile([1, 2, 3, 4], n => false)).toEqual([1, 2, 3, 4]);
|
||||||
|
});
|
||||||
|
|||||||
@ -4,3 +4,6 @@ const {timeTaken} = require('./_30s.js');
|
|||||||
test('timeTaken is a Function', () => {
|
test('timeTaken is a Function', () => {
|
||||||
expect(timeTaken).toBeInstanceOf(Function);
|
expect(timeTaken).toBeInstanceOf(Function);
|
||||||
});
|
});
|
||||||
|
test('timeTaken is a Function', () => {
|
||||||
|
expect(timeTaken(() => 10)).toBe(10);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user