Updated the test system

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

34
test/zip.test.js Normal file
View File

@ -0,0 +1,34 @@
const expect = require('expect');
const {zip} = require('./_30s.js');
test('zip is a Function', () => {
expect(zip).toBeInstanceOf(Function);
});
test('zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]]', () => {
expect(zip(['a', 'b'], [1, 2], [true, false])).toEqual([['a', 1, true], ['b', 2, false]]);
});
test('zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]]', () => {
expect(zip(['a'], [1, 2], [true, false])).toEqual([['a', 1, true], [undefined, 2, false]]);
});
test('zip([]) returns []', () => {
expect(zip()).toEqual([]);
});
test('zip(123) returns []', () => {
expect(zip(123)).toEqual([]);
});
test('zip([a, b], [1, 2], [true, false]) returns an Array', () => {
expect(Array.isArray(zip(['a', 'b'], [1, 2], [true, false]))).toBeTruthy();
});
test('zip([a], [1, 2], [true, false]) returns an Array', () => {
expect(Array.isArray(zip(['a'], [1, 2], [true, false]))).toBeTruthy();
});
test('zip(null) throws an error', () => {
expect(() => {
zip(null);
}).toThrow();
});
test('zip(undefined) throws an error', () => {
expect(() => {
zip(undefined);
}).toThrow();
});