Skip to content

Commit

Permalink
Update test for monthDayFromFields()
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditi-1400 committed May 25, 2023
1 parent e5a7450 commit 8de9048
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ features: [Temporal]

const cal = new Temporal.Calendar("iso8601");

let result = cal.monthDayFromFields({ year: 2021, monthCode: "M02", day: 29 });
TemporalHelpers.assertPlainMonthDay(result, "M02", 29, "year is ignored and reference year should be a leap year if monthCode is given");
let result = cal.monthDayFromFields({ year: 2021, monthCode: "M02", day: 29} , { overflow: "constrain" });
TemporalHelpers.assertPlainMonthDay(result, "M02", 28, "year should not be ignored when monthCode is given (overflow constrain");

assert.throws(
RangeError,
() => cal.monthDayFromFields({ year: 2021, monthCode: "M02", day: 29 }, {overflow: "reject"}),
"year should not be ignored when monthCode is given (overflow reject)"
);

result = cal.monthDayFromFields({ year: 2021, month: 2, day: 29 }, { overflow: "constrain" });
TemporalHelpers.assertPlainMonthDay(result, "M02", 28, "year should not be ignored if monthCode is not given (overflow constrain)");
Expand Down

0 comments on commit 8de9048

Please sign in to comment.