Additional tests
This commit is contained in:
@ -4,3 +4,9 @@ const {initializeNDArray} = require('./_30s.js');
|
||||
test('initializeNDArray is a Function', () => {
|
||||
expect(initializeNDArray).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Initializes a n-D array with given data', () => {
|
||||
expect(initializeNDArray(1, 3)).toEqual([1, 1, 1]);
|
||||
});
|
||||
test('Initializes a n-D array with given data', () => {
|
||||
expect(initializeNDArray(5, 2, 2, 2)).toEqual([[[5, 5], [5, 5]],[[5, 5], [5, 5]]]);
|
||||
});
|
||||
|
||||
@ -10,3 +10,6 @@ test('Returns the median of an array of numbers', () => {
|
||||
test('Returns the median of an array of numbers', () => {
|
||||
expect(median([1, 2, 3])).toBe(2);
|
||||
});
|
||||
test('Returns the median of an array of numbers', () => {
|
||||
expect(median([1, 2, 3, 4])).toBe(2.5);
|
||||
});
|
||||
|
||||
@ -4,3 +4,13 @@ const {nest} = require('./_30s.js');
|
||||
test('nest is a Function', () => {
|
||||
expect(nest).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Nests items', () => {
|
||||
const comments = [
|
||||
{ id: 1, parent_id: null },
|
||||
{ id: 2, parent_id: 1 },
|
||||
{ id: 3, parent_id: 1 },
|
||||
{ id: 4, parent_id: 2 },
|
||||
{ id: 5, parent_id: 4 }
|
||||
];
|
||||
expect(nest(comments)).toEqual([{ 'id': 1, 'parent_id': null, 'children': [{ 'id': 2, 'parent_id': 1, 'children': [{ 'id': 4, 'parent_id': 2, 'children': [{ 'id': 5, 'parent_id': 4, 'children': [] }] }] }, { 'id': 3, 'parent_id': 1, 'children': [] }] }]);
|
||||
});
|
||||
|
||||
@ -10,3 +10,9 @@ test('Returns the nth element of an array.', () => {
|
||||
test('Returns the nth element of an array.', () => {
|
||||
expect(nthElement(['a', 'b', 'c'], -3)).toBe('a');
|
||||
});
|
||||
test('Returns the nth element of an array.', () => {
|
||||
expect(nthElement(['a', 'b', 'c'], -1)).toBe('c');
|
||||
});
|
||||
test('Returns the nth element of an array.', () => {
|
||||
expect(nthElement(['a', 'b', 'c'])).toBe('a');
|
||||
});
|
||||
|
||||
@ -4,3 +4,6 @@ const {once} = require('./_30s.js');
|
||||
test('once is a Function', () => {
|
||||
expect(once).toBeInstanceOf(Function);
|
||||
});
|
||||
test('once is a Function', () => {
|
||||
expect(typeof once(x => 10)).toBe('function');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user