Chore: Set timezone for tests to non utc. (#28405)

* Set timezone for tests to non utc.

* Fix comment
This commit is contained in:
Andrej Ocenas 2020-10-20 17:41:47 +02:00 committed by GitHub
parent 0bfdf79968
commit 4169646c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,7 @@
process.env.TZ = 'UTC';
// We set this specifically for 2 reasons.
// 1. It makes sense for both CI tests and local tests to behave the same so issues are found earlier
// 2. Any wrong timezone handling could be hidden if we use UTC/GMT local time (which would happen in CI).
process.env.TZ = 'Pacific/Easter';
module.exports = {
verbose: false,

View File

@ -2,28 +2,25 @@ import { getTimeZoneInfo } from './timezones';
import { setTimeZoneResolver } from './common';
describe('getTimeZoneInfo', () => {
// global timezone is set to UTC, see jest-config.js file
// global timezone is set to Pacific/Easter, see jest-config.js file
describe('IANA canonical name of the timezone', () => {
it('should resolve for default timezone', () => {
setTimeZoneResolver(() => 'browser');
const result = getTimeZoneInfo('', Date.now());
expect(result?.ianaName).toBe('Africa/Abidjan');
expect(result?.ianaName).toBe('Pacific/Easter');
});
it('should resolve for browser timezone', () => {
// global timezone is set to UTC
const result = getTimeZoneInfo('browser', Date.now());
expect(result?.ianaName).toBe('Africa/Abidjan');
expect(result?.ianaName).toBe('Pacific/Easter');
});
it('should resolve for utc timezone', () => {
// global timezone is set to UTC
const result = getTimeZoneInfo('utc', Date.now());
expect(result?.ianaName).toBe('UTC');
});
it('should resolve for given timezone', () => {
// global timezone is set to UTC
const result = getTimeZoneInfo('Europe/Warsaw', Date.now());
expect(result?.ianaName).toBe('Europe/Warsaw');
});