mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-19 08:51:57 +00:00
LibJS: Implement Temporal.PlainDate.prototype.toPlainMonthDay/YearMonth
This commit is contained in:
parent
3aa4cdd314
commit
f8b593a7df
Notes:
github-actions[bot]
2024-11-23 13:47:41 +00:00
Author: https://github.com/trflynn89
Commit: f8b593a7df
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2513
Reviewed-by: https://github.com/shannonbooth ✅
4 changed files with 76 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Temporal.PlainDate.prototype.toPlainMonthDay).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainDate = new Temporal.PlainDate(2021, 7, 6);
|
||||
const plainMonthDay = plainDate.toPlainMonthDay();
|
||||
expect(plainMonthDay.calendar).toBe(plainDate.calendar);
|
||||
expect(plainMonthDay.monthCode).toBe("M07");
|
||||
expect(plainMonthDay.day).toBe(6);
|
||||
|
||||
const fields = plainMonthDay.toString({ calendarName: "always" });
|
||||
const year = fields.split("-")[0];
|
||||
expect(year).toBe("1972");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Temporal.PlainDate.prototype.toPlainYearMonth).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainDate = new Temporal.PlainDate(2021, 7, 6);
|
||||
const plainYearMonth = plainDate.toPlainYearMonth();
|
||||
expect(plainYearMonth.calendar).toBe(plainDate.calendar);
|
||||
expect(plainYearMonth.year).toBe(2021);
|
||||
expect(plainYearMonth.month).toBe(7);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue