summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2021-11-03 01:58:12 +0000
committerLinus Groh <mail@linusgroh.de>2021-11-03 11:03:30 +0100
commite42431ec7c3ff2630347a25f9b5441a0527409a3 (patch)
tree38244dc84f160f3ed25d18f3c5633c510012ddc3 /Userland/Libraries/LibJS/Tests
parent2a98b521b492416ff6d4dfab8cba75a4def511ca (diff)
downloadserenity-e42431ec7c3ff2630347a25f9b5441a0527409a3.zip
LibJS: Implement Temporal.PlainDateTime.prototype.toJSON
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDateTime/PlainDateTime.prototype.toJSON.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDateTime/PlainDateTime.prototype.toJSON.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDateTime/PlainDateTime.prototype.toJSON.js
new file mode 100644
index 0000000000..b0ce506a78
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDateTime/PlainDateTime.prototype.toJSON.js
@@ -0,0 +1,18 @@
+describe("correct behavior", () => {
+ test("length is 0", () => {
+ expect(Temporal.PlainDateTime.prototype.toJSON).toHaveLength(0);
+ });
+
+ test("basic functionality", () => {
+ const plainDateTime = new Temporal.PlainDateTime(2021, 11, 3, 1, 33, 5, 100, 200, 300);
+ expect(plainDateTime.toJSON()).toBe("2021-11-03T01:33:05.1002003");
+ });
+});
+
+describe("errors", () => {
+ test("this value must be a Temporal.PlainDateTime object", () => {
+ expect(() => {
+ Temporal.PlainDateTime.prototype.toJSON.call("foo");
+ }).toThrowWithMessage(TypeError, "Not an object of type Temporal.PlainDateTime");
+ });
+});