blob: b7f5e7bee7f86e5f2abf46b0b748d2d373d523bb [file] [log] [blame]
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.toplaindatetime
description: Verify the result of calendar.fields() is treated correctly.
info: |
sec-temporal.plaintime.prototype.toplaindatetime step 3:
3. Set _temporalDate_ to ? ToTemporalDate(_temporalDate_).
sec-temporal-totemporaldate step 2.c:
c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »).
sec-temporal-calendarfields step 4:
4. Let _result_ be ? IterableToList(_fieldsArray_).
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expected = [
"day",
"month",
"monthCode",
"year",
];
const time = new Temporal.PlainTime(13, 3);
const calendar = TemporalHelpers.calendarFieldsIterable();
time.toPlainDateTime({ year: 2000, month: 5, day: 3, calendar });
assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once");
assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args");
assert(calendar.iteratorExhausted[0], "iterated through the whole iterable");