UNPKG

607 BJavaScriptView Raw
1const test = require('./config').test
2const { pipeline } = require('..')
3
4test('pass single argument to function', t => {
5 t.is(pipeline(1)(x => x + 2), 3)
6})
7
8test('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
17test('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
29test('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})