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

2024-11-11, Version 23.2.0 (Current) #55741

Merged
merged 93 commits into from
Nov 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
0ea74f3
test,crypto: make crypto tests work with BoringSSL
codebytere Oct 24, 2024
69dd1e1
module: add module.stripTypeScriptTypes
marco-ippolito Oct 24, 2024
9dcca54
doc: add jazelly to collaborators
jazelly Oct 25, 2024
2d19614
test: increase test coverage for `http.OutgoingMessage.appendHeader()`
juanarbol Oct 25, 2024
adda37f
module: add `findPackageJSON` util
JakobJingleheimer Oct 25, 2024
88c7f5b
sqlite: refactor open options
tniessen Oct 26, 2024
53a7d8e
test,crypto: update WebCryptoAPI WPT
panva Oct 26, 2024
1b82013
deps: update undici to 6.20.1
nodejs-github-bot Oct 26, 2024
71cc20a
test: avoid `apply()` calls with large amount of elements
LiviaMedeiros Oct 26, 2024
f00ad27
doc: add esm examples to node:string_decoder
mfdebian Oct 26, 2024
649d767
test: increase coverage of `pathToFileURL`
aduh95 Oct 27, 2024
bb78904
build: fix GN build for sqlite and nghttp2
codebytere Oct 27, 2024
f77bf65
doc: add suggested tsconfig for type stripping
marco-ippolito Oct 27, 2024
fa61dce
doc: move typescript support to active development
marco-ippolito Oct 27, 2024
f628fc4
fs: make `dirent.path` writable
aduh95 Oct 28, 2024
f8df27a
build: fix GN arg used in generate_config_gypi.py
codebytere Oct 28, 2024
a9e08cf
module: allow ESM that failed to be required to be re-imported
joyeecheung Oct 28, 2024
f92f20b
http: don't emit error after destroy
ronag Oct 28, 2024
efa142c
src: migrate `String::Value` to `String::ValueView`
Oct 29, 2024
50552fd
deps: update acorn to 8.13.0
nodejs-github-bot Oct 29, 2024
3a1d490
deps: update nghttp2 to 1.64.0
nodejs-github-bot Oct 29, 2024
016baae
src: do not run IsWindowsBatchFile on non-windows
anonrig Oct 29, 2024
b3971bb
module: trim off internal stack frames for require(esm) warnings
joyeecheung Oct 18, 2024
d3be3da
module: fix error thrown from require(esm) hitting TLA repeatedly
joyeecheung Oct 29, 2024
6aa797d
test: remove unneeded listeners
lpinca Oct 29, 2024
4887214
build: fix building with system icu 76
cho-m Oct 29, 2024
815e252
test: split up test-runner-mock-timers test
badkeyy Oct 30, 2024
f355054
doc: capitalize "MIT License"
Oct 30, 2024
0906004
dns: stop using deprecated `ares_query`
Oct 30, 2024
4676184
src: use NewFromUtf8Literal in NODE_DEFINE_CONSTANT
ckerr Oct 31, 2024
2ec4ae7
sqlite: add readOnly option
tniessen Oct 31, 2024
25b1422
http: add diagnostic channel `http.client.request.created`
marco-ippolito Oct 31, 2024
56c46ab
module: unify TypeScript and .mjs handling in CommonJS
joyeecheung Oct 31, 2024
137aa5c
http2: fix client async storage persistence
orgads Oct 31, 2024
2b99285
url: refactor `pathToFileURL` to native
aduh95 Oct 31, 2024
4c34891
src: fix dns crash when failed to create NodeAresTask
theanarkh Nov 1, 2024
5de2567
doc: improve c++ embedder API doc
gireeshpunathil Nov 1, 2024
3477492
deps: update amaro to 0.2.0
nodejs-github-bot Nov 1, 2024
3234dc6
test_runner: pass `options` directly to `TestCoverage`
Nov 1, 2024
cfa4d96
src,lib: optimize nodeTiming.uvMetricsInfo
RafaelGSS Oct 30, 2024
34483a2
benchmark: add nodeTiming.uvmetricsinfo bench
RafaelGSS Oct 31, 2024
b1ca7ab
meta: show PR/issue title on review-wanted
Nov 1, 2024
7ab1f46
build: stop pre-compiling `lint-md`
Nov 1, 2024
b79e483
build: use rclone instead of aws CLI
targos Nov 2, 2024
d26dedf
src: refactor ECDHBitsJob signature
panva Nov 2, 2024
9743fa4
doc: remove mention of ECDH-ES in crypto.diffieHellman
panva Nov 2, 2024
6662752
doc: add a note on console stream behavior
gireeshpunathil Nov 2, 2024
8d0526f
http: add diagnostic channel `http.server.response.created`
marco-ippolito Nov 2, 2024
7ce7eab
tools: lint README lists more strictly
aduh95 Nov 2, 2024
0302efe
src: move more key related stuff to ncrypto
jasnell Nov 2, 2024
6ab59c8
os: improve path check with direct index access
mertcanaltin Nov 2, 2024
7af76ef
assert: fix the string length check for printing the simple diff
puskin94 Nov 2, 2024
869e88c
module: simplify `findPackageJSON` implementation
aduh95 Nov 2, 2024
d0ea981
meta: make review-wanted message minimal
Nov 2, 2024
dd9b683
Revert "fs,win: fix bug in paths with trailing slashes"
rvagg Nov 2, 2024
c2fcda4
typings: fix `ModulesBinding` types
aduh95 Nov 2, 2024
b8ca9d8
doc: add write flag when open file as the demo code's intention
robberfree Nov 2, 2024
505ff19
doc: broken `PerformanceObserver` code sample
domharrington Nov 2, 2024
cba05cd
tools: run daily WPT.fyi report on all supported releases
panva Nov 2, 2024
d0b2d6b
tools: compact jq output in daily-wpt-fyi.yml action
panva Nov 2, 2024
dfb764c
deps: update sqlite to 3.47.0
nodejs-github-bot Nov 2, 2024
9b351b0
crypto: fix `RSA_PKCS1_PADDING` error message
richardlau Nov 3, 2024
19b1edf
module: simplify --inspect-brk handling
joyeecheung Nov 3, 2024
d79c8bf
meta: bump github/codeql-action from 3.26.10 to 3.27.0
dependabot[bot] Nov 3, 2024
5c2e472
meta: bump actions/checkout from 4.2.0 to 4.2.2
dependabot[bot] Nov 3, 2024
9042e9a
meta: bump actions/cache from 4.0.2 to 4.1.2
dependabot[bot] Nov 3, 2024
42e6c47
meta: bump actions/upload-artifact from 4.4.0 to 4.4.3
dependabot[bot] Nov 3, 2024
2ae8d3b
meta: bump rtCamp/action-slack-notify from 2.3.0 to 2.3.2
dependabot[bot] Nov 3, 2024
21e3b7b
meta: bump actions/setup-node from 4.0.4 to 4.1.0
dependabot[bot] Nov 3, 2024
7bfd295
meta: bump actions/setup-python from 5.2.0 to 5.3.0
dependabot[bot] Nov 3, 2024
8fc962f
tools: fix root certificate updater
richardlau Nov 1, 2024
535f1b0
crypto: update root certificates to NSS 3.104
richardlau Nov 1, 2024
7aa250a
sqlite: improve error handling using MaybeLocal
tniessen Nov 4, 2024
961cbc9
tools: use `util.parseArgs` in `lint-md`
Nov 4, 2024
4b192da
deps: update acorn to 8.14.0
nodejs-github-bot Nov 5, 2024
aebf676
test,crypto: update WebCryptoAPI WPT
panva Nov 5, 2024
bf552fa
lib: prefer number to string in webidl `type` function
jazelly Oct 24, 2024
d1965f9
lib: implement webidl dictionary converter and use it in structuredClone
jazelly Oct 20, 2024
bffbaa1
doc: update `--max-semi-space-size` description
joebowbeer Nov 5, 2024
038ac01
path,win: fix bug in resolve and normalize
huseyinacacak-janea Nov 5, 2024
15028dd
tools: update ESLint to 9.14.0
dependabot[bot] Nov 5, 2024
7d93c0c
test: refactor some esm tests
aduh95 Nov 5, 2024
9dbb255
assert: fix `deepStrictEqual` on errors when `cause` is not undefined
geeksilva97 Nov 5, 2024
10b68ed
test: ignore unrelated events in FW watch tests
Ceres6 Nov 6, 2024
7853462
src: provide workaround for container-overflow
lemire Nov 6, 2024
20cb52d
doc: clarity to available addon options
preveen-stack Nov 6, 2024
4129bc7
util: do not catch on circular `@@toStringTag` errors
Nov 6, 2024
19da4de
test: update `performance-timeline` wpt
avivkeller Sep 30, 2024
ee12431
doc: consistent use of word child process
gireeshpunathil Nov 6, 2024
89aa838
doc: add esm example in `path.md`
Nov 8, 2024
cbe09b5
doc: add path aliases typescript doc
Ceres6 Nov 8, 2024
355af0f
doc: consolidate history table of `CustomEvent`
geeksilva97 Nov 9, 2024
a83fbdb
2024-11-11, Version 23.2.0 (Current)
aduh95 Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: split up test-runner-mock-timers test
PR-URL: #55506
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Claudio Wunder <cwunder@gnome.org>
badkeyy authored and RafaelGSS committed Nov 1, 2024
commit 815e2524a63ac3cf87553526fc08bc700855da3e
120 changes: 120 additions & 0 deletions test/parallel/test-runner-mock-timers-date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
'use strict';
process.env.NODE_TEST_KNOWN_GLOBALS = 0;
require('../common');

