Skip to content

Commit 1c5c8e5

Browse files
committed
test_runner: fix date as function implementation
Signed-off-by: Lucas Santos <[email protected]>
1 parent 5463dcb commit 1c5c8e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/internal/test_runner/mock/mock_timers.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,18 @@ class MockTimers {
110110
* @returns {MockDate} a mocked Date object
111111
*/
112112
function MockDate(year, month, date, hours, minutes, seconds, ms) {
113+
const mockTimersSource = MockDate[kMock];
114+
const nativeDate = mockTimersSource.#realDate;
113115
// As of the fake-timers implementation for Sinon
114116
// ref https://github.com/sinonjs/fake-timers/blob/a4c757f80840829e45e0852ea1b17d87a998388e/src/fake-timers-src.js#L456
115117
// This covers the Date constructor called as a function ref.
116118
// ECMA-262 Edition 5.1 section 15.9.2.
117119
// and ECMA-262 Edition 14 Section 21.4.2.1
118120
if (!(this instanceof MockDate)) {
119-
return new this.#realDate(this.#now).toString();
121+
return new nativeDate(mockTimersSource.#now).toString();
120122
}
121123

122-
const mockTimersSource = MockDate[kMock];
123-
const nativeDate = mockTimersSource.#realDate;
124+
124125

125126
// Cases where Date is called as a constructor
126127
switch (arguments.length) {

0 commit comments

Comments
 (0)