Skip to content

Commit

Permalink
test: fix test-process-env-tz.js by using RegExp
Browse files Browse the repository at this point in the history
Not all environment returns 'Central European Summer Time', 'British
Summer Time' and 'Coordinated Universal Time'. E.g. Some environment
like Chinese returns '中欧夏令时间', '英国夏令时间' and '协调世界时'.

PR-URL: #42113
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Mestery <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Akhil Marsonya <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
XadillaX authored Mar 4, 2022
1 parent 29bb2bb commit b35ee26
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/parallel/test-process-env-tz.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ if (date.toString().includes('(Central European Time)') ||
common.skip('tzdata too old');
}

assert.strictEqual(
date.toString().replace('Central European Summer Time', 'CEST'),
'Sat Apr 14 2018 14:34:56 GMT+0200 (CEST)');
assert.match(
date.toString(),
/^Sat Apr 14 2018 14:34:56 GMT\+0200 \(.+\)$/);

process.env.TZ = 'Europe/London';
assert.strictEqual(
date.toString().replace('British Summer Time', 'BST'),
'Sat Apr 14 2018 13:34:56 GMT+0100 (BST)');
assert.match(
date.toString(),
/^Sat Apr 14 2018 13:34:56 GMT\+0100 \(.+\)$/);

process.env.TZ = 'Etc/UTC';
assert.strictEqual(
date.toString().replace('Coordinated Universal Time', 'UTC'),
'Sat Apr 14 2018 12:34:56 GMT+0000 (UTC)');
assert.match(
date.toString(),
/^Sat Apr 14 2018 12:34:56 GMT\+0000 \(.+\)$/);

// Just check that deleting the environment variable doesn't crash the process.
// We can't really check the result of date.toString() because we don't know
Expand Down

0 comments on commit b35ee26

Please sign in to comment.