mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-01 13:44:21 +00:00
LibJS/Tests: Verify the parsing of Date at maximum and minimum values
This commit is contained in:
parent
0bb5421515
commit
4d099c91cd
|
@ -203,3 +203,23 @@ test("Round trip Date.prototype.to*String", () => {
|
|||
expect(Date.parse(epoch.toISOString())).toBe(epoch.valueOf());
|
||||
expect(Date.parse(epoch.toUTCString())).toBe(epoch.valueOf());
|
||||
});
|
||||
|
||||
test("Date parsing of minimum and maximum values", () => {
|
||||
const minDateStr = "-271821-04-20T00:00:00.000Z";
|
||||
const minDate = new Date(-8640000000000000);
|
||||
|
||||
expect(minDate.toISOString()).toBe(minDateStr);
|
||||
expect(Date.parse(minDateStr)).toBe(minDate.valueOf());
|
||||
|
||||
const maxDateStr = "+275760-09-13T00:00:00.000Z";
|
||||
const maxDate = new Date(8640000000000000);
|
||||
|
||||
expect(maxDate.toISOString()).toBe(maxDateStr);
|
||||
expect(Date.parse(maxDateStr)).toBe(maxDate.valueOf());
|
||||
|
||||
const belowRange = "-271821-04-19T23:59:59.999Z";
|
||||
const aboveRange = "+275760-09-13T00:00:00.001Z";
|
||||
|
||||
expect(Date.parse(belowRange)).toBe(NaN);
|
||||
expect(Date.parse(aboveRange)).toBe(NaN);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue