summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests/builtins
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-08-27 19:45:10 +0100
committerLinus Groh <mail@linusgroh.de>2021-08-27 23:36:52 +0100
commitf746850d1c81847e194de6a5b17b0ef7b3c8c27e (patch)
treee72ace8a66f3996b08f73997d671dba471f64f39 /Userland/Libraries/LibJS/Tests/builtins
parent525a7e487bc1fd469015b2539b7f6be3e54dad75 (diff)
downloadserenity-f746850d1c81847e194de6a5b17b0ef7b3c8c27e.zip
LibJS: Implement Temporal.Calendar.prototype.era()
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/builtins')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.era.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.era.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.era.js
new file mode 100644
index 0000000000..a80ab602a2
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.era.js
@@ -0,0 +1,26 @@
+describe("correct behavior", () => {
+ test("length is 1", () => {
+ expect(Temporal.Calendar.prototype.era).toHaveLength(1);
+ });
+
+ test("basic functionality", () => {
+ const plainDate = new Temporal.PlainDate(2021, 7, 6);
+ const calendar = new Temporal.Calendar("iso8601");
+ expect(calendar.era(plainDate)).toBeUndefined();
+ });
+});
+
+describe("errors", () => {
+ test("this value must be a Temporal.Calendar object", () => {
+ expect(() => {
+ Temporal.Calendar.prototype.era.call("foo");
+ }).toThrowWithMessage(TypeError, "Not a Temporal.Calendar");
+ });
+
+ test("argument must be date-like", () => {
+ const calendar = new Temporal.Calendar("iso8601");
+ expect(() => {
+ calendar.era({});
+ }).toThrowWithMessage(TypeError, "Required property year is missing or undefined");
+ });
+});