diff options
author | Linus Groh <mail@linusgroh.de> | 2021-08-27 20:33:25 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-08-27 23:36:52 +0100 |
commit | a8329272ccf2089c4f6a3a87874e852550429c77 (patch) | |
tree | c0446fb6cfc0bda9c13682290c06f4f25d440532 /Userland/Libraries/LibJS/Tests/builtins | |
parent | b59e9260db2f4aeda13b2628133e6377f2012e5a (diff) | |
download | serenity-a8329272ccf2089c4f6a3a87874e852550429c77.zip |
LibJS: Implement Temporal.ZonedDateTime.prototype.eraYear
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/builtins')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.eraYear.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.eraYear.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.eraYear.js new file mode 100644 index 0000000000..304d9eea02 --- /dev/null +++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.eraYear.js @@ -0,0 +1,26 @@ +describe("correct behavior", () => { + test("basic functionality", () => { + const timeZone = new Temporal.TimeZone("UTC"); + const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone); + expect(zonedDateTime.eraYear).toBeUndefined(); + }); + + test("calendar with custom eraYear function", () => { + const timeZone = new Temporal.TimeZone("UTC"); + const calendar = { + eraYear() { + return 123; + }, + }; + const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone, calendar); + expect(zonedDateTime.eraYear).toBe(123); + }); +}); + +describe("errors", () => { + test("this value must be a Temporal.ZonedDateTime object", () => { + expect(() => { + Reflect.get(Temporal.ZonedDateTime.prototype, "eraYear", "foo"); + }).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime"); + }); +}); |