UNPKG

931 BJavaScriptView Raw
1const test = require('./config').test
2const { map } = require('..')
3
4test('map over single function', t => {
5 const cpsFun = cb => cb(42)
6 map(x => x*2)(cpsFun)(t.cis(84))
7})
8
9test('map over single function with several arguments', t => {
10 const cpsFun = cb => cb(42, 24)
11 map((a, b) => a - b)(cpsFun)(t.cis(18))
12})
13
14test('map over single function with no arguments', t => {
15 const cpsFun = cb => cb()
16 map(() => 30)(cpsFun)(t.cis(30))
17})
18
19test('further callbacks are unaffected when map over single function', t => {
20 const cpsFun = (cb1, cb2) => {cb1(42); cb2(23)}
21 map(x => x*2)(cpsFun)(x=>x, t.cis(23))
22})
23
24test('map over multiple functions', t => {
25 const cpsFun = (cb1, cb2) => {cb1(42); cb2(23)}
26 map(x => x/2, x => x*2)(cpsFun)(t.cis(21), t.cis(46))
27})
28
29test('map over more functions than callbacks, the extra functions are ignored', t => {
30 const cpsFun = cb => cb(42)
31 map(x => x*2, x => x+10)(cpsFun)(t.cis(84))
32})