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 constructor-based checks for fake Date no longer pass after installing #512

Merged

Conversation

alexanderweiss
Copy link
Contributor

Purpose (TL;DR) - mandatory

Fixes #511 (fix for #510) no longer working after the clock had been installed and global Date assigned to the fake.

Background (Problem in detail) - optional

Once ClockDateProxy was installed to global Date (to my surprise) the constructor reference on it was 'updated' to point to ClockDateProxy.

Thanks again for the help!

@@ -450,7 +450,7 @@ function withGlobal(_global) {

// ensures identity checks using the constructor prop still works
// this should have no other functional effect
this.constructor = Date;
this.constructor = NativeDate;
Copy link
Contributor

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 😄

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

patch version out shortly

@fatso83 fatso83 merged commit 0bf9d0c into sinonjs:main Oct 22, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants