mirror of
https://github.com/grafana/grafana.git
synced 2025-01-18 20:43:26 -06:00
Convert FormField
tests to RTL (#49068)
This commit is contained in:
parent
e5925b2e91
commit
bddbed4e21
@ -8,9 +8,6 @@ exports[`no enzyme tests`] = {
|
||||
"packages/grafana-ui/src/components/BarGauge/BarGauge.test.tsx:4199795290": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/FormField/FormField.test.tsx:3429087660": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Forms/Legacy/Input/Input.test.tsx:3129955645": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { FormField, Props } from './FormField';
|
||||
@ -13,26 +13,20 @@ const setup = (propOverrides?: Partial<Props>) => {
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
||||
return shallow(<FormField {...props} />);
|
||||
render(<FormField {...props} />);
|
||||
};
|
||||
|
||||
describe('FormField', () => {
|
||||
it('should render component with default inputEl', () => {
|
||||
const wrapper = setup();
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
it('should render a default inputEl', () => {
|
||||
setup();
|
||||
expect(screen.getByRole('textbox')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render component with custom inputEl', () => {
|
||||
const wrapper = setup({
|
||||
inputEl: (
|
||||
<>
|
||||
<span>Input</span>
|
||||
<button>Ok</button>
|
||||
</>
|
||||
),
|
||||
it('should render a custom inputEl instead if specified', () => {
|
||||
setup({
|
||||
inputEl: <input role="checkbox" />,
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(screen.queryByRole('textbox')).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -1,37 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`FormField should render component with custom inputEl 1`] = `
|
||||
<div
|
||||
className="css-aq4c43"
|
||||
>
|
||||
<FormLabel
|
||||
width={11}
|
||||
>
|
||||
Test
|
||||
</FormLabel>
|
||||
<span>
|
||||
Input
|
||||
</span>
|
||||
<button>
|
||||
Ok
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`FormField should render component with default inputEl 1`] = `
|
||||
<div
|
||||
className="css-aq4c43"
|
||||
>
|
||||
<FormLabel
|
||||
width={11}
|
||||
>
|
||||
Test
|
||||
</FormLabel>
|
||||
<input
|
||||
className="gf-form-input width-12"
|
||||
onChange={[MockFunction]}
|
||||
type="text"
|
||||
value={10}
|
||||
/>
|
||||
</div>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user