From 7f091cf05715a3c76fb9bddc809fc050cb674d80 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Tue, 17 Oct 2023 15:52:46 +0200 Subject: [PATCH] (core) Fix number parsing/formatting tests after updates to node version and locales Summary: The en-ZA locale was recently updated: https://github.com/nodejs/node/issues/48120 This caused test failures which I was happy about, until I saw af-ZA is still using the old separators. Test Plan: Tests failed locally when using the latest node 18, then passed after this change. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D4079 --- test/common/NumberParse.ts | 4 ++-- test/common/ValueFormatter.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common/NumberParse.ts b/test/common/NumberParse.ts index ec7ac1e5..d8980624 100644 --- a/test/common/NumberParse.ts +++ b/test/common/NumberParse.ts @@ -153,10 +153,10 @@ describe("NumberParse", function() { check(" 123 456 789,123", 123456789.123); // normal space check(" 123 456 789,123", 123456789.123); // NBSP - formatter = Intl.NumberFormat("en-ZA", {useGrouping: true}); + formatter = Intl.NumberFormat("af-ZA", {useGrouping: true}); assert.equal(formatter.format(123456789.123), '123 456 789,123'); - parser = new NumberParse("en-ZA", "ZAR"); + parser = new NumberParse("af-ZA", "ZAR"); assert.equal(parser.digitGroupSeparator, " "); assert.equal(parser.digitGroupSeparatorCurrency, " "); diff --git a/test/common/ValueFormatter.ts b/test/common/ValueFormatter.ts index cd39cf31..856e0253 100644 --- a/test/common/ValueFormatter.ts +++ b/test/common/ValueFormatter.ts @@ -115,7 +115,7 @@ describe("ValueFormatter", function() { assert.equal(fmt({numMode: 'currency'}, 0.1234567, {locale: 'fr-BE'}), '0,12 €'); assert.equal(fmt({numMode: 'currency', maxDecimals: 0}, 12.34567, {locale: 'en-GB'}), '£12.35'); assert.equal(fmt({numMode: 'currency', decimals: 0, maxDecimals: 0}, 12.34567, {locale: 'en-IE'}), '€12'); - assert.equal(fmt({numMode: 'currency'}, 1.015e-8, {locale: 'en-ZA'}), 'R 0,00'); + assert.equal(fmt({numMode: 'currency'}, 1.015e-8, {locale: 'af-ZA'}), 'R 0,00'); assert.equal(fmt({numMode: 'currency', maxDecimals: 10}, 1.015e-8, {locale: 'en-CA'}), '$0.0000000102'); assert.equal(fmt({numMode: 'currency'}, -1.015e-8, {locale: 'nl-BE'}), '€ -0,00'); @@ -133,7 +133,7 @@ describe("ValueFormatter", function() { assert.equal( fmt({numMode: 'currency', decimals: 0, maxDecimals: 0}, 12.34567, {locale: 'en-IE', currency: 'SGD'}), '$12'); - assert.equal(fmt({numMode: 'currency'}, 1.015e-8, {locale: 'en-ZA', currency: 'HKD'}), '$0,00'); + assert.equal(fmt({numMode: 'currency'}, 1.015e-8, {locale: 'af-ZA', currency: 'HKD'}), '$0,00'); assert.equal( fmt({numMode: 'currency', maxDecimals: 10}, 1.015e-8, {locale: 'en-CA', currency: 'RUB'}), '₽0.0000000102');