Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8383d3

Browse files
authored
tests: fix i18n format in Node 20.19 (#16398)
1 parent 7938a6c commit d8383d3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

.github/workflows/devtools.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ jobs:
5252
# 3) every change to file in Lighthouse repo important to running these tests.
5353
#
5454
# The number is how many times this hash key was manually updated to break the cache.
55-
key: ${{ runner.os }}-12-${{ env.WEEK_OF_THE_YEAR }}-${{ hashFiles('cdt-test-hash.txt') }}
56-
restore-keys: ${{ runner.os }}-12
55+
key: ${{ runner.os }}-13-${{ env.WEEK_OF_THE_YEAR }}-${{ hashFiles('cdt-test-hash.txt') }}
56+
restore-keys: ${{ runner.os }}-13
5757
- name: Set GHA_DEVTOOLS_CACHE_HIT
5858
if: steps.devtools-cache.outputs.cache-hit == 'true'
5959
run: echo "GHA_DEVTOOLS_CACHE_HIT=1" >> $GITHUB_ENV

report/test/renderer/i18n-formatter-test.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {I18nFormatter} from '../../renderer/i18n-formatter.js';
1010

1111
const NBSP = '\xa0';
1212

13+
const [nodeMajor, nodeMinor] = process.version.replace('v', '').split('.').map(Number);
14+
1315
describe('i18n formatter', () => {
1416
it('formats a number', () => {
1517
const i18n = new I18nFormatter('en');
@@ -139,9 +141,16 @@ describe('i18n formatter', () => {
139141
// Yes, this is actually backwards (s h d).
140142
i18n = new I18nFormatter('ar');
141143
/* eslint-disable no-irregular-whitespace */
142-
assert.equal(i18n.formatDuration(60 * 1000), ${NBSP}د`);
143-
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), ${NBSP}س ٥${NBSP}ث`);
144-
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `١ ي ٤ س ٥ ث`);
144+
if (nodeMajor >= 20 && nodeMinor >= 19) {
145+
assert.equal(i18n.formatDuration(60 * 1000), `1${NBSP}د`);
146+
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `1${NBSP}س 5${NBSP}ث`);
147+
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `1 ي 4 س 5 ث`);
148+
} else {
149+
assert.equal(i18n.formatDuration(60 * 1000), ${NBSP}د`);
150+
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), ${NBSP}س ٥${NBSP}ث`);
151+
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `١ ي ٤ س ٥ ث`);
152+
}
153+
145154
/* eslint-enable no-irregular-whitespace */
146155
});
147156

0 commit comments

Comments
 (0)