-
Notifications
You must be signed in to change notification settings - Fork 16
/
jasmine_timers.javascript.txt
38 lines (23 loc) · 2.48 KB
/
jasmine_timers.javascript.txt
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
JASMINE_TIMERS
ALTERNATIVES ==> #See @sinonjs/fake-timers
VERSION ==> #Part of Jasmine (see its doc)
#Mocks setTimeout|Interval()
/=+===============================+=\
/ : : \
)==: CORE :==(
\ :_______________________________: /
\=+===============================+=/
JASMINE.clock()->CLOCK #Always returns same singleton
CLOCK.install() #Mock setTimeout|Interval()
CLOCK.uninstall() #
CLOCK.withMock(FUNC) #Calls CLOCK.install|uninstall() before FUNC and after it (in a "finally")
CLOCK.mockDate([DATE]) #Make new Date() follow CLOCK instead of time
#DATE is time when CLOCK is starting (def: now).
/=+===============================+=\
/ : : \
)==: ADVANCE :==(
\ :_______________________________: /
\=+===============================+=/
CLOCK.tick(NUM) #Advance time (in ms)