diff options
-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); }); |