Files
30-seconds-of-code/test/nthElement.test.js
Angelos Chalaris 91c1de3a45 Additional tests
2018-10-31 21:04:22 +02:00

19 lines
605 B
JavaScript

const expect = require('expect');
const {nthElement} = require('./_30s.js');
test('nthElement is a Function', () => {
expect(nthElement).toBeInstanceOf(Function);
});
test('Returns the nth element of an array.', () => {
expect(nthElement(['a', 'b', 'c'], 1)).toBe('b');
});
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');
});