deno.land / x / rambda@v9.1.1 / source / transpose.spec.js

transpose.spec.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { transpose } from './transpose.js'
test('happy', () => { const input = [ [ 'a', 1 ], [ 'b', 2 ], [ 'c', 3 ], ]
expect(transpose(input)).toEqual([ [ 'a', 'b', 'c' ], [ 1, 2, 3 ], ])})
test('when rows are shorter', () => { const actual = transpose([ [ 10, 11 ], [ 20 ], [], [ 30, 31, 32 ] ]) const expected = [ [ 10, 20, 30 ], [ 11, 31 ], [ 32 ] ] expect(actual).toEqual(expected)})
test('with empty array', () => { expect(transpose([])).toEqual([])})
test('array with falsy values', () => { const actual = transpose([ [ true, false, undefined, null ], [ null, undefined, false, true ], ]) const expected = [ [ true, null ], [ false, undefined ], [ undefined, false ], [ null, true ], ] expect(actual).toEqual(expected)})
rambda

Version Info

Tagged at
2 months ago