blob: 25f795a89ae2d4873f42d1af422f76e03d50c559 [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.instant.prototype.since
description: RangeError thrown when smallestUnit option not one of the allowed string values
features: [Temporal]
---*/
const earlier = new Temporal.Instant(1_000_000_000_000_000_000n);
const later = new Temporal.Instant(1_000_090_061_987_654_321n);
const badValues = [
"era",
"eraYear",
"year",
"month",
"week",
"day",
"millisecond\0",
"mill\u0131second",
"SECOND",
"eras",
"eraYears",
"years",
"months",
"weeks",
"days",
"milliseconds\0",
"mill\u0131seconds",
"SECONDS",
"other string",
];
for (const smallestUnit of badValues) {
assert.throws(RangeError, () => later.since(earlier, { smallestUnit }),
`"${smallestUnit}" is not a valid value for smallest unit`);
}