Skip to content

Commit 180dbec

Browse files
committed
test: add grid component test
1 parent 9c080c7 commit 180dbec

File tree

4 files changed

+78
-22
lines changed

4 files changed

+78
-22
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@codemirror/state": "^6.5.2",
5050
"@codemirror/view": "^6.38.1",
5151
"@mendix/pluggable-widgets-tools": "10.21.2",
52+
"@testing-library/react": ">=15.0.6",
5253
"@types/big.js": "^6.2.2",
5354
"@types/node": "~22.14.0",
5455
"@types/react": ">=18.2.36",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { render } from "@testing-library/react";
2+
import { ContainerProvider } from "brandi-react";
3+
import { createDatagridContainer } from "../../model/containers/createDatagridContainer";
4+
import { mockContainerProps } from "../../utils/test-utils";
5+
import { Grid } from "../Grid";
6+
7+
describe("Grid", () => {
8+
it("renders without crashing", () => {
9+
const props = mockContainerProps();
10+
const [container] = createDatagridContainer(props);
11+
const { asFragment } = render(
12+
<ContainerProvider container={container}>
13+
<Grid>Test</Grid>
14+
</ContainerProvider>
15+
);
16+
17+
expect(asFragment()).toMatchSnapshot();
18+
});
19+
20+
it("renders without selector column", () => {
21+
const [container] = createDatagridContainer({
22+
...mockContainerProps(),
23+
columnsHidable: false
24+
});
25+
const { asFragment } = render(
26+
<ContainerProvider container={container}>
27+
<Grid>Test</Grid>
28+
</ContainerProvider>
29+
);
30+
31+
expect(asFragment()).toMatchSnapshot();
32+
});
33+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Grid renders without crashing 1`] = `
4+
<DocumentFragment>
5+
<div
6+
class="widget-datagrid-grid table"
7+
role="grid"
8+
style="grid-template-columns: 1fr 1fr 54px;"
9+
>
10+
Test
11+
</div>
12+
</DocumentFragment>
13+
`;
14+
15+
exports[`Grid renders without selector column 1`] = `
16+
<DocumentFragment>
17+
<div
18+
class="widget-datagrid-grid table"
19+
role="grid"
20+
style="grid-template-columns: 1fr 1fr;"
21+
>
22+
Test
23+
</div>
24+
</DocumentFragment>
25+
`;

pnpm-lock.yaml

Lines changed: 19 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)