summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2021-11-03 20:22:55 +0000
committerLinus Groh <mail@linusgroh.de>2021-11-04 12:11:33 +0100
commitc001926752a5d321ab9b242d9b20d89341cab290 (patch)
treeba4a45dbd93e4aeef853347b7080600594ee65fd /Userland/Libraries/LibJS/Tests
parent98accad9baf74c9c1f56621ff5ae7dbbd1f54ec6 (diff)
downloadserenity-c001926752a5d321ab9b242d9b20d89341cab290.zip
LibJS: Implement Temporal.ZonedDateTime.prototype.startOfDay
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.startOfDay.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.startOfDay.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.startOfDay.js
new file mode 100644
index 0000000000..d95402e5e0
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/ZonedDateTime/ZonedDateTime.prototype.startOfDay.js
@@ -0,0 +1,45 @@
+describe("correct behavior", () => {
+ test("length is 0", () => {
+ expect(Temporal.ZonedDateTime.prototype.startOfDay).toHaveLength(0);
+ });
+
+ test("basic functionality", () => {
+ const plainDateTime = new Temporal.PlainDateTime(2021, 11, 3, 20, 9, 45, 100, 200, 300);
+ const timeZone = new Temporal.TimeZone("UTC");
+ const zonedDateTime = plainDateTime.toZonedDateTime(timeZone);
+ const startOfDayZonedDateTime = zonedDateTime.startOfDay();
+
+ expect(startOfDayZonedDateTime.epochNanoseconds).toBe(1635897600000000000n);
+ expect(startOfDayZonedDateTime.epochMicroseconds).toBe(1635897600000000n);
+ expect(startOfDayZonedDateTime.epochMilliseconds).toBe(1635897600000);
+ expect(startOfDayZonedDateTime.epochSeconds).toBe(1635897600);
+ expect(startOfDayZonedDateTime.year).toBe(2021);
+ expect(startOfDayZonedDateTime.month).toBe(11);
+ expect(startOfDayZonedDateTime.monthCode).toBe("M11");
+ expect(startOfDayZonedDateTime.day).toBe(3);
+ expect(startOfDayZonedDateTime.hour).toBe(0);
+ expect(startOfDayZonedDateTime.minute).toBe(0);
+ expect(startOfDayZonedDateTime.second).toBe(0);
+ expect(startOfDayZonedDateTime.millisecond).toBe(0);
+ expect(startOfDayZonedDateTime.microsecond).toBe(0);
+ expect(startOfDayZonedDateTime.nanosecond).toBe(0);
+ expect(startOfDayZonedDateTime.dayOfWeek).toBe(3);
+ expect(startOfDayZonedDateTime.dayOfYear).toBe(307);
+ expect(startOfDayZonedDateTime.weekOfYear).toBe(44);
+ expect(startOfDayZonedDateTime.hoursInDay).toBe(24);
+ expect(startOfDayZonedDateTime.daysInWeek).toBe(7);
+ expect(startOfDayZonedDateTime.daysInYear).toBe(365);
+ expect(startOfDayZonedDateTime.monthsInYear).toBe(12);
+ expect(startOfDayZonedDateTime.inLeapYear).toBeFalse();
+ expect(startOfDayZonedDateTime.offset).toBe("+00:00");
+ expect(startOfDayZonedDateTime.offsetNanoseconds).toBe(0);
+ });
+});
+
+describe("errors", () => {
+ test("this value must be a Temporal.ZonedDateTime object", () => {
+ expect(() => {
+ Temporal.ZonedDateTime.prototype.startOfDay.call("foo");
+ }).toThrowWithMessage(TypeError, "Not an object of type Temporal.ZonedDateTime");
+ });
+});