CloudWatch: Fix broken test (#57879)

* mock date.now

* fix broken test
pull/57817/head^2
Erik Sundell 3 years ago committed by GitHub
parent 19b961465c
commit 92ed9a4f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchMetricsQueryRunner.test.ts

@ -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,

Loading…
Cancel
Save