test: add NumberFormat resolvedOptions test

Add a regression test for NumberFormat resolvedOptions.

PR-URL: https://github.com/nodejs/node/pull/39401
Refs: https://github.com/nodejs/node/issues/39050
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

Backport-PR-URL: https://github.com/nodejs/node/pull/39051
This commit is contained in:
Richard Lau 2021-07-15 13:00:19 -04:00
parent 9b69069f71
commit 45c2ea3b72
No known key found for this signature in database
GPG Key ID: C43CEC45C17AB93C

View File

@ -104,6 +104,13 @@ if (!common.hasIntl) {
const numberFormat = new Intl.NumberFormat(['en']).format(12345.67890);
assert.strictEqual(numberFormat, '12,345.679');
}
// Number format resolved options
{
const numberFormat = new Intl.NumberFormat('en-US', { style: 'percent' });
const resolvedOptions = numberFormat.resolvedOptions();
assert.strictEqual(resolvedOptions.locale, 'en-US');
assert.strictEqual(resolvedOptions.style, 'percent');
}
// Significant Digits
{
const loc = ['en-US'];