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

mapParallelAsync.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
48
49
50
51
52
53
import { willFailAssertion } from './_internals/testUtils.js'import { composeAsync } from './composeAsync.js'import { delay } from './delay.js'import { map } from './map.js'import { mapParallelAsync } from './mapParallelAsync.js'
test('happy', async () => { const fn = async x => { await delay(100)
return x + 10 } const result = await mapParallelAsync(fn, [ 1, 2, 3 ]) expect(result).toEqual([ 11, 12, 13 ])})
test('composeAsync', async () => { const result = await composeAsync( mapParallelAsync(async x => { await delay(100)
return x + 1 }), mapParallelAsync(async x => { await delay(100)
return x + 10 }), map(x => x * 10) )([ 1, 2, 3 ]) expect(result).toEqual([ 21, 31, 41 ])})
test('error', async () => { try { const fn = async () => { JSON.parse('{:') } await mapParallelAsync(fn, [ 1, 2, 3 ]) willFailAssertion() } catch (err){ expect(err.message).toBeTruthy() }})
test('pass index as second argument', async () => { await mapParallelAsync((x, i) => { expect(x % 10).toBe(0) expect(typeof i).toBe('number') }, [ 10, 20, 30 ])})
rambda

Version Info

Tagged at
2 months ago