Chore: Convert a test from enzyme to testing library (#49492)

This commit is contained in:
Piotr Jamróz 2022-05-25 12:19:51 +02:00 committed by GitHub
parent 5557d2e666
commit f93ad85b08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -173,9 +173,6 @@ exports[`no enzyme tests`] = {
"public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx:4164297658": [ "public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx:4164297658": [
[0, 17, 13, "RegExp match", "2409514259"] [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": [ "public/app/features/folders/FolderSettingsPage.test.tsx:1109052730": [
[0, 19, 13, "RegExp match", "2409514259"] [0, 19, 13, "RegExp match", "2409514259"]
], ],

View File

@ -1,4 +1,4 @@
import { mount } from 'enzyme'; import { render } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { SortOrder } from 'app/core/utils/richHistory'; import { SortOrder } from 'app/core/utils/richHistory';
@ -44,27 +44,27 @@ const setup = (activeDatasourceOnly = false) => {
}, },
}; };
const wrapper = mount(<RichHistoryStarredTab {...props} />); const container = render(<RichHistoryStarredTab {...props} />);
return wrapper; return container;
}; };
describe('RichHistoryStarredTab', () => { describe('RichHistoryStarredTab', () => {
describe('sorter', () => { describe('sorter', () => {
it('should render sorter', () => { it('should render sorter', () => {
const wrapper = setup(); const container = setup();
expect(wrapper.find({ 'aria-label': 'Sort queries' })).toHaveLength(1); expect(container.queryByLabelText('Sort queries')).toBeInTheDocument();
}); });
}); });
describe('select datasource', () => { describe('select datasource', () => {
it('should render select datasource if activeDatasourceOnly is false', () => { it('should render select datasource if activeDatasourceOnly is false', () => {
const wrapper = setup(); const container = setup();
expect(wrapper.find({ 'aria-label': 'Filter queries for data sources(s)' }).exists()).toBeTruthy(); expect(container.queryByLabelText('Filter queries for data sources(s)')).toBeInTheDocument();
}); });
it('should not render select datasource if activeDatasourceOnly is true', () => { it('should not render select datasource if activeDatasourceOnly is true', () => {
const wrapper = setup(true); const container = setup(true);
expect(wrapper.find({ 'aria-label': 'Filter queries for data sources(s)' }).exists()).toBeFalsy(); expect(container.queryByLabelText('Filter queries for data sources(s)')).not.toBeInTheDocument();
}); });
}); });
}); });