From 7106106e3b07711df3945a7f5bf16f6998bbec2a Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 25 May 2022 08:21:18 -0400 Subject: [PATCH] Chore: Convert a test from enzyme to testing library (#49492) (#49576) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit f93ad85b0892a851ef70e8457e568eee6e134639) Co-authored-by: Piotr Jamróz --- .betterer.results | 3 --- .../RichHistory/RichHistoryStarredTab.test.tsx | 18 +++++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.betterer.results b/.betterer.results index 59543858a39..14981d93b13 100644 --- a/.betterer.results +++ b/.betterer.results @@ -173,9 +173,6 @@ exports[`no enzyme tests`] = { "public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx:4164297658": [ [0, 17, 13, "RegExp match", "2409514259"] ], - "public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx:523695501": [ - [0, 17, 13, "RegExp match", "2409514259"] - ], "public/app/features/folders/FolderSettingsPage.test.tsx:1109052730": [ [0, 19, 13, "RegExp match", "2409514259"] ], diff --git a/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx b/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx index e0434713f69..4cedf1e8e8f 100644 --- a/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx @@ -1,4 +1,4 @@ -import { mount } from 'enzyme'; +import { render } from '@testing-library/react'; import React from 'react'; import { SortOrder } from 'app/core/utils/richHistory'; @@ -44,27 +44,27 @@ const setup = (activeDatasourceOnly = false) => { }, }; - const wrapper = mount(); - return wrapper; + const container = render(); + return container; }; describe('RichHistoryStarredTab', () => { describe('sorter', () => { it('should render sorter', () => { - const wrapper = setup(); - expect(wrapper.find({ 'aria-label': 'Sort queries' })).toHaveLength(1); + const container = setup(); + expect(container.queryByLabelText('Sort queries')).toBeInTheDocument(); }); }); describe('select datasource', () => { it('should render select datasource if activeDatasourceOnly is false', () => { - const wrapper = setup(); - expect(wrapper.find({ 'aria-label': 'Filter queries for data sources(s)' }).exists()).toBeTruthy(); + const container = setup(); + expect(container.queryByLabelText('Filter queries for data sources(s)')).toBeInTheDocument(); }); it('should not render select datasource if activeDatasourceOnly is true', () => { - const wrapper = setup(true); - expect(wrapper.find({ 'aria-label': 'Filter queries for data sources(s)' }).exists()).toBeFalsy(); + const container = setup(true); + expect(container.queryByLabelText('Filter queries for data sources(s)')).not.toBeInTheDocument(); }); }); });