Add missing tests for PlainTime property bag with no time units

We already had similar tests to these for other methods, such as
Temporal.PlainTime.prototype.equals(). since() and until() should have
these tests too.

Update assertion messages in all of the existing tests as well, as per
Ms2ger's review comment.
This commit is contained in:
Philip Chimento 2022-04-18 10:36:34 -07:00 committed by Philip Chimento
parent 15ed94c891
commit 7b3c176629
8 changed files with 42 additions and 6 deletions

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.PlainDate(2000, 1, 1);
const props = {};
assert.throws(TypeError, () => instance.toPlainDateTime(props), "TypeError if at least one property is not present");
assert.throws(TypeError, () => instance.toPlainDateTime(props), "TypeError if no properties are present");
props.minute = 30;
const result = instance.toPlainDateTime(props);

View File

@ -10,7 +10,7 @@ features: [Temporal]
const instance = new Temporal.PlainDate(2000, 1, 1);
const props = {};
assert.throws(TypeError, () => instance.toZonedDateTime({ plainTime: props, timeZone: "UTC" }), "TypeError if at least one property is not present");
assert.throws(TypeError, () => instance.toZonedDateTime({ plainTime: props, timeZone: "UTC" }), "TypeError if no properties are present");
props.minute = 30;
const result = instance.toZonedDateTime({ plainTime: props, timeZone: "UTC" });

View File

@ -11,7 +11,7 @@ features: [Temporal]
const instance = new Temporal.PlainDateTime(2000, 1, 1, 12, 30, 45, 123, 456, 789);
const props = {};
assert.throws(TypeError, () => instance.withPlainTime(props), "TypeError if at least one property is not present");
assert.throws(TypeError, () => instance.withPlainTime(props), "TypeError if no properties are present");
props.minute = 30;
const result = instance.withPlainTime(props);

View File

@ -8,7 +8,7 @@ features: [Temporal]
---*/
const props = {};
assert.throws(TypeError, () => Temporal.PlainTime.compare(props, new Temporal.PlainTime(0, 30)), "TypeError if at least one property is not present");
assert.throws(TypeError, () => Temporal.PlainTime.compare(props, new Temporal.PlainTime(0, 30)), "TypeError if no properties are present");
props.minute = 30;
const result = Temporal.PlainTime.compare(props, new Temporal.PlainTime(0, 30));

View File

@ -10,7 +10,7 @@ features: [Temporal]
const instance = new Temporal.PlainTime(0, 30, 0, 0, 0, 0);
const props = {};
assert.throws(TypeError, () => instance.equals(props), "TypeError if at least one property is not present");
assert.throws(TypeError, () => instance.equals(props), "TypeError if no properties are present");
props.minute = 30;
const result = instance.equals(props);

View File

@ -0,0 +1,18 @@
// 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.since
description: Missing time units in property bag default to 0
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(1, 0, 0, 0, 0, 1);
const props = {};
assert.throws(TypeError, () => instance.since(props), "TypeError if no properties are present");
props.minute = 30;
const result = instance.since(props);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 30, 0, 0, 0, 1, "missing time units default to 0");

View File

@ -0,0 +1,18 @@
// 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.until
description: Missing time units in property bag default to 0
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(1, 0, 0, 0, 0, 1);
const props = {};
assert.throws(TypeError, () => instance.until(props), "TypeError if no properties are present");
props.minute = 30;
const result = instance.until(props);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, -30, 0, 0, 0, -1, "missing time units default to 0");

View File

@ -10,7 +10,7 @@ features: [Temporal]
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
const props = {};
assert.throws(TypeError, () => instance.withPlainTime(props), "TypeError if at least one property is not present");
assert.throws(TypeError, () => instance.withPlainTime(props), "TypeError if no properties are present");
props.minute = 30;
const result = instance.withPlainTime(props);