Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
work around test environments that don't know their timezone.
Browse files Browse the repository at this point in the history
adding a kludge to deal with environments that serve up a timezone
offset instead of an IANA timezone name.
  • Loading branch information
stopfstedt committed Jan 25, 2024
1 parent 9f0ca9e commit 9ccc5f1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/test-app/tests/unit/services/timezone-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ module('Unit | Service | timezone', function (hooks) {
const names = service.getTimezoneNames();
const currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
assert.ok(names.includes(currentTimezone));
if (currentTimezone === 'UTC') {
//we already know it's in the list because it is the current zone
//however we now want to remove it because it won't ever display
//for users, just in CI
names.splice(names.indexOf('UTC'));
// KLUDGE!
// Some of the test environments (mobile platforms) in our CI/CD pipeline either serve up 'UTC'
// as current timezone name, or - even worse - a timezone offset instead of a AINA timezone name.
// But that's not how the real world functions, this only ever happens in these broken test environments.
// So let's pretend this isn't happening and filter these out to prevent test breakage.
// [ST 2023/01/24]
if (
currentTimezone === 'UTC' ||
!!currentTimezone.match('^([+-](?:2[0-3]|[01][0-9]):[0-5][0-9])$')
) {
names.splice(names.indexOf(currentTimezone), 1);
}
assert.notOk(names.includes('Etc/GMT-13'));
assert.notOk(names.includes('Canada/Newfoundland'));
Expand Down

0 comments on commit 9ccc5f1

Please sign in to comment.