Test cleanup and fixes [o-p]

This commit is contained in:
Angelos Chalaris
2018-06-18 18:00:19 +03:00
parent b393ad5878
commit 43e92c610d
35 changed files with 164 additions and 262 deletions

View File

@ -1,27 +1,24 @@
const expect = require('expect');
const offset = require('./offset.js');
test('offset is a Function', () => {
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()
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), [3, 4, 5, 1, 2]).toEqual()
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), [4, 5, 1, 2, 3]).toEqual()
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),[1, 2, 3, 4, 5]).toEqual()
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), [1, 2, 3, 4, 5]).toEqual()
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()
test('Offsetting empty array returns an empty array.', () => {
expect(offset([], 3)).toEqual([]);
});