Add test for #349 and #351 PR (#2379)

Test DateTimeFormat change pattern based on calendar and output relatedYear and yearName
based on the assumption that "en-u-ca-chinese" will output 'relatedYear' and 'yearName'.
https://github.com/tc39/ecma402/pull/349
https://github.com/tc39/ecma402/pull/351
@rwaldron @leobalter @Ms2ger @littledan
This commit is contained in:
Frank Yung-Fong Tang 2019-10-08 11:54:02 -07:00 committed by Leo Balter
parent 79a01f5122
commit 79591ae6c8
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
// Copyright 2019 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-partitiondatetimepattern
description: Checks the output of 'relatedYear' and 'yearName' type, and
the choose of pattern base on calendar.
locale: [en-u-ca-chinese]
---*/
let df = new Intl.DateTimeFormat("en-u-ca-chinese", {year: "numeric"});
let parts = df.formatToParts(new Date());
var relatedYearCount = 0;
var yearNameCount = 0;
parts.forEach(function(part) {
relatedYearCount += (part.type == "relatedYear") ? 1 : 0;
yearNameCount += (part.type == "yearName") ? 1 : 0;
});
assert.sameValue(relatedYearCount > 0, true);
assert.sameValue(yearNameCount > 0, true);