Skip to content

Commit 0d5b88a

Browse files
test: test order
1 parent 23a3524 commit 0d5b88a

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

src/test/utils.spec.js

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -86,54 +86,6 @@ describe('compute positions', () => {
8686
})
8787
})
8888

89-
describe('debounce', () => {
90-
jest.useFakeTimers()
91-
92-
const func = jest.fn()
93-
94-
test('execute just once', () => {
95-
const debouncedFunc = debounce(func, 1000)
96-
for (let i = 0; i < 100; i += 1) {
97-
debouncedFunc()
98-
}
99-
100-
expect(func).not.toHaveBeenCalled()
101-
102-
jest.runAllTimers()
103-
104-
expect(func).toBeCalledTimes(1)
105-
})
106-
107-
test('execute immediately just once', () => {
108-
const debouncedFunc = debounce(func, 1000, true)
109-
110-
debouncedFunc()
111-
expect(func).toBeCalledTimes(1)
112-
113-
for (let i = 0; i < 100; i += 1) {
114-
debouncedFunc()
115-
}
116-
117-
jest.runAllTimers()
118-
119-
expect(func).toHaveBeenCalledTimes(1)
120-
})
121-
122-
test('does not execute after cancel', () => {
123-
const debouncedFunc = debounce(func, 1000)
124-
125-
debouncedFunc()
126-
127-
expect(func).not.toHaveBeenCalled()
128-
129-
debouncedFunc.cancel()
130-
131-
jest.runAllTimers()
132-
133-
expect(func).not.toHaveBeenCalled()
134-
})
135-
})
136-
13789
describe('css supports', () => {
13890
let windowSpy
13991

@@ -183,3 +135,51 @@ describe('css time to ms', () => {
183135
expect(cssTimeToMs('1000')).toBe(0)
184136
})
185137
})
138+
139+
describe('debounce', () => {
140+
jest.useFakeTimers()
141+
142+
const func = jest.fn()
143+
144+
test('execute just once', () => {
145+
const debouncedFunc = debounce(func, 1000)
146+
for (let i = 0; i < 100; i += 1) {
147+
debouncedFunc()
148+
}
149+
150+
expect(func).not.toHaveBeenCalled()
151+
152+
jest.runAllTimers()
153+
154+
expect(func).toBeCalledTimes(1)
155+
})
156+
157+
test('execute immediately just once', () => {
158+
const debouncedFunc = debounce(func, 1000, true)
159+
160+
debouncedFunc()
161+
expect(func).toBeCalledTimes(1)
162+
163+
for (let i = 0; i < 100; i += 1) {
164+
debouncedFunc()
165+
}
166+
167+
jest.runAllTimers()
168+
169+
expect(func).toHaveBeenCalledTimes(1)
170+
})
171+
172+
test('does not execute after cancel', () => {
173+
const debouncedFunc = debounce(func, 1000)
174+
175+
debouncedFunc()
176+
177+
expect(func).not.toHaveBeenCalled()
178+
179+
debouncedFunc.cancel()
180+
181+
jest.runAllTimers()
182+
183+
expect(func).not.toHaveBeenCalled()
184+
})
185+
})

0 commit comments

Comments
 (0)