Temporal: Add test for Calendar.id with custom calendar

We already have a similar test covering TimeZone.id that ensures toString
is not called. We did not have this coverage yet for Calendar.id, so adapt
the TimeZone test for Calendar.
This commit is contained in:
Philip Chimento 2022-10-19 10:55:17 -07:00 committed by Philip Chimento
parent 0fc42035eb
commit 39302ea3c1
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-temporal.calendar.prototype.id
description: Getter does not call toString(), returns the ID from internal slot
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const actual = [];
const expected = [];
const calendar = new Temporal.Calendar("iso8601");
TemporalHelpers.observeProperty(actual, calendar, Symbol.toPrimitive, undefined);
TemporalHelpers.observeProperty(actual, calendar, "toString", function () {
actual.push("call calendar.toString");
return "calendar ID";
});
const result = calendar.id;
assert.compareArray(actual, expected);
assert.sameValue(result, "iso8601");