Skip to content

Commit 03c8b12

Browse files
JasperB-TeamBluedupondje
authored andcommitted
test: fix error in testing based on node version
When running yarn test locally a different result in contrast to the CI was generated based on the node version installed. The change occurs between node 17 and 18 due to the unicode package that is used that bumps from 43 to 44. The changes in question: unicode-org/cldr@ee245ad#diff-13ab47c2c389ca4df107ede5363ddf13de85f9de0553e5560cd3bfada4ec0736R2122 Due to survey results implemented there, some locales changed from d/M format to dd/MM which fails in testing. Usage of an if statement due to centos9 having a max node version of 16.20 so support is still needed. Signed-off-by: Jasper Berton <jasper.berton@team.blue>
1 parent 901d1e8 commit 03c8b12

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/utils/intl.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ function extractTimeZoneName (locale, timeZone) {
151151
// then the formatted output is different.
152152

153153
describe('DateTime Formatters', function () {
154+
const nodeMajorVersion = parseInt(process.version.match(/^v(\d+)/)[1], 10)
154155
describe('format dates and date+times (en-US)', function () {
155156
it('format date', function () {
156157
initTimeZone('UTC')
@@ -180,15 +181,23 @@ describe('DateTime Formatters', function () {
180181
expect(currentTimeZone()).toBe('UTC')
181182

182183
expect(formatDate(new Date(Date.UTC(1999, 11, 31)))).toBe('31/12/1999')
183-
expect(formatDate(new Date(Date.UTC(2020, 6, 4)))).toBe('4/7/2020')
184+
if (nodeMajorVersion < 18) {
185+
expect(formatDate(new Date(Date.UTC(2020, 6, 4)))).toBe('4/7/2020')
186+
} else {
187+
expect(formatDate(new Date(Date.UTC(2020, 6, 4)))).toBe('04/07/2020')
188+
}
184189
})
185190
it('format datetime', function () {
186191
initLocale('it-IT')
187192
initTimeZone('UTC')
188193
const utcTzName = extractUtcTimezoneName(currentLocale())
189194

190195
expect(formatDateTime(new Date(Date.UTC(1999, 11, 31, 16, 35, 42)))).toBe(`31/12/1999, 16:35:42 ${utcTzName}`)
191-
expect(formatDateTime(new Date(Date.UTC(2020, 6, 4, 11, 12, 13)))).toBe(`4/7/2020, 11:12:13 ${utcTzName}`)
196+
if (nodeMajorVersion < 18) {
197+
expect(formatDateTime(new Date(Date.UTC(2020, 6, 4, 11, 12, 13)))).toBe(`4/7/2020, 11:12:13 ${utcTzName}`)
198+
} else {
199+
expect(formatDateTime(new Date(Date.UTC(2020, 6, 4, 11, 12, 13)))).toBe(`04/07/2020, 11:12:13 ${utcTzName}`)
200+
}
192201
})
193202
})
194203
}

0 commit comments

Comments
 (0)