Add tests: "Extend TimeZoneName Option" proposal (#3042)

This commit is contained in:
jugglinmike 2021-07-16 09:45:02 -04:00 committed by GitHub
parent d15066ec39
commit 8faacdbaee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-initializedatetimeformat
description:
Invalid values for the `timeZoneName` option of the DateTimeFormat constructor
features: [Intl.DateTimeFormat-extend-timezonename]
---*/
assert.throws(RangeError, function () {
new Intl.DateTimeFormat('en', { timeZoneName: '' });
}, 'empty string');
assert.throws(RangeError, function () {
new Intl.DateTimeFormat('en', { timeZoneName: 'short ' });
}, '"short "');
assert.throws(RangeError, function () {
new Intl.DateTimeFormat('en', { timeZoneName: ' long' });
}, '" long"');
assert.throws(RangeError, function () {
new Intl.DateTimeFormat('en', { timeZoneName: 'offset' });
}, '"offset"');
assert.throws(RangeError, function () {
new Intl.DateTimeFormat('en', { timeZoneName: 'generic' });
}, '"generic"');

View File

@ -0,0 +1,28 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-initializedatetimeformat
description:
Valid values for the `timeZoneName` option of the DateTimeFormat constructor
features: [Intl.DateTimeFormat-extend-timezonename]
---*/
var dtf;
dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'short' });
assert.sameValue(dtf.resolvedOptions().timeZoneName, 'short');
dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'long' });
assert.sameValue(dtf.resolvedOptions().timeZoneName, 'long');
dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'shortOffset' });
assert.sameValue(dtf.resolvedOptions().timeZoneName, 'shortOffset');
dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'longOffset' });
assert.sameValue(dtf.resolvedOptions().timeZoneName, 'longOffset');
dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'shortGeneric' });
assert.sameValue(dtf.resolvedOptions().timeZoneName, 'shortGeneric');
dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'longGeneric' });
assert.sameValue(dtf.resolvedOptions().timeZoneName, 'longGeneric');