1 | const test = require('./config').test
|
2 | const { pipeline } = require('..')
|
3 |
|
4 | test('pass single argument to function', t => {
|
5 | t.is(pipeline(1)(x => x + 2), 3)
|
6 | })
|
7 |
|
8 | test('pass multiple arguments to function', t => {
|
9 | t.is(pipeline(1, 5)(
|
10 | (x, y) => x + y
|
11 | ), 6)
|
12 | t.is(pipeline(1, 2, 5)(
|
13 | (x, y, z) => x + y - z
|
14 | ), -2)
|
15 | })
|
16 |
|
17 | test('chain multiple functions', t => {
|
18 | t.is(pipeline(2)(
|
19 | x => x + 1,
|
20 | y => y - 2
|
21 | ), 1)
|
22 | t.is(pipeline(2)(
|
23 | x => x + 1,
|
24 | y => y - 2,
|
25 | z => z * 2
|
26 | ), 2)
|
27 | })
|
28 |
|
29 | test('chain multiple functions with multiple args', t => {
|
30 | t.is(pipeline(1, 3)(
|
31 | (x, y) => x + y,
|
32 | z => z * 2
|
33 | ), 8)
|
34 | })
|