mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:07:46 +00:00
LibJS: Implement Temporal.ZonedDateTime.prototype.getISOFields()
This commit is contained in:
parent
82ab5da4db
commit
b7b23d05d5
3 changed files with 123 additions and 0 deletions
|
@ -0,0 +1,49 @@
|
|||
describe("normal behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Temporal.ZonedDateTime.prototype.getISOFields).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone, calendar);
|
||||
const fields = zonedDateTime.getISOFields();
|
||||
expect(fields).toEqual({
|
||||
calendar: calendar,
|
||||
isoDay: 6,
|
||||
isoHour: 23,
|
||||
isoMicrosecond: 0,
|
||||
isoMillisecond: 0,
|
||||
isoMinute: 42,
|
||||
isoMonth: 7,
|
||||
isoNanosecond: 0,
|
||||
isoSecond: 1,
|
||||
isoYear: 2021,
|
||||
offset: "+00:00",
|
||||
timeZone: timeZone,
|
||||
});
|
||||
// Test field order
|
||||
expect(Object.getOwnPropertyNames(fields)).toEqual([
|
||||
"calendar",
|
||||
"isoDay",
|
||||
"isoHour",
|
||||
"isoMicrosecond",
|
||||
"isoMillisecond",
|
||||
"isoMinute",
|
||||
"isoMonth",
|
||||
"isoNanosecond",
|
||||
"isoSecond",
|
||||
"isoYear",
|
||||
"offset",
|
||||
"timeZone",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
test("errors", () => {
|
||||
test("this value must be a Temporal.ZonedDateTime object", () => {
|
||||
expect(() => {
|
||||
Temporal.ZonedDateTime.prototype.getISOFields.call("foo");
|
||||
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue