-
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 constructor-based checks for fake Date no longer pass after installing #512
Merged
fatso83
merged 1 commit into
sinonjs:main
from
alexanderweiss:fix-constructor-checks-after-installing
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -22,10 +22,10 @@ | |
*/ | ||
|
||
/** | ||
* 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 | ||
*/ | ||
|
@@ -52,13 +52,13 @@ | |
|
||
/** | ||
* @typedef RequestAnimationFrame | ||
* @property {function(number):void} requestAnimationFrame | ||
Check warning on line 55 in src/fake-timers-src.js GitHub Actions / lint
|
||
* @returns {number} - the id | ||
*/ | ||
|
||
/** | ||
* @typedef Performance | ||
* @property {function(): number} now | ||
Check warning on line 61 in src/fake-timers-src.js GitHub Actions / lint
|
||
*/ | ||
|
||
/* eslint-disable jsdoc/require-property-description */ | ||
|
@@ -105,7 +105,7 @@ | |
/* eslint-enable jsdoc/require-property-description */ | ||
|
||
/** | ||
* Configuration object for the `install` method. | ||
* | ||
* @typedef {object} Config | ||
* @property {number|Date} [now] a number (in milliseconds) or a Date object (default epoch) | ||
|
@@ -119,7 +119,7 @@ | |
|
||
/* eslint-disable jsdoc/require-property-description */ | ||
/** | ||
* The internal structure to describe a scheduled fake timer | ||
* | ||
* @typedef {object} Timer | ||
* @property {Function} func | ||
|
@@ -133,7 +133,7 @@ | |
*/ | ||
|
||
/** | ||
* A Node timer | ||
* | ||
* @typedef {object} NodeImmediate | ||
* @property {function(): boolean} hasRef | ||
|
@@ -145,7 +145,7 @@ | |
/* eslint-disable complexity */ | ||
|
||
/** | ||
* Mocks available features in the specified global namespace. | ||
* | ||
* @param {*} _global Namespace to mock (e.g. `window`) | ||
* @returns {FakeTimers} | ||
|
@@ -275,7 +275,7 @@ | |
/** | ||
* Parse strings like "01:10:00" (meaning 1 hour, 10 minutes, 0 seconds) into | ||
* number of milliseconds. This is used to support human-readable strings passed | ||
* to clock.tick() | ||
* | ||
* @param {string} str | ||
* @returns {number} | ||
|
@@ -311,7 +311,7 @@ | |
} | ||
|
||
/** | ||
* Get the decimal part of the millisecond value as nanoseconds | ||
* | ||
* @param {number} msFloat the number of milliseconds | ||
* @returns {number} an integer number of nanoseconds in the range [0,1e6) | ||
|
@@ -450,7 +450,7 @@ | |
|
||
// ensures identity checks using the constructor prop still works | ||
// this should have no other functional effect | ||
this.constructor = Date; | ||
this.constructor = NativeDate; | ||
} | ||
|
||
static [Symbol.hasInstance](instance) { | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Good catch, this was naively working in the tests due to it being the same when not overwritten. This is what I meant to have written 😄
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.
👍 I was initially very surprised, but makes sense now — since this happens every time a fake Date is created.
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.
patch version out shortly