const assert = require('node:assert');
const { it, describe } = require('node:test');

describe('Mock Timers Date Test Suite', () => {
it('should return the initial UNIX epoch if not specified', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
const date = new Date();
assert.strictEqual(date.getTime(), 0);
assert.strictEqual(Date.now(), 0);
});

it('should throw an error if setTime is called without enabling timers', (t) => {
assert.throws(
() => {
t.mock.timers.setTime(100);
},
{ code: 'ERR_INVALID_STATE' }
);
});

it('should throw an error if epoch passed to enable is not valid', (t) => {
assert.throws(
() => {
t.mock.timers.enable({ now: -1 });
},
{ code: 'ERR_INVALID_ARG_VALUE' }
);

assert.throws(
() => {
t.mock.timers.enable({ now: 'string' });
},
{ code: 'ERR_INVALID_ARG_TYPE' }
);

assert.throws(
() => {
t.mock.timers.enable({ now: NaN });
},
{ code: 'ERR_INVALID_ARG_VALUE' }
);
});

it('should replace the original Date with the mocked one', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
assert.ok(Date.isMock);
});

it('should return the ticked time when calling Date.now after tick', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
const time = 100;
t.mock.timers.tick(time);
assert.strictEqual(Date.now(), time);
});

it('should return the Date as string when calling it as a function', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
const returned = Date();
// Matches the format: 'Mon Jan 01 1970 00:00:00'
// We don't care about the date, just the format
assert.ok(/\w{3}\s\w{3}\s\d{1,2}\s\d{2,4}\s\d{1,2}:\d{2}:\d{2}/.test(returned));
});

