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 authored and ptomato committed Aug 21, 2023
1 parent c30aff0 commit bdddd9e
Showing 1 changed file with 8 additions and 2 deletions.
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 bdddd9e

Please sign in to comment.