Updated the test system

This commit is contained in:
Angelos Chalaris
2018-10-10 23:36:17 +03:00
parent 0f334e1431
commit 1edaed51e4
725 changed files with 385 additions and 2332 deletions

19
test/shuffle.test.js Normal file
View File

@ -0,0 +1,19 @@
const expect = require('expect');
const {shuffle} = require('./_30s.js');
test('shuffle is a Function', () => {
expect(shuffle).toBeInstanceOf(Function);
});
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 single-element arrays', () => {
expect(shuffle([1])).toEqual([1]);
});