tests: fix i18n-test bugs in Node 13 (#10595)
This commit is contained in:
Родитель
64208321f5
Коммит
8b430442fa
|
@ -298,7 +298,15 @@ describe('i18n', () => {
|
|||
expect(helloInfinityStr).toBeDisplayString('Hello ∞ World');
|
||||
|
||||
const helloNaNStr = str_(UIStrings.helloBytesWorld, {in: NaN});
|
||||
expect(helloNaNStr).toBeDisplayString('Hello NaN World');
|
||||
// TODO(COMPAT): workaround can be removed after Node 13 is retired.
|
||||
// expect(helloNaNStr).toBeDisplayString('Hello NaN World');
|
||||
|
||||
// Node 13/V8 7.9 and 8.0 have a bug where `({a: NaN}).a.toLocaleString() === "-NaN"`. It
|
||||
// works correctly in Node 12 and 14, so work around it since NaN isn't essential for
|
||||
// user-facing strings and it will eventually correct itself.
|
||||
const formattedNaNStr = i18n.getFormatted(helloNaNStr, 'en-US');
|
||||
expect(formattedNaNStr === 'Hello NaN World' || formattedNaNStr === 'Hello -NaN World')
|
||||
.toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,27 +11,27 @@ const lhr = require('../../results/sample_v2.json');
|
|||
|
||||
/* eslint-env jest */
|
||||
describe('swap-locale', () => {
|
||||
it('can change golden LHR english strings into spanish', () => {
|
||||
it('can change golden LHR english strings into german', () => {
|
||||
const lhrEn = /** @type {LH.Result} */ (JSON.parse(JSON.stringify(lhr)));
|
||||
const lhrEs = swapLocale(lhrEn, 'es').lhr;
|
||||
const lhrDe = swapLocale(lhrEn, 'de').lhr;
|
||||
|
||||
// Basic replacement
|
||||
expect(lhrEn.audits.plugins.title).toEqual('Document avoids plugins');
|
||||
expect(lhrEs.audits.plugins.title).toEqual('El documento no usa complementos');
|
||||
expect(lhrDe.audits.plugins.title).toEqual('Dokument verwendet keine Plug-ins');
|
||||
|
||||
// With ICU string argument values
|
||||
expect(lhrEn.audits['dom-size'].displayValue).toEqual('31 elements');
|
||||
expect(lhrEs.audits['dom-size'].displayValue).toEqual('31 elementos');
|
||||
expect(lhrDe.audits['dom-size'].displayValue).toEqual('31 Elemente');
|
||||
|
||||
// Renderer formatted strings
|
||||
expect(lhrEn.i18n.rendererFormattedStrings.labDataTitle).toEqual('Lab Data');
|
||||
expect(lhrEs.i18n.rendererFormattedStrings.labDataTitle).toEqual('Datos de prueba');
|
||||
expect(lhrDe.i18n.rendererFormattedStrings.labDataTitle).toEqual('Labdaten');
|
||||
|
||||
// Formatted numbers in placeholders.
|
||||
expect(lhrEn.audits['render-blocking-resources'].displayValue)
|
||||
.toEqual('Potential savings of 1,130 ms');
|
||||
expect(lhrEs.audits['render-blocking-resources'].displayValue)
|
||||
.toEqual('Ahorro potencial de 1.130 ms');
|
||||
expect(lhrDe.audits['render-blocking-resources'].displayValue)
|
||||
.toEqual('Mögliche Einsparung von 1.130 ms');
|
||||
});
|
||||
|
||||
it('can roundtrip back to english correctly', () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче