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

waitFor.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
54
55
56
57
58
59
60
61
import { delay } from './delay.js'import { waitFor } from './waitFor.js'
const howLong = 1000
test('true', async () => { let counter = 0 const condition = x => { counter++
return counter > x }
const result = await waitFor(condition, howLong)(6) expect(result).toBeTrue()})
test('false', async () => { let counter = 0 const condition = x => { counter++
return counter > x }
const result = await waitFor(condition, howLong)(12) expect(result).toBeFalse()})
test('async condition | true', async () => { let counter = 0 const condition = async x => { counter++ await delay(10)
return counter > x }
const result = await waitFor(condition, howLong)(6) expect(result).toBeTrue()})
test('async condition | false', async () => { let counter = 0 const condition = async x => { counter++ await delay(10)
return counter > x }
const result = await waitFor(condition, howLong)(12) expect(result).toBeFalse()})
test('throws when fn is not function', () => { const fn = 'foo'
expect(() => waitFor(fn, howLong)()).toThrowErrorMatchingInlineSnapshot('"R.waitFor"')})
rambda

Version Info

Tagged at
2 months ago