it('should return the date with different argument calls', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
assert.strictEqual(new Date(0).getTime(), 0);
assert.strictEqual(new Date(100).getTime(), 100);
assert.strictEqual(new Date('1970-01-01T00:00:00.000Z').getTime(), 0);
assert.strictEqual(new Date(1970, 0).getFullYear(), 1970);
assert.strictEqual(new Date(1970, 0).getMonth(), 0);
assert.strictEqual(new Date(1970, 0, 1).getDate(), 1);
assert.strictEqual(new Date(1970, 0, 1, 11).getHours(), 11);
assert.strictEqual(new Date(1970, 0, 1, 11, 10).getMinutes(), 10);
assert.strictEqual(new Date(1970, 0, 1, 11, 10, 45).getSeconds(), 45);
assert.strictEqual(new Date(1970, 0, 1, 11, 10, 45, 898).getMilliseconds(), 898);
assert.strictEqual(new Date(1970, 0, 1, 11, 10, 45, 898).toDateString(), 'Thu Jan 01 1970');
});

it('should return native code when calling Date.toString', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
assert.strictEqual(Date.toString(), 'function Date() { [native code] }');
});

it('should start with a custom epoch if the second argument is specified', (t) => {
t.mock.timers.enable({ apis: ['Date'], now: 100 });
const date1 = new Date();
assert.strictEqual(date1.getTime(), 100);

t.mock.timers.reset();
t.mock.timers.enable({ apis: ['Date'], now: new Date(200) });
const date2 = new Date();
assert.strictEqual(date2.getTime(), 200);
});

