mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
committed by
Andreas Kling
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/93712b24bf2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256 Reviewed-by: https://github.com/sideshowbarker
@@ -0,0 +1,57 @@
|
||||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Temporal.Now.plainDateISO).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainDate = Temporal.Now.plainDateISO();
|
||||
expect(plainDate).toBeInstanceOf(Temporal.PlainDate);
|
||||
expect(plainDate.calendar.id).toBe("iso8601");
|
||||
});
|
||||
|
||||
test("custom time zone", () => {
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor() {
|
||||
return 86399999999999;
|
||||
},
|
||||
};
|
||||
const plainDate = Temporal.Now.plainDateISO("UTC");
|
||||
const plainDateWithOffset = Temporal.Now.plainDateISO(timeZone);
|
||||
if (plainDate.dayOfYear === plainDate.daysInYear) {
|
||||
expect(plainDateWithOffset.year).toBe(plainDate.year + 1);
|
||||
expect(plainDateWithOffset.month).toBe(1);
|
||||
expect(plainDateWithOffset.day).toBe(1);
|
||||
} else {
|
||||
expect(plainDateWithOffset.year).toBe(plainDate.year);
|
||||
if (plainDate.day === plainDate.daysInMonth) {
|
||||
expect(plainDateWithOffset.month).toBe(plainDate.month + 1);
|
||||
expect(plainDateWithOffset.day).toBe(1);
|
||||
} else {
|
||||
expect(plainDateWithOffset.month).toBe(plainDate.month);
|
||||
expect(plainDateWithOffset.day).toBe(plainDate.day + 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("cannot have a time zone with more than a day", () => {
|
||||
[86400000000000, -86400000000000, 86400000000001, 86400000000002].forEach(offset => {
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor() {
|
||||
return offset;
|
||||
},
|
||||
};
|
||||
expect(() => Temporal.Now.plainDateISO(timeZone)).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid offset nanoseconds value, must be in range -86400 * 10^9 + 1 to 86400 * 10^9 - 1"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("custom time zone doesn't have a getOffsetNanosecondsFor function", () => {
|
||||
expect(() => {
|
||||
Temporal.Now.plainDateISO({});
|
||||
}).toThrowWithMessage(TypeError, "getOffsetNanosecondsFor is undefined");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user