-
Notifications
You must be signed in to change notification settings - Fork 86
/
waitFor-spec.ts
46 lines (41 loc) · 1.09 KB
/
waitFor-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
import {delay, waitFor} from 'rambda'
describe('R.waitFor', () => {
it('async condition with input', async() => {
let counter = 0
const condition = async(x: number) => {
await delay(10)
counter += x
return counter > 2
}
const result = await waitFor(condition, 1000, 6)(6)
result // $ExpectType boolean
})
it('async condition without input', async() => {
let counter = 0
const condition = async() => {
await delay(10)
counter++
return counter > 2
}
const result = await waitFor(condition, 1000, 6)()
result // $ExpectType boolean
})
it('sync condition with input', async() => {
let counter = 0
const condition = (x: number) => {
counter += x
return counter > 2
}
const result = await waitFor(condition, 1000, 6)(6)
result // $ExpectType boolean
})
it('sync condition without input', async() => {
let counter = 0
const condition = () => {
counter++
return counter > 2
}
const result = await waitFor(condition, 1000, 6)()
result // $ExpectType boolean
})
})