forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranspose.js
22 lines (21 loc) · 864 Bytes
/
transpose.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('transpose', function() {
it('returns an array of two arrays', function() {
var input = [['a', 1], ['b', 2], ['c', 3]];
eq(R.transpose(input), [['a', 'b', 'c'], [1, 2, 3]]);
});
it('skips elements when rows are shorter', function() {
var actual = R.transpose([[10, 11], [20], [], [30, 31, 32]]);
var expected = [[10, 20, 30], [11, 31], [32]];
eq(actual, expected);
});
it('copes with empty arrays', function() {
eq(R.transpose([]), []);
});
it('copes with true, false, null & undefined elements of arrays', function() {
var actual = R.transpose([[true, false, undefined, null], [null, undefined, false, true]]);
var expected = [[true, null], [false, undefined], [undefined, false], [null, true]];
eq(actual, expected);
});
});