2019-04-10 17:09:40 +02:00
|
|
|
// Copyright 2019 Igalia, S.L. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
2023-08-07 17:01:48 +02:00
|
|
|
esid: sec-createdatetimeformat
|
2019-04-10 17:09:40 +02:00
|
|
|
description: >
|
|
|
|
Checks error cases for the options argument to the DateTimeFormat constructor.
|
|
|
|
info: |
|
2023-08-07 17:01:48 +02:00
|
|
|
CreateDateTimeFormat ( dateTimeFormat, locales, options, required, defaults )
|
2019-04-10 17:09:40 +02:00
|
|
|
|
|
|
|
...
|
2023-08-07 17:01:48 +02:00
|
|
|
39. Let dateStyle be ? GetOption(options, "dateStyle", "string", « "full", "long", "medium", "short" », undefined).
|
2019-04-10 17:09:40 +02:00
|
|
|
features: [Intl.DateTimeFormat-datetimestyle]
|
|
|
|
---*/
|
|
|
|
|
|
|
|
|
|
|
|
const invalidOptions = [
|
|
|
|
"",
|
|
|
|
"FULL",
|
|
|
|
" long",
|
|
|
|
"short ",
|
|
|
|
"narrow",
|
|
|
|
"numeric",
|
|
|
|
];
|
|
|
|
for (const dateStyle of invalidOptions) {
|
|
|
|
assert.throws(RangeError, function() {
|
|
|
|
new Intl.DateTimeFormat("en", { dateStyle });
|
|
|
|
}, `new Intl.DateTimeFormat("en", { dateStyle: "${dateStyle}" }) throws RangeError`);
|
|
|
|
}
|