-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathbasicGrid.test.tsx
More file actions
54 lines (45 loc) · 1.08 KB
/
basicGrid.test.tsx
File metadata and controls
54 lines (45 loc) · 1.08 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
import { page } from 'vitest/browser';
import { DataGrid, SelectColumn, type Column } from '../../src';
import { getGrid } from '../browser/utils';
interface Row {
id: number;
name: string;
}
const columns: readonly Column<Row, Row>[] = [
SelectColumn,
{
key: 'name',
name: 'Name',
renderSummaryCell(props) {
return props.row.name;
}
}
];
const rows: readonly Row[] = [
{ id: 1, name: 'Row 1' },
{ id: 2, name: 'Row 2' },
{ id: 3, name: 'Row 3' }
];
const topSummaryRows: readonly Row[] = [
{ id: 4, name: 'Top Summary Row 1' },
{ id: 5, name: 'Top Summary Row 2' }
];
const bottomSummaryRows: readonly Row[] = [
{ id: 6, name: 'Bottom Summary Row 1' },
{ id: 7, name: 'Bottom Summary Row 2' }
];
function rowKeyGetter(row: Row) {
return row.id;
}
test('basic grid', async () => {
await page.render(
<DataGrid
rowKeyGetter={rowKeyGetter}
columns={columns}
rows={rows}
topSummaryRows={topSummaryRows}
bottomSummaryRows={bottomSummaryRows}
/>
);
await expect(getGrid()).toMatchScreenshot('basic-grid');
});