From fb17b9f5454a981156b7f8ac8f1966d398998a9f Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Thu, 17 Mar 2022 07:00:42 -0700 Subject: [PATCH] Chore: clean up console warning from Annotation Query Editor tests (#46660) --- .../components/AnnotationQueryEditor.test.tsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/public/app/plugins/datasource/cloudwatch/components/AnnotationQueryEditor.test.tsx b/public/app/plugins/datasource/cloudwatch/components/AnnotationQueryEditor.test.tsx index 8d8ffc62283..ea0fec67e6d 100644 --- a/public/app/plugins/datasource/cloudwatch/components/AnnotationQueryEditor.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/AnnotationQueryEditor.test.tsx @@ -1,10 +1,9 @@ import React from 'react'; import '@testing-library/jest-dom'; -import { cleanup, render, screen, waitFor } from '@testing-library/react'; +import { render, screen, waitFor } from '@testing-library/react'; import { setupMockedDataSource } from '../__mocks__/CloudWatchDataSource'; import { CloudWatchAnnotationQuery } from '../types'; import { AnnotationQueryEditor } from './AnnotationQueryEditor'; -import { act } from 'react-dom/test-utils'; const ds = setupMockedDataSource({ variables: [], @@ -43,15 +42,15 @@ const props = { onRunQuery: jest.fn(), }; -afterEach(cleanup); - describe('AnnotationQueryEditor', () => { - it('should not display match exact switch', () => { + it('should not display match exact switch', async () => { render(); - expect(screen.queryByText('Match exact')).toBeNull(); + await waitFor(() => { + expect(screen.queryByText('Match exact')).toBeNull(); + }); }); - it('shoud not display wildcard option in dimension value dropdown', async () => { + it('should not display wildcard option in dimension value dropdown', async () => { ds.datasource.getDimensionValues = jest.fn().mockResolvedValue([[{ label: 'dimVal1', value: 'dimVal1' }]]); props.query.dimensions = { instanceId: 'instance-123' }; render(); @@ -59,11 +58,9 @@ describe('AnnotationQueryEditor', () => { const valueElement = screen.getByText('instance-123'); expect(valueElement).toBeInTheDocument(); expect(screen.queryByText('*')).toBeNull(); - act(async () => { - await valueElement.click(); - await waitFor(() => { - expect(screen.queryByText('*')).toBeNull(); - }); + valueElement.click(); + await waitFor(() => { + expect(screen.queryByText('*')).toBeNull(); }); }); });