CloudWatch: Fix broken test (#57879) (#57900)

* mock date.now

* fix broken test

(cherry picked from commit 92ed9a4f2f)

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-10-31 08:16:12 -04:00
committed by GitHub
co-authored by Erik Sundell
parent dac165a7fc
commit 3be1ddc56a
@@ -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,