it('should replace epoch if setTime is lesser than now and not tick', (t) => {
t.mock.timers.enable();
const fn = t.mock.fn();
const id = setTimeout(fn, 1000);
t.mock.timers.setTime(800);
assert.strictEqual(Date.now(), 800);
t.mock.timers.setTime(500);
assert.strictEqual(Date.now(), 500);
assert.strictEqual(fn.mock.callCount(), 0);
clearTimeout(id);
});

it('should not tick time when setTime is called', (t) => {
t.mock.timers.enable();
const fn = t.mock.fn();
const id = setTimeout(fn, 1000);
t.mock.timers.setTime(1200);
assert.strictEqual(Date.now(), 1200);
assert.strictEqual(fn.mock.callCount(), 0);
clearTimeout(id);
});
});
124 changes: 124 additions & 0 deletions test/parallel/test-runner-mock-timers-scheduler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
'use strict';
process.env.NODE_TEST_KNOWN_GLOBALS = 0;
const common = require('../common');

const assert = require('node:assert');
const { it, describe } = require('node:test');
const nodeTimersPromises = require('node:timers/promises');

describe('Mock Timers Scheduler Test Suite', () => {
it('should advance in time and trigger timers when calling the .tick function', (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });

const now = Date.now();
const durationAtMost = 100;

const p = nodeTimersPromises.scheduler.wait(4000);
t.mock.timers.tick(4000);

return p.then(common.mustCall((result) => {
assert.strictEqual(result, undefined);
assert.ok(
Date.now() - now < durationAtMost,
`time should be advanced less than the ${durationAtMost}ms`
);
}));
});

it('should advance in time and trigger timers when calling the .tick function multiple times', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });

const fn = t.mock.fn();

nodeTimersPromises.scheduler.wait(9999).then(fn);

t.mock.timers.tick(8999);
assert.strictEqual(fn.mock.callCount(), 0);
t.mock.timers.tick(500);

await nodeTimersPromises.setImmediate();

assert.strictEqual(fn.mock.callCount(), 0);
t.mock.timers.tick(500);

await nodeTimersPromises.setImmediate();
assert.strictEqual(fn.mock.callCount(), 1);
});

it('should work with the same params as the original timers/promises/scheduler.wait', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

t.mock.timers.tick(1000);
t.mock.timers.tick(500);
t.mock.timers.tick(500);
t.mock.timers.tick(500);

const result = await p;
assert.strictEqual(result, undefined);
});

it('should abort operation if timers/promises/scheduler.wait received an aborted signal', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

t.mock.timers.tick(1000);
controller.abort();
t.mock.timers.tick(500);
t.mock.timers.tick(500);
t.mock.timers.tick(500);

await assert.rejects(() => p, {
name: 'AbortError',
});
});
it('should abort operation even if the .tick was not called', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

controller.abort();

await assert.rejects(() => p, {
name: 'AbortError',
});
});

