Test cleanup and fixes [s-t]

This commit is contained in:
Angelos Chalaris
2018-06-18 18:37:35 +03:00
parent ba3e684a27
commit 9cf2c4680c
53 changed files with 286 additions and 409 deletions

View File

@ -1,20 +1,19 @@
const expect = require('expect');
const shuffle = require('./shuffle.js');
test('shuffle is a Function', () => {
test('shuffle is a Function', () => {
expect(shuffle).toBeInstanceOf(Function);
});
const arr = [1,2,3,4,5,6];
t.notEqual(shuffle(arr), arr, 'Shuffles the array');
test('New array contains all original elements', () => {
const arr = [1,2,3,4,5,6];
test('Shuffles the array', () => {
expect(shuffle(arr)).not.toEqual(arr);
});
test('New array contains all original elements', () => {
expect(shuffle(arr).every(x => arr.includes(x))).toBeTruthy();
});
test('Works for empty arrays', () => {
expect(shuffle([]),[]).toEqual()
test('Works for empty arrays', () => {
expect(shuffle([])).toEqual([]);
});
test('Works for single-element arrays', () => {
expect(shuffle([1]),[1]).toEqual()
test('Works for single-element arrays', () => {
expect(shuffle([1])).toEqual([1]);
});