Temporal: Use propertyBagObserver in monthDayFromFields test

This commit is contained in:
Philip Chimento 2023-09-19 11:13:44 -07:00 committed by Richard Gibson
parent f4377a7cf0
commit 892a5dccd2
1 changed files with 9 additions and 16 deletions

View File

@ -24,20 +24,13 @@ const missingDay = {
assert.throws(TypeError, () => instance.monthDayFromFields(missingDay), "day should be checked before year and month"); assert.throws(TypeError, () => instance.monthDayFromFields(missingDay), "day should be checked before year and month");
let got = []; let got = [];
const fieldsSpy = { const fieldsSpy = TemporalHelpers.propertyBagObserver(got, { day: 1 });
get year() {
got.push("year");
},
get month() {
got.push("month");
},
get monthCode() {
got.push("monthCode");
},
get day() {
got.push("day");
return 1;
},
};
assert.throws(TypeError, () => instance.monthDayFromFields(fieldsSpy), "incomplete fields should be rejected (but after reading all non-required fields)"); assert.throws(TypeError, () => instance.monthDayFromFields(fieldsSpy), "incomplete fields should be rejected (but after reading all non-required fields)");
assert.compareArray(got, ["day", "month", "monthCode", "year"], "fields should be read in alphabetical order"); assert.compareArray(got, [
"get day",
"get day.valueOf",
"call day.valueOf",
"get month",
"get monthCode",
"get year",
], "fields should be read in alphabetical order");