This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
FakeDate does not accept a timestamp value #1069
Closed
Description
Expected Behaviour: Passing a timestamp value into the Date object, as shown below, will produce a Date with that timestamp
Actual Behaviour: The timestamp is ignored and the current Date is used
In later versions (0.8.21 and onwards) this is happening, while using fakeAsync(worked with 0.8.20 and earlier)
The following code sample demonstrates this:
it('should set the right date', fakeAsync(() => {
test();
tick(1000);
console.log("second", Date, new Date(0));
}));
async function test() {
await (new Promise(resolve => {
resolve();
}));
console.log("first", Date, new Date(0));
}
The output is:
'first', function FakeDate() { ... }, Thu Apr 05 2018 11:05:19 GMT+0200 (CEST)
'second', function Date() { ... }, Thu Jan 01 1970 01:00:00 GMT+0100 (CET)
The first line of output is using the FakeDate object which is ignoring the value passed in and just producing the current Date.
The second line is working as expected.
This only occurs inside an async block, after an 'await' has been used
Metadata
Metadata
Assignees
Labels
No labels