From 50bbbbf376bfcf1893faf1b6a595b2b9a86b5d6f Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Thu, 17 Mar 2022 06:55:14 -0700 Subject: [PATCH] Chore: clean up console warning from Resource Picker tests (#46664) --- .../ResourcePicker/ResourcePicker.test.tsx | 90 +++++++++---------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/ResourcePicker/ResourcePicker.test.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/ResourcePicker/ResourcePicker.test.tsx index 1e9a97aec58..e78c2ef1834 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/ResourcePicker/ResourcePicker.test.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/ResourcePicker/ResourcePicker.test.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import React from 'react'; import ResourcePicker from '.'; @@ -28,19 +28,17 @@ describe('AzureMonitor ResourcePicker', () => { getResourceGroupsBySubscriptionId: jest.fn(), getResourcesForResourceGroup: jest.fn(), }); - await act(() => { - render( - - ); - }); + render( + + ); - await waitFor(() => expect(screen.getByText('Primary Subscription')).toBeInTheDocument()); + expect(await screen.findByText('Primary Subscription')).toBeInTheDocument(); expect(resourePickerDataMock.getSubscriptions).toHaveBeenCalledTimes(1); expect(resourePickerDataMock.getResourceGroupsBySubscriptionId).not.toHaveBeenCalled(); expect(resourePickerDataMock.getResourcesForResourceGroup).not.toHaveBeenCalled(); @@ -54,19 +52,17 @@ describe('AzureMonitor ResourcePicker', () => { getResourceGroupsBySubscriptionId: jest.fn(), getResourcesForResourceGroup: jest.fn(), }); - await act(async () => { - render( - - ); - }); + render( + + ); - await waitFor(() => expect(screen.getByText('Primary Subscription')).toBeInTheDocument()); + expect(await screen.findByText('Primary Subscription')).toBeInTheDocument(); expect(resourePickerDataMock.getSubscriptions).toHaveBeenCalledTimes(1); expect(resourePickerDataMock.getResourceGroupsBySubscriptionId).not.toHaveBeenCalled(); expect(resourePickerDataMock.getResourcesForResourceGroup).not.toHaveBeenCalled(); @@ -80,19 +76,17 @@ describe('AzureMonitor ResourcePicker', () => { getResourceGroupsBySubscriptionId: jest.fn().mockResolvedValue(createMockResourceGroupsBySubscription()), getResourcesForResourceGroup: jest.fn(), }); - await act(async () => { - render( - - ); - }); + render( + + ); - await waitFor(() => expect(screen.getByText('Primary Subscription')).toBeInTheDocument()); + expect(await screen.findByText('Primary Subscription')).toBeInTheDocument(); expect(resourePickerDataMock.getSubscriptions).toHaveBeenCalledTimes(1); expect(resourePickerDataMock.getResourceGroupsBySubscriptionId).toHaveBeenCalledTimes(1); expect(resourePickerDataMock.getResourceGroupsBySubscriptionId).toHaveBeenLastCalledWith( @@ -109,19 +103,17 @@ describe('AzureMonitor ResourcePicker', () => { getResourceGroupsBySubscriptionId: jest.fn().mockResolvedValue(createMockResourceGroupsBySubscription()), getResourcesForResourceGroup: jest.fn().mockResolvedValue(mockResourcesByResourceGroup()), }); - await act(async () => { - render( - - ); - }); + render( + + ); - await waitFor(() => expect(screen.getByText('Primary Subscription')).toBeInTheDocument()); + expect(await screen.findByText('Primary Subscription')).toBeInTheDocument(); expect(resourePickerDataMock.getSubscriptions).toHaveBeenCalledTimes(1); expect(resourePickerDataMock.getResourceGroupsBySubscriptionId).toHaveBeenCalledTimes(1); expect(resourePickerDataMock.getResourceGroupsBySubscriptionId).toHaveBeenLastCalledWith(