|
| 1 | +import { render } from '@shared/tests'; |
1 | 2 | import { createPassThroughPropsTest } from '@shared/tests/utils';
|
2 |
| -import { mount } from 'enzyme'; |
3 | 3 | import { Text } from '@ui5/webcomponents-react/lib/Text';
|
4 | 4 | import React from 'react';
|
5 | 5 |
|
6 | 6 | describe('Text', () => {
|
7 | 7 | test('Render Basic Text', () => {
|
8 |
| - const wrapper = mount(<Text>FioriText</Text>); |
9 |
| - expect(wrapper.render()).toMatchSnapshot(); |
| 8 | + const { asFragment } = render(<Text>FioriText</Text>); |
| 9 | + expect(asFragment()).toMatchSnapshot(); |
10 | 10 | });
|
11 | 11 |
|
12 | 12 | test('No Wrap', () => {
|
13 |
| - const wrapper = mount(<Text wrapping={false}>Lorem Ipsum dolor sit amed</Text>); |
14 |
| - expect(wrapper.render()).toMatchSnapshot(); |
| 13 | + const { asFragment } = render(<Text wrapping={false}>Lorem Ipsum dolor sit amed</Text>); |
| 14 | + expect(asFragment()).toMatchSnapshot(); |
15 | 15 | });
|
16 | 16 |
|
17 | 17 | test('Render Whitespace', () => {
|
18 |
| - const wrapper = mount(<Text renderWhitespace>Lorem Ipsum dolor sit amed</Text>); |
19 |
| - expect(wrapper.render()).toMatchSnapshot(); |
| 18 | + const { asFragment } = render(<Text renderWhitespace>Lorem Ipsum dolor sit amed</Text>); |
| 19 | + expect(asFragment()).toMatchSnapshot(); |
20 | 20 | });
|
21 | 21 |
|
22 | 22 | test('Renders correct Text', () => {
|
23 | 23 | const el = 'My Text';
|
24 |
| - const wrapper = mount(<Text>{el}</Text>); |
25 |
| - expect(wrapper.text()).toEqual(el); |
| 24 | + const { container } = render(<Text>{el}</Text>); |
| 25 | + expect(container).toHaveTextContent(el); |
26 | 26 | });
|
27 | 27 |
|
28 | 28 | test('custom width', () => {
|
29 |
| - const wrapper = mount(<Text style={{ width: '300px' }}>Test</Text>); |
30 |
| - expect(window.getComputedStyle(wrapper.getDOMNode()).width).toEqual('300px'); |
| 29 | + const { getByText } = render(<Text style={{ width: '300px' }}>Test</Text>); |
| 30 | + expect(getByText('Test')).toHaveStyle({ |
| 31 | + width: '300px' |
| 32 | + }); |
31 | 33 | });
|
32 | 34 |
|
33 | 35 | createPassThroughPropsTest(Text);
|
|
0 commit comments