From f87c1b0eb95551912d13de3f72e7aa32409b3dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Mon, 30 May 2022 17:36:16 +0200 Subject: [PATCH] Chore: Convert FolderPicker test to rtl (#49838) --- .betterer.results | 3 --- .../components/Select/FolderPicker.test.tsx | 10 ++++++---- .../__snapshots__/FolderPicker.test.tsx.snap | 19 ------------------- 3 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 public/app/core/components/Select/__snapshots__/FolderPicker.test.tsx.snap diff --git a/.betterer.results b/.betterer.results index d47c50cd923..7e4d9cdd1b3 100644 --- a/.betterer.results +++ b/.betterer.results @@ -116,9 +116,6 @@ exports[`no enzyme tests`] = { "public/app/core/components/QueryOperationRow/QueryOperationRow.test.tsx:2026575657": [ [0, 26, 13, "RegExp match", "2409514259"] ], - "public/app/core/components/Select/FolderPicker.test.tsx:993468764": [ - [0, 19, 13, "RegExp match", "2409514259"] - ], "public/app/core/components/Select/MetricSelect.test.tsx:3351544014": [ [0, 19, 13, "RegExp match", "2409514259"] ], diff --git a/public/app/core/components/Select/FolderPicker.test.tsx b/public/app/core/components/Select/FolderPicker.test.tsx index 2ccfdc3e467..b36713247da 100644 --- a/public/app/core/components/Select/FolderPicker.test.tsx +++ b/public/app/core/components/Select/FolderPicker.test.tsx @@ -1,6 +1,7 @@ -import { shallow } from 'enzyme'; +import { render, screen } from '@testing-library/react'; import React from 'react'; +import { selectors } from '@grafana/e2e-selectors'; import * as api from 'app/features/manage-dashboards/state/actions'; import { DashboardSearchHit } from '../../../features/search/types'; @@ -8,15 +9,16 @@ import { DashboardSearchHit } from '../../../features/search/types'; import { FolderPicker, getInitialValues } from './FolderPicker'; describe('FolderPicker', () => { - it('should render', () => { + it('should render', async () => { jest .spyOn(api, 'searchFolders') .mockResolvedValue([ { title: 'Dash 1', id: 1 } as DashboardSearchHit, { title: 'Dash 2', id: 2 } as DashboardSearchHit, ]); - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); + + render(); + expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); }); }); diff --git a/public/app/core/components/Select/__snapshots__/FolderPicker.test.tsx.snap b/public/app/core/components/Select/__snapshots__/FolderPicker.test.tsx.snap deleted file mode 100644 index c95c3ac6ac4..00000000000 --- a/public/app/core/components/Select/__snapshots__/FolderPicker.test.tsx.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`FolderPicker should render 1`] = ` -
- -
-`;