-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTable.test.tsx
More file actions
71 lines (64 loc) · 1.48 KB
/
Copy pathTable.test.tsx
File metadata and controls
71 lines (64 loc) · 1.48 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { screen } from '@testing-library/react';
import { Column } from 'react-table';
import { vi } from 'vitest';
import { setup } from '../../utils/tests/setup';
import Table from './Table';
type Data = {
id: number;
col1: string;
col2: string;
};
const data: Data[] = [
{
id: 1,
col1: 'col11 value',
col2: 'col21 value',
},
{
id: 2,
col1: 'col12 value',
col2: 'col22 value',
},
{
id: 3,
col1: 'col13 value',
col2: 'col23 value',
},
];
const columns: Column<Data>[] = [
{ accessor: 'id', Header: 'ID' },
{ accessor: 'col1', Header: 'Col1' },
{ accessor: 'col2', Header: 'Col2' },
];
describe('DatatableLight/Table', () => {
afterEach(() => {
vi.resetAllMocks();
});
describe('given isDataLoading', () => {
it('should display empty loading page when no data is present', () => {
setup(
<Table<Data> data={[]} columns={columns} dataSize={0} isDataLoading />,
);
expect(
screen.getByRole('heading', {
name: /Loading/i,
}),
).toBeInTheDocument();
});
it('should display loading overlay without Cancel button when data is present and canceling is disabled', () => {
setup(
<Table<Data>
data={data}
columns={columns}
dataSize={data.length}
isDataLoading
/>,
);
expect(
screen.queryByRole('button', {
name: /Cancel/i,
}),
).not.toBeInTheDocument();
});
});
});