CloudWatch: Fix broken test (#57879)

* mock date.now

* fix broken test
This commit is contained in:
Erik Sundell 2022-10-31 11:26:43 +01:00 committed by GitHub
parent 19b961465c
commit 92ed9a4f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -572,6 +572,13 @@ describe('CloudWatchMetricsQueryRunner', () => {
});
describe('timezoneUTCOffset', () => {
beforeEach(() => {
jest.useFakeTimers().setSystemTime(new Date('2022-09-01'));
});
afterEach(() => {
jest.useFakeTimers().clearAllTimers();
});
const testQuery = {
id: '',
refId: 'a',
@ -594,7 +601,7 @@ describe('CloudWatchMetricsQueryRunner', () => {
['Asia/Tokyo', '+0900'],
['UTC', '+0000'],
];
describe.each(testTable)('should use the right time zone offset', (ianaTimezone, expectedOffset) => {
test.each(testTable)('should use the right time zone offset', (ianaTimezone, expectedOffset) => {
const { runner, fetchMock, request } = setupMockedMetricsQueryRunner();
runner.handleMetricQueries([testQuery], {
...request,