Debian Codegraph @

node/@patternfly/react-table/src/components/Table/__tests__/Tr.test.tsx

raw
1 import { render, screen } from '@testing-library/react';
2 import { Tr } from '../Tr';
3 import styles from '@patternfly/react-styles/css/components/Table/table';
4
5 test('Renders without children', () => {
6 render(
7 <table>
8 <tbody>
9 <Tr />
10 </tbody>
11 </table>
12 );
13
14 expect(screen.getByRole('row')).toBeInTheDocument();
15 });
16
17 test('Renders with children', () => {
18 render(
19 <table>
20 <tbody>
21 <Tr>
22 <td>Row content</td>
23 </Tr>
24 </tbody>
25 </table>
26 );
27
28 expect(screen.getByRole('row')).toHaveTextContent('Row content');
29 });
30
31 test(`Does not render as hidden by default`, () => {
32 render(
33 <table>
34 <tbody>
35 <Tr />
36 </tbody>
37 </table>
38 );
39
40 expect(screen.getByRole('row')).not.toHaveAttribute('hidden');
41 });
42
43 test(`Renders as hidden when isHidden is true`, () => {
44 render(
45 <table>
46 <tbody>
47 <Tr isHidden />
48 </tbody>
49 </table>
50 );
51
52 expect(screen.queryByRole('row')).not.toBeInTheDocument();
53 });
54
55 test('Matches snapshot without children', () => {
56 const { asFragment } = render(
57 <table>
58 <tbody>
59 <Tr />
60 </tbody>
61 </table>
62 );
63
64 expect(asFragment()).toMatchSnapshot();
65 });
66
67 test('Matches snapshot with children', () => {
68 const { asFragment } = render(
69 <table>
70 <tbody>
71 <Tr>
72 <td>Row content</td>
73 </Tr>
74 </tbody>
75 </table>
76 );
77
78 expect(asFragment()).toMatchSnapshot();
79 });