Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
8
test/unzip/unzip.js
Normal file
8
test/unzip/unzip.js
Normal file
@ -0,0 +1,8 @@
|
||||
const unzip = arr =>
|
||||
arr.reduce(
|
||||
(acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc),
|
||||
Array.from({
|
||||
length: Math.max(...arr.map(x => x.length))
|
||||
}).map(x => [])
|
||||
);
|
||||
module.exports = unzip;
|
||||
11
test/unzip/unzip.test.js
Normal file
11
test/unzip/unzip.test.js
Normal file
@ -0,0 +1,11 @@
|
||||
const expect = require('expect');
|
||||
const unzip = require('./unzip.js');
|
||||
|
||||
|
||||
test('unzip is a Function', () => {
|
||||
expect(unzip).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(unzip([['a', 1, true], ['b', 2, false]]), [['a', 'b'], [1, 2], [true, false]], `unzip([['a', 1, true], ['b', 2, false]]) equals [['a', 'b'], [1, 2], [true, false]]`);
|
||||
t.deepEqual(unzip([['a', 1, true], ['b', 2]]), [['a', 'b'], [1, 2], [true]], `unzip([['a', 1, true], ['b', 2]]) equals [['a', 'b'], [1, 2], [true]]`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user