-
Notifications
You must be signed in to change notification settings - Fork 108
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: fake all supported timers by default #323
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
/** | ||
* Queues a function to be called during a browser's idle periods | ||
* @callback RequestIdleCallback | ||
* @param {function(IdleDeadline)} callback | ||
* @param {{timeout: number}} options - an options object | ||
* @returns {number} the id | ||
*/ | ||
|
@@ -51,13 +51,13 @@ | |
|
||
/** | ||
* @typedef RequestAnimationFrame | ||
* @property {function(number):void} requestAnimationFrame | ||
Check warning on line 54 in src/fake-timers-src.js GitHub Actions / lint
|
||
* @returns {number} - the id | ||
*/ | ||
|
||
/** | ||
* @typedef Performance | ||
* @property {function(): number} now | ||
Check warning on line 60 in src/fake-timers-src.js GitHub Actions / lint
|
||
*/ | ||
|
||
/* eslint-disable jsdoc/require-property-description */ | ||
|
@@ -348,7 +348,7 @@ | |
return timer && timer.callAt >= from && timer.callAt <= to; | ||
} | ||
|
||
/** | ||
Check warning on line 351 in src/fake-timers-src.js GitHub Actions / lint
|
||
* @param {Clock} clock | ||
* @param {Timer} job | ||
*/ | ||
|
@@ -428,7 +428,7 @@ | |
* @param {number} minute | ||
* @param {number} second | ||
* @param {number} ms | ||
* @returns void | ||
Check warning on line 431 in src/fake-timers-src.js GitHub Actions / lint
|
||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
constructor(year, month, date, hour, minute, second, ms) { | ||
|
@@ -460,7 +460,7 @@ | |
/** | ||
* A normal Class constructor cannot be called without `new`, but Date can, so we need | ||
* to wrap it in a Proxy in order to ensure this functionality of Date is kept intact | ||
* @type {ClockDate} | ||
*/ | ||
const ClockDateProxy = new Proxy(ClockDate, { | ||
// handler for [[Call]] invocations (i.e. not using `new`) | ||
|
@@ -656,7 +656,7 @@ | |
} | ||
|
||
/* eslint consistent-return: "off" */ | ||
/** | ||
Check warning on line 659 in src/fake-timers-src.js GitHub Actions / lint
|
||
* Timer comparitor | ||
* @param {Timer} a | ||
* @param {Timer} b | ||
|
@@ -787,7 +787,7 @@ | |
} | ||
} | ||
|
||
/** | ||
Check warning on line 790 in src/fake-timers-src.js GitHub Actions / lint
|
||
* Gets clear handler name for a given timer type | ||
* @param {string} ttype | ||
*/ | ||
|
@@ -798,7 +798,7 @@ | |
return `clear${ttype}`; | ||
} | ||
|
||
/** | ||
Check warning on line 801 in src/fake-timers-src.js GitHub Actions / lint
|
||
* Gets schedule handler name for a given timer type | ||
* @param {string} ttype | ||
*/ | ||
|
@@ -809,7 +809,7 @@ | |
return `set${ttype}`; | ||
} | ||
|
||
/** | ||
Check warning on line 812 in src/fake-timers-src.js GitHub Actions / lint
|
||
* Creates an anonymous function to warn only once | ||
*/ | ||
function createWarnOnce() { | ||
|
@@ -1776,10 +1776,7 @@ | |
clock.methods = config.toFake || []; | ||
|
||
if (clock.methods.length === 0) { | ||
// do not fake nextTick by default - GitHub#126 | ||
clock.methods = Object.keys(timers).filter(function (key) { | ||
return key !== "nextTick" && key !== "queueMicrotask"; | ||
}); | ||
clock.methods = Object.keys(timers); | ||
} | ||
|
||
if (config.shouldAdvanceTime === true) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems docs were lying 🤷
queueMicrotask
was also not mocked by default