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 <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
XadillaX authored and danielleadams committed Apr 24, 2022
1 parent 63b468f commit 70281e1
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 70281e1

Please sign in to comment.