Skip to content

Commit 0bf9d0c

Browse files
Fix constructor-based checks for fake Date no longer pass after installing (#512)
1 parent 2eb02fe commit 0bf9d0c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/fake-timers-src.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ function withGlobal(_global) {
450450

451451
// ensures identity checks using the constructor prop still works
452452
// this should have no other functional effect
453-
this.constructor = Date;
453+
this.constructor = NativeDate;
454454
}
455455

456456
static [Symbol.hasInstance](instance) {

test/fake-timers-test.js

+3
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,9 @@ describe("FakeTimers", function () {
32033203
// issue #510
32043204
it("creates Date objects where the constructor prop matches the original", function () {
32053205
const realDate = new Date();
3206+
Date = NOOP; // eslint-disable-line no-global-assign
3207+
global.Date = NOOP;
3208+
32063209
const date = new this.clock.Date();
32073210

32083211
assert.equals(date.constructor.name, realDate.constructor.name);

0 commit comments

Comments
 (0)