* chore: make aware eslint that we use jest By setting up the jest environment, we no longer need to declare the 'test' global in the configuration. * chore: don't need to import expect, it's a jest environment global * chore: don't need to import expect when creating undefined test
24 lines
911 B
JavaScript
24 lines
911 B
JavaScript
const {offset} = require('./_30s.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)).toEqual([1, 2, 3, 4, 5]);
|
|
});
|
|
test('Offset > 0 returns the offsetted array.', () => {
|
|
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)).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)).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)).toEqual([1, 2, 3, 4, 5]);
|
|
});
|
|
test('Offsetting empty array returns an empty array.', () => {
|
|
expect(offset([], 3)).toEqual([]);
|
|
});
|