Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of NaN/Infinity in mock timer delay, #5960 #5966

Merged
merged 6 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
([#5914](https://github.com/facebook/jest/pull/5914))
* `[jest-regex-util]` Fix handling regex symbols in tests path on Windows
([#5941](https://github.com/facebook/jest/pull/5941))
* `[jest-util]` Fix handling for NaN as timer delay
([#5966](https://github.com/facebook/jest/pull/5966))

### Chore & Maintenance

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-util/src/__tests__/fake_timers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ describe('FakeTimers', () => {
const mock4 = jest.fn(() => runOrder.push('mock4'));

global.setTimeout(mock1, 100);
global.setTimeout(mock2, 0);
global.setTimeout(mock2, NaN);
global.setTimeout(mock3, 0);
const intervalHandler = global.setInterval(() => {
mock4();
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-util/src/fake_timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ export default class FakeTimers<TimerRef> {
return null;
}

if (delay == null) {
if (delay == null || isNaN(delay)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tnx, updated in 6d70f85

delay = 0;
}

Expand Down