forked from eighttrigrams/tsfun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
a_filter.spec.ts
64 lines (35 loc) · 1.06 KB
/
a_filter.spec.ts
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
54
55
56
57
58
59
60
61
62
63
64
import {aFilter} from '../../src/async'
/**
* tsfun | aFilter
*
* asynchronous function for filtering items from Collection by a given predicate
*/
describe('aFilter', () => {
const delayedSmaller4 =
_ => new Promise<any>(resolve => setTimeout(() => resolve(_ < 4), 50))
it('array, multiple argument lists', async done => {
expect(
await (await aFilter(delayedSmaller4))([2, 4, 3]))
.toEqual([2, 3])
done()
})
it('array, multiple argument list', async done => {
expect(
await aFilter(delayedSmaller4, [2, 4, 3])
).toEqual([2, 3])
done()
})
it('array, multiple argument list, different order', async done => {
expect(
await aFilter([2, 4, 3], delayedSmaller4)
).toEqual([2, 3])
done()
})
it('object', async done => {
expect(
await aFilter(delayedSmaller4, {a: 2, b: 4, c: 3}))
.toEqual({a: 2, c: 3})
done()
})
// typing - see comments in asyncMap typing test
})