Skip to content

Commit f80b990

Browse files
Label (v8): convert tests to use testing-library (#22211)
1 parent f10cc04 commit f80b990

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

packages/react/src/components/Label/Label.test.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import * as React from 'react';
2-
import { mount } from 'enzyme';
3-
import * as renderer from 'react-test-renderer';
2+
import { render } from '@testing-library/react';
43
import { isConformant } from '../../common/isConformant';
54
import { Label } from './Label';
65

76
describe('Label', () => {
87
it('renders a label', () => {
9-
const label = mount(<Label>test</Label>);
10-
expect(label.text()).toEqual('test');
8+
const { container } = render(<Label>test</Label>);
9+
const label = container.querySelector('label');
10+
expect(label!.textContent).toEqual('test');
1111
});
1212

1313
it('renders label correctly', () => {
14-
const component = renderer.create(<Label>test</Label>);
15-
const tree = component.toJSON();
16-
expect(tree).toMatchSnapshot();
14+
const { container } = render(<Label>test</Label>);
15+
expect(container).toMatchSnapshot();
1716
});
1817

1918
isConformant({
Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Label renders label correctly 1`] = `
4-
<label
5-
className=
6-
ms-Label
7-
{
8-
-moz-osx-font-smoothing: grayscale;
9-
-webkit-font-smoothing: antialiased;
10-
box-shadow: none;
11-
box-sizing: border-box;
12-
color: #323130;
13-
display: block;
14-
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
15-
font-size: 14px;
16-
font-weight: 600;
17-
margin-bottom: 0px;
18-
margin-left: 0px;
19-
margin-right: 0px;
20-
margin-top: 0px;
21-
overflow-wrap: break-word;
22-
padding-bottom: 5px;
23-
padding-left: 0;
24-
padding-right: 0;
25-
padding-top: 5px;
26-
word-wrap: break-word;
27-
}
28-
>
29-
test
30-
</label>
4+
<div>
5+
<label
6+
class=
7+
ms-Label
8+
{
9+
-moz-osx-font-smoothing: grayscale;
10+
-webkit-font-smoothing: antialiased;
11+
box-shadow: none;
12+
box-sizing: border-box;
13+
color: #323130;
14+
display: block;
15+
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
16+
font-size: 14px;
17+
font-weight: 600;
18+
margin-bottom: 0px;
19+
margin-left: 0px;
20+
margin-right: 0px;
21+
margin-top: 0px;
22+
overflow-wrap: break-word;
23+
padding-bottom: 5px;
24+
padding-left: 0;
25+
padding-right: 0;
26+
padding-top: 5px;
27+
word-wrap: break-word;
28+
}
29+
>
30+
test
31+
</label>
32+
</div>
3133
`;

0 commit comments

Comments
 (0)