Chore: Convert FolderPicker test to rtl (#49838)
This commit is contained in:
@@ -116,9 +116,6 @@ exports[`no enzyme tests`] = {
|
|||||||
"public/app/core/components/QueryOperationRow/QueryOperationRow.test.tsx:2026575657": [
|
"public/app/core/components/QueryOperationRow/QueryOperationRow.test.tsx:2026575657": [
|
||||||
[0, 26, 13, "RegExp match", "2409514259"]
|
[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": [
|
"public/app/core/components/Select/MetricSelect.test.tsx:3351544014": [
|
||||||
[0, 19, 13, "RegExp match", "2409514259"]
|
[0, 19, 13, "RegExp match", "2409514259"]
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { shallow } from 'enzyme';
|
import { render, screen } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import * as api from 'app/features/manage-dashboards/state/actions';
|
import * as api from 'app/features/manage-dashboards/state/actions';
|
||||||
|
|
||||||
import { DashboardSearchHit } from '../../../features/search/types';
|
import { DashboardSearchHit } from '../../../features/search/types';
|
||||||
@@ -8,15 +9,16 @@ import { DashboardSearchHit } from '../../../features/search/types';
|
|||||||
import { FolderPicker, getInitialValues } from './FolderPicker';
|
import { FolderPicker, getInitialValues } from './FolderPicker';
|
||||||
|
|
||||||
describe('FolderPicker', () => {
|
describe('FolderPicker', () => {
|
||||||
it('should render', () => {
|
it('should render', async () => {
|
||||||
jest
|
jest
|
||||||
.spyOn(api, 'searchFolders')
|
.spyOn(api, 'searchFolders')
|
||||||
.mockResolvedValue([
|
.mockResolvedValue([
|
||||||
{ title: 'Dash 1', id: 1 } as DashboardSearchHit,
|
{ title: 'Dash 1', id: 1 } as DashboardSearchHit,
|
||||||
{ title: 'Dash 2', id: 2 } 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();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
|
||||||
`;
|
|
||||||
Reference in New Issue
Block a user