Bug 1913305 - Add test. r=mtigley
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / PlainDateTime / prototype / since / smallestunit-invalid-string.js
blob36f1d33e5063ce0e2a19fc258472d058ffd822c6
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 esid: sec-temporal.plaindatetime.prototype.since
7 description: RangeError thrown when smallestUnit option not one of the allowed string values
8 features: [Temporal]
9 ---*/
11 const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 0);
12 const later = new Temporal.PlainDateTime(2000, 5, 3, 13, 35, 57, 987, 654, 321);
13 const badValues = [
14   "era",
15   "eraYear",
16   "millisecond\0",
17   "mill\u0131second",
18   "SECOND",
19   "eras",
20   "eraYears",
21   "milliseconds\0",
22   "mill\u0131seconds",
23   "SECONDS",
24   "other string",
26 for (const smallestUnit of badValues) {
27   assert.throws(RangeError, () => later.since(earlier, { smallestUnit }),
28     `"${smallestUnit}" is not a valid value for smallest unit`);
31 reportCompare(0, 0);