diff options
author | Nico Weber <thakis@chromium.org> | 2020-08-25 20:07:36 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-26 08:52:07 +0200 |
commit | 2c1b84b3e10e67d6aeb3006f7535b8990355d769 (patch) | |
tree | bc8bcc24f57d3dbb02f1a26f6f6ff633ea003ed8 /Libraries/LibJS/Tests/builtins/Date | |
parent | 9b170828999d1b20da0e1f15c548188f6835a1cb (diff) | |
download | serenity-2c1b84b3e10e67d6aeb3006f7535b8990355d769.zip |
LibJS: Add some more tests, mostly around leap years
Diffstat (limited to 'Libraries/LibJS/Tests/builtins/Date')
-rw-r--r-- | Libraries/LibJS/Tests/builtins/Date/Date.UTC.js | 4 | ||||
-rw-r--r-- | Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTCMonth.js | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js b/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js index f1194dd495..d5c8082729 100644 --- a/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js +++ b/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js @@ -26,6 +26,10 @@ test("basic functionality", () => { expect(Date.UTC(20000, 0)).toBe(568971820800000); }); +test("leap year", () => { + expect(Date.UTC(2020, 2, 1)).toBe(1583020800000); +}); + test("out of range", () => { expect(Date.UTC(2020, -20)).toBe(1525132800000); expect(Date.UTC(2020, 20)).toBe(1630454400000); diff --git a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTCMonth.js b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTCMonth.js index 8b031497de..ed6ed64d97 100644 --- a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTCMonth.js +++ b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTCMonth.js @@ -4,4 +4,23 @@ test("basic functionality", () => { expect(d.getUTCMonth()).not.toBeNaN(); expect(d.getUTCMonth()).toBeGreaterThanOrEqual(0); expect(d.getUTCMonth()).toBeLessThanOrEqual(11); + + expect(new Date(Date.UTC(2020, 11)).getUTCMonth()).toBe(11); +}); + +test("leap years", () => { + expect(new Date(Date.UTC(2019, 1, 29)).getUTCDate()).toBe(1); + expect(new Date(Date.UTC(2019, 1, 29)).getUTCMonth()).toBe(2); + expect(new Date(Date.UTC(2100, 1, 29)).getUTCDate()).toBe(1); + expect(new Date(Date.UTC(2100, 1, 29)).getUTCMonth()).toBe(2); + + expect(new Date(Date.UTC(2000, 1, 29)).getUTCDate()).toBe(29); + expect(new Date(Date.UTC(2000, 1, 29)).getUTCMonth()).toBe(1); + expect(new Date(Date.UTC(2020, 1, 29)).getUTCDate()).toBe(29); + expect(new Date(Date.UTC(2020, 1, 29)).getUTCMonth()).toBe(1); + + expect(new Date(Date.UTC(2019, 2, 1)).getUTCDate()).toBe(1); + expect(new Date(Date.UTC(2019, 2, 1)).getUTCMonth()).toBe(2); + expect(new Date(Date.UTC(2020, 2, 1)).getUTCDate()).toBe(1); + expect(new Date(Date.UTC(2020, 2, 1)).getUTCMonth()).toBe(2); }); |