FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
roadmap/spec/javascripts/debounceSpec.js at api-patch · DMPRoadmap/roadmap · GitHub
DMPRoadmap
roadmap
Repository navigation
Code
Issues
300
(300)
Pull requests
49
(49)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
roadmap
/
spec
/
javascripts
/
debounceSpec.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (50 loc) · 1.95 KB
Breadcrumbs
roadmap
/
spec
/
javascripts
/
debounceSpec.js
Copy path
File metadata and controls
68 lines (50 loc) · 1.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
65
66
67
68
import
debounce
from
'../../app/javascript/src/utils/debounce'
;
describe
(
'debounce test suite'
,
(
)
=>
{
let
functionToDebounce
;
beforeEach
(
(
)
=>
{
functionToDebounce
=
jasmine
.
createSpy
(
'My function to debounce'
)
;
jasmine
.
clock
(
)
.
install
(
)
;
}
)
;
afterEach
(
(
)
=>
{
jasmine
.
clock
(
)
.
uninstall
(
)
;
}
)
;
it
(
'functionToDebounce gets called after the time specified'
,
(
)
=>
{
const
debounced
=
debounce
(
functionToDebounce
,
1000
)
;
debounced
(
'foo'
,
'bar'
)
;
expect
(
functionToDebounce
)
.
not
.
toHaveBeenCalled
(
)
;
jasmine
.
clock
(
)
.
tick
(
1001
)
;
expect
(
functionToDebounce
)
.
toHaveBeenCalled
(
)
;
expect
(
functionToDebounce
.
calls
.
first
(
)
.
args
[
0
]
)
.
toBe
(
'foo'
)
;
expect
(
functionToDebounce
.
calls
.
first
(
)
.
args
[
1
]
)
.
toBe
(
'bar'
)
;
}
)
;
it
(
'functionToDebounce gets cancelled before time elapses'
,
(
)
=>
{
const
debounced
=
debounce
(
functionToDebounce
,
1000
)
;
debounced
(
'foo'
,
'bar'
)
;
jasmine
.
clock
(
)
.
tick
(
999
)
;
debounced
.
cancel
(
)
;
jasmine
.
clock
(
)
.
tick
(
2
)
;
expect
(
functionToDebounce
)
.
not
.
toHaveBeenCalled
(
)
;
}
)
;
it
(
'functionToDebounce gets called once after the time specified'
,
(
)
=>
{
const
debounced
=
debounce
(
functionToDebounce
,
1000
)
;
debounced
(
'foo'
,
'bar'
)
;
jasmine
.
clock
(
)
.
tick
(
999
)
;
debounced
(
'foo'
,
'bar'
)
;
jasmine
.
clock
(
)
.
tick
(
999
)
;
debounced
(
'foo'
,
'bar'
)
;
jasmine
.
clock
(
)
.
tick
(
1001
)
;
expect
(
functionToDebounce
.
calls
.
count
(
)
)
.
toBe
(
1
)
;
}
)
;
it
(
'functionToDebounce gets called once after the time specified with args of last invocation'
,
(
)
=>
{
const
debounced
=
debounce
(
functionToDebounce
,
1000
)
;
debounced
(
'foo'
,
'bar'
)
;
jasmine
.
clock
(
)
.
tick
(
999
)
;
debounced
(
'foo2'
,
'bar2'
)
;
jasmine
.
clock
(
)
.
tick
(
999
)
;
debounced
(
'foo3'
,
'bar3'
)
;
jasmine
.
clock
(
)
.
tick
(
1001
)
;
expect
(
functionToDebounce
.
calls
.
count
(
)
)
.
toBe
(
1
)
;
expect
(
functionToDebounce
.
calls
.
first
(
)
.
args
[
0
]
)
.
toBe
(
'foo3'
)
;
expect
(
functionToDebounce
.
calls
.
first
(
)
.
args
[
1
]
)
.
toBe
(
'bar3'
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL