forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibJS: Implement Temporal.PlainMonthDay.prototype.toPlainDate()
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...raries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.prototype.toPlainDate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe("normal behavior", () => { | ||
test("length is 1", () => { | ||
expect(Temporal.PlainMonthDay.prototype.toPlainDate).toHaveLength(1); | ||
}); | ||
|
||
test("basic functionality", () => { | ||
const plainMonthDay = new Temporal.PlainMonthDay(7, 6); | ||
const plainDate = plainMonthDay.toPlainDate({ year: 2021 }); | ||
expect(plainDate.equals(new Temporal.PlainDate(2021, 7, 6))).toBeTrue(); | ||
}); | ||
}); | ||
|
||
describe("errors", () => { | ||
test("argument must be an object", () => { | ||
const plainMonthDay = new Temporal.PlainMonthDay(7, 6); | ||
expect(() => { | ||
plainMonthDay.toPlainDate(42); | ||
}).toThrowWithMessage(TypeError, "42 is not an object"); | ||
}); | ||
|
||
test("year field is required", () => { | ||
const plainMonthDay = new Temporal.PlainMonthDay(7, 6); | ||
expect(() => { | ||
plainMonthDay.toPlainDate({}); | ||
}).toThrowWithMessage(TypeError, "Required property year is missing or undefined"); | ||
}); | ||
}); |