Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorZiJian Liu <Lxxyxzj@gmail.com>2021-05-20 08:22:38 +0300
committerJames M Snell <jasnell@gmail.com>2021-05-24 17:36:11 +0300
commit80ed0a66b5ac5754168db2e9e6b8021d596a0679 (patch)
tree7858e60f6d7c2bfecaeb74f8ff9b8d1a495b1aeb /test
parent28e1b2e2f1a6bedc835db244226659bfcaa0f068 (diff)
test: set locale for datetime-change-notify test
The time zone output by toString() will change with user's language, use toLocaleString() to set the time zone. PR-URL: https://github.com/nodejs/node/pull/38741 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-datetime-change-notify.js35
1 files changed, 24 insertions, 11 deletions
diff --git a/test/parallel/test-datetime-change-notify.js b/test/parallel/test-datetime-change-notify.js
index 94f126179b7..9cd6d7abfd8 100644
--- a/test/parallel/test-datetime-change-notify.js
+++ b/test/parallel/test-datetime-change-notify.js
@@ -11,14 +11,27 @@ if (!isMainThread)
const assert = require('assert');
-process.env.TZ = 'Etc/UTC';
-assert.match(new Date().toString(), /GMT\+0000/);
-
-process.env.TZ = 'America/New_York';
-assert.match(new Date().toString(), /Eastern (Standard|Daylight) Time/);
-
-process.env.TZ = 'America/Los_Angeles';
-assert.match(new Date().toString(), /Pacific (Standard|Daylight) Time/);
-
-process.env.TZ = 'Europe/Dublin';
-assert.match(new Date().toString(), /Irish/);
+const cases = [
+ {
+ timeZone: 'Etc/UTC',
+ expected: /Coordinated Universal Time/,
+ },
+ {
+ timeZone: 'America/New_York',
+ expected: /Eastern (Standard|Daylight) Time/,
+ },
+ {
+ timeZone: 'America/Los_Angeles',
+ expected: /Pacific (Standard|Daylight) Time/,
+ },
+ {
+ timeZone: 'Europe/Dublin',
+ expected: /Irish/,
+ },
+];
+
+for (const { timeZone, expected } of cases) {
+ process.env.TZ = timeZone;
+ const date = new Date().toLocaleString('en-US', { timeZoneName: 'long' });
+ assert.match(date, expected);
+}