Chore: Convert FolderPicker test to rtl (#49838)

This commit is contained in:
Zoltán Bedi 2022-05-30 17:36:16 +02:00 committed by GitHub
parent 0a341812d2
commit f87c1b0eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 26 deletions

View File

@ -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"]
],

View File

@ -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(<FolderPicker onChange={jest.fn()} />);
expect(wrapper).toMatchSnapshot();
render(<FolderPicker onChange={jest.fn()} />);
expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument();
});
});

View File

@ -1,19 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FolderPicker should render 1`] = `
<div
data-testid="data-testid Folder picker select container"
>
<AsyncSelect
allowCustomValue={false}
aria-label="Select a folder"
defaultOptions={true}
defaultValue={null}
loadOptions={[Function]}
loadingMessage="Loading folders..."
onChange={[Function]}
onCreateOption={[Function]}
value={null}
/>
</div>
`;