From e885ab7ee590a194f44118261e5dc429ac72eb54 Mon Sep 17 00:00:00 2001 From: Khaidi Chu Date: Fri, 4 Mar 2022 19:48:33 +0800 Subject: [PATCH] test: fix test-process-env-tz.js by using RegExp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/42113 Reviewed-By: Richard Lau Reviewed-By: Antoine du Hamel Reviewed-By: Mestery Reviewed-By: Luigi Pinca Reviewed-By: Akhil Marsonya Reviewed-By: Darshan Sen --- test/parallel/test-process-env-tz.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-process-env-tz.js b/test/parallel/test-process-env-tz.js index da716299c9f622..b0188ab9c267f8 100644 --- a/test/parallel/test-process-env-tz.js +++ b/test/parallel/test-process-env-tz.js @@ -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