it('should abort operation when .abort is called before calling setInterval', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
controller.abort();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

await assert.rejects(() => p, {
name: 'AbortError',
});
});

it('should reject given an an invalid signal instance', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: {},
});

await assert.rejects(() => p, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_TYPE',
});
});
});
240 changes: 4 additions & 236 deletions test/parallel/test-runner-mock-timers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';
process.env.NODE_TEST_KNOWN_GLOBALS = 0;
const common = require('../common');
@@ -6,6 +7,7 @@ const assert = require('node:assert');
const { it, mock, describe } = require('node:test');
const nodeTimers = require('node:timers');
const nodeTimersPromises = require('node:timers/promises');
const { TIMEOUT_MAX } = require('internal/timers');

describe('Mock Timers Test Suite', () => {
describe('MockTimers API', () => {
@@ -252,10 +254,10 @@ describe('Mock Timers Test Suite', () => {
}), timeout);
});

it('should change timeout to 1ms when it is >= 2 ** 31', (t) => {
it('should change timeout to 1ms when it is > TIMEOUT_MAX', (t) => {
t.mock.timers.enable({ apis: ['setTimeout'] });
const fn = t.mock.fn();
global.setTimeout(fn, 2 ** 31);
global.setTimeout(fn, TIMEOUT_MAX + 1);
t.mock.timers.tick(1);
assert.strictEqual(fn.mock.callCount(), 1);
});
@@ -791,240 +793,6 @@ describe('Mock Timers Test Suite', () => {
});
});

describe('scheduler Suite', () => {
describe('scheduler.wait', () => {
it('should advance in time and trigger timers when calling the .tick function', (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });

const now = Date.now();
const durationAtMost = 100;

const p = nodeTimersPromises.scheduler.wait(4000);
t.mock.timers.tick(4000);

return p.then(common.mustCall((result) => {
assert.strictEqual(result, undefined);
assert.ok(
Date.now() - now < durationAtMost,
`time should be advanced less than the ${durationAtMost}ms`
);
}));
});

it('should advance in time and trigger timers when calling the .tick function multiple times', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });

const fn = t.mock.fn();

nodeTimersPromises.scheduler.wait(9999).then(fn);

t.mock.timers.tick(8999);
assert.strictEqual(fn.mock.callCount(), 0);
t.mock.timers.tick(500);

await nodeTimersPromises.setImmediate();

assert.strictEqual(fn.mock.callCount(), 0);
t.mock.timers.tick(500);

await nodeTimersPromises.setImmediate();
assert.strictEqual(fn.mock.callCount(), 1);
});

it('should work with the same params as the original timers/promises/scheduler.wait', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

t.mock.timers.tick(1000);
t.mock.timers.tick(500);
t.mock.timers.tick(500);
t.mock.timers.tick(500);

const result = await p;
assert.strictEqual(result, undefined);
});

it('should abort operation if timers/promises/scheduler.wait received an aborted signal', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

t.mock.timers.tick(1000);
controller.abort();
t.mock.timers.tick(500);
t.mock.timers.tick(500);
t.mock.timers.tick(500);

await assert.rejects(() => p, {
name: 'AbortError',
});
});
it('should abort operation even if the .tick was not called', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

controller.abort();

await assert.rejects(() => p, {
name: 'AbortError',
});
});

it('should abort operation when .abort is called before calling setInterval', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
controller.abort();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
});

await assert.rejects(() => p, {
name: 'AbortError',
});
});

it('should reject given an an invalid signal instance', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: {},
});

await assert.rejects(() => p, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_TYPE',
});
});

});
});

