-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
/
fakeTimers.test.ts
48 lines (40 loc) · 1.38 KB
/
fakeTimers.test.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
47
48
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import runJest from '../runJest';
describe('enableGlobally', () => {
test('enables fake timers from Jest config', () => {
const result = runJest('fake-timers/enable-globally');
expect(result.exitCode).toBe(0);
});
});
describe('useFakeTimers', () => {
test('enables fake timers from Jest object', () => {
const result = runJest('fake-timers/use-fake-timers');
expect(result.exitCode).toBe(0);
});
});
describe('requestAnimationFrame', () => {
test('fakes requestAnimationFrame', () => {
const result = runJest('fake-timers/request-animation-frame');
expect(result.stderr).toMatch('requestAnimationFrame test');
expect(result.exitCode).toBe(0);
});
});
describe('setImmediate', () => {
test('fakes setImmediate', () => {
const result = runJest('fake-timers/set-immediate');
expect(result.stderr).toMatch('setImmediate test');
expect(result.exitCode).toBe(0);
});
});
describe('useRealTimers', () => {
test('restores timers to the native implementation', () => {
const result = runJest('fake-timers/use-real-timers');
expect(result.stdout).toMatch('API is not mocked with fake timers.');
expect(result.exitCode).toBe(0);
});
});