Test migration to jest by hand

Apparently using regular expressions is way easier.
This commit is contained in:
Angelos Chalaris
2018-06-18 15:15:56 +03:00
parent 5df7098fac
commit a78f5db260
894 changed files with 5917 additions and 3607 deletions

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

@ -0,0 +1,7 @@
const zip = (...arrays) => {
const maxLength = Math.max(...arrays.map(x => x.length));
return Array.from({ length: maxLength }).map((_, i) => {
return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
};
module.exports = zip;

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

@ -0,0 +1,22 @@
const expect = require('expect');
const zip = require('./zip.js');
test('zip is a Function', () => {
expect(zip).toBeInstanceOf(Function);
});
t.deepEqual(zip(['a', 'b'], [1, 2], [true, false]), [['a', 1, true], ['b', 2, false]], 'zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]]');
t.deepEqual(zip(['a'], [1, 2], [true, false]), [['a', 1, true], [undefined, 2, false]], 'zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]]');
t.deepEqual(zip(), [], 'zip([]) returns []');
t.deepEqual(zip(123), [], 'zip(123) returns []');
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();
});
t.throws(() => zip(null), 'zip(null) throws an error');
t.throws(() => zip(undefined), 'zip(undefined) throws an error');