describe('Date Suite', () => {
it('should return the initial UNIX epoch if not specified', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
const date = new Date();
assert.strictEqual(date.getTime(), 0);
assert.strictEqual(Date.now(), 0);
});

it('should throw an error if setTime is called without enabling timers', (t) => {
assert.throws(
() => {
t.mock.timers.setTime(100);
},
{ code: 'ERR_INVALID_STATE' }
);
});

it('should throw an error if epoch passed to enable is not valid', (t) => {
assert.throws(
() => {
t.mock.timers.enable({ now: -1 });
},
{ code: 'ERR_INVALID_ARG_VALUE' }
);

assert.throws(
() => {
t.mock.timers.enable({ now: 'string' });
},
{ code: 'ERR_INVALID_ARG_TYPE' }
);

assert.throws(
() => {
t.mock.timers.enable({ now: NaN });
},
{ code: 'ERR_INVALID_ARG_VALUE' }
);
});

it('should replace the original Date with the mocked one', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
assert.ok(Date.isMock);
});

it('should return the ticked time when calling Date.now after tick', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
const time = 100;
t.mock.timers.tick(time);
assert.strictEqual(Date.now(), time);
});

it('should return the Date as string when calling it as a function', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
const returned = Date();
// Matches the format: 'Mon Jan 01 1970 00:00:00'
// We don't care about the date, just the format
assert.ok(/\w{3}\s\w{3}\s\d{1,2}\s\d{2,4}\s\d{1,2}:\d{2}:\d{2}/.test(returned));
});

it('should return the date with different argument calls', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
assert.strictEqual(new Date(0).getTime(), 0);
assert.strictEqual(new Date(100).getTime(), 100);
assert.strictEqual(new Date('1970-01-01T00:00:00.000Z').getTime(), 0);
assert.strictEqual(new Date(1970, 0).getFullYear(), 1970);
assert.strictEqual(new Date(1970, 0).getMonth(), 0);
assert.strictEqual(new Date(1970, 0, 1).getDate(), 1);
assert.strictEqual(new Date(1970, 0, 1, 11).getHours(), 11);
assert.strictEqual(new Date(1970, 0, 1, 11, 10).getMinutes(), 10);
assert.strictEqual(new Date(1970, 0, 1, 11, 10, 45).getSeconds(), 45);
assert.strictEqual(new Date(1970, 0, 1, 11, 10, 45, 898).getMilliseconds(), 898);
assert.strictEqual(new Date(1970, 0, 1, 11, 10, 45, 898).toDateString(), 'Thu Jan 01 1970');
});

it('should return native code when calling Date.toString', (t) => {
t.mock.timers.enable({ apis: ['Date'] });
assert.strictEqual(Date.toString(), 'function Date() { [native code] }');
});

it('should start with a custom epoch if the second argument is specified', (t) => {
t.mock.timers.enable({ apis: ['Date'], now: 100 });
const date1 = new Date();
assert.strictEqual(date1.getTime(), 100);

t.mock.timers.reset();
t.mock.timers.enable({ apis: ['Date'], now: new Date(200) });
const date2 = new Date();
assert.strictEqual(date2.getTime(), 200);
});

it('should replace epoch if setTime is lesser than now and not tick', (t) => {
t.mock.timers.enable();
const fn = t.mock.fn();
const id = setTimeout(fn, 1000);
t.mock.timers.setTime(800);
assert.strictEqual(Date.now(), 800);
t.mock.timers.setTime(500);
assert.strictEqual(Date.now(), 500);
assert.strictEqual(fn.mock.callCount(), 0);
clearTimeout(id);
});

it('should not tick time when setTime is called', (t) => {
t.mock.timers.enable();
const fn = t.mock.fn();
const id = setTimeout(fn, 1000);
t.mock.timers.setTime(1200);
assert.strictEqual(Date.now(), 1200);
assert.strictEqual(fn.mock.callCount(), 0);
clearTimeout(id);
});
});

describe('Api should have same public properties as original', () => {
it('should have hasRef', (t) => {
t.mock.timers.enable();