forked from patternfly/react-component-groups
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkeletonTableHead.test.tsx
More file actions
35 lines (30 loc) · 1.21 KB
/
Copy pathSkeletonTableHead.test.tsx
File metadata and controls
35 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { render } from '@testing-library/react';
import SkeletonTableHead from './SkeletonTableHead';
import { Table, Th } from '@patternfly/react-table';
describe('SkeletonTableHead component', () => {
it('should render correctly with count', () => {
expect(render(<Table><SkeletonTableHead columnsCount={2} isSelectable isExpandable /></Table>)).toMatchSnapshot();
});
it('should render correctly with string columns', () => {
expect(render(<Table><SkeletonTableHead columns={[ 'First', 'Second' ]} isTreeTable isSelectable /></Table>)).toMatchSnapshot();
});
it('should render correctly with Th element columns without nesting', () => {
const { container } = render(
<Table>
<SkeletonTableHead
columns={[
<Th key="1" sort={{ columnIndex: 0, sortBy: {} }}>First</Th>,
<Th key="2" sort={{ columnIndex: 1, sortBy: {} }}>Second</Th>
]}
/>
</Table>
);
// Ensure there are no nested <th> elements
const theadCells = container.querySelectorAll('thead th');
theadCells.forEach(th => {
const nestedTh = th.querySelector('th');
expect(nestedTh).toBeNull();
});
expect(container).toMatchSnapshot();
});
});