Skip to content

Commit c7f1492

Browse files
authored
test(Form): rewrite test using react-testing-library (#821)
[ci skip]
1 parent 4340cf6 commit c7f1492

File tree

2 files changed

+456
-397
lines changed

2 files changed

+456
-397
lines changed

packages/main/src/components/Form/Form.test.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { render } from '@shared/tests';
12
import { createPassThroughPropsTest } from '@shared/tests/utils';
2-
import { mount } from 'enzyme';
33
import { Form } from '@ui5/webcomponents-react/lib/Form';
44
import { FormGroup } from '@ui5/webcomponents-react/lib/FormGroup';
55
import { FormItem } from '@ui5/webcomponents-react/lib/FormItem';
@@ -36,26 +36,26 @@ const component = (
3636
describe('Create a Form', () => {
3737
test('size rate S; should create Label and Element with 100% width and display: block for top FormItem div', () => {
3838
window = Object.assign(window, { innerWidth: SIZE_S });
39-
const wrapper = mount(component);
40-
expect(wrapper.render()).toMatchSnapshot();
39+
const { asFragment } = render(component);
40+
expect(asFragment()).toMatchSnapshot();
4141
});
4242

4343
test('size rate M; should create Label and Element with 16% and 83% width respectively and display: flex for top FormItem div', () => {
4444
window = Object.assign(window, { innerWidth: SIZE_M });
45-
const wrapper = mount(component);
46-
expect(wrapper.render()).toMatchSnapshot();
45+
const { asFragment } = render(component);
46+
expect(asFragment()).toMatchSnapshot();
4747
});
4848

4949
test('size rate L; should create Label and Element with 33% and 66% width respectively and display: flex for top FormItem div', () => {
5050
window = Object.assign(window, { innerWidth: SIZE_L });
51-
const wrapper = mount(component);
52-
expect(wrapper.render()).toMatchSnapshot();
51+
const { asFragment } = render(component);
52+
expect(asFragment()).toMatchSnapshot();
5353
});
5454

5555
test('size rate XL; should create Label and Element with 33% and 66% width respectively and display: flex for top FormItem div', () => {
5656
window = Object.assign(window, { innerWidth: SIZE_XL });
57-
const wrapper = mount(component);
58-
expect(wrapper.render()).toMatchSnapshot();
57+
const { asFragment } = render(component);
58+
expect(asFragment()).toMatchSnapshot();
5959
});
6060

6161
test("should use a single FormGroup's title as a Form title if one is not set", () => {
@@ -71,8 +71,8 @@ describe('Create a Form', () => {
7171
</FormGroup>
7272
</Form>
7373
);
74-
const wrapper = mount(ungroupedChildren);
75-
expect(wrapper.render()).toMatchSnapshot();
74+
const { asFragment } = render(ungroupedChildren);
75+
expect(asFragment()).toMatchSnapshot();
7676
});
7777

7878
createPassThroughPropsTest(Form, {

0 commit comments

Comments
 (0)