-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement node Timer api when running in node environment. (#4622)
* Implement node Timer api when running in node environment. * CR feedback, use toBeUndefined. * CR feedback, turn Faketimer constructor args into an object.. * tweak Faketimer tests, assert if ref/unref are actually functions.
- Loading branch information
Showing
6 changed files
with
178 additions
and
55 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
packages/jest-environment-jsdom/src/__tests__/jsdom_environment.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. 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. | ||
*/ | ||
'use strict'; | ||
|
||
const JSDomEnvironment = require.requireActual('../'); | ||
|
||
describe('JSDomEnvironment', () => { | ||
it('should configure setTimeout/setInterval to use the browser api', () => { | ||
const env1 = new JSDomEnvironment({}); | ||
|
||
env1.fakeTimers.useFakeTimers(); | ||
|
||
const timer1 = env1.global.setTimeout(() => {}, 0); | ||
const timer2 = env1.global.setInterval(() => {}, 0); | ||
|
||
[timer1, timer2].forEach(timer => { | ||
expect(typeof timer).toBe('number'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.