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

produceAsync.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
40
41
42
43
44
45
46
47
import { delay } from './delay.js'import { produceAsync } from './produceAsync.js'
test('happy', async () => { const result = await produceAsync({ foo : async x => { await delay(100)
return `${ x }_ZEPPELIN` }, bar : x => x.length === 3, }, 'LED') const expected = { foo : 'LED_ZEPPELIN', bar : true, }
expect(result).toEqual(expected)})
test('when all rules are synchronous', async () => { const result = await produceAsync({ foo : x => `${ x }_ZEPPELIN`, bar : x => x.length === 3, }, 'LED') const expected = { foo : 'LED_ZEPPELIN', bar : true, }
expect(result).toEqual(expected)})
test('with error', async () => { const fn = produceAsync({ foo : async x => { await delay(100) throw new Error(`${ x }_ZEPPELIN`) }, bar : inputArgument => inputArgument === 5, })
await expect(fn('LED')).rejects.toThrow('LED_ZEPPELIN')})
rambda

Version Info

Tagged at
2 months ago