Skip to content

Commit 4a2716f

Browse files
authored
Merge pull request #1509 from Py4Js/fix-tests
Added tests to PyBox
2 parents 341ec5b + 6db8551 commit 4a2716f

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`PyBox check if match snapshots with alpha pyscript provider 1`] = `
4+
<div>
5+
<py-box
6+
widths="2/3;1/6;1/6"
7+
>
8+
<div
9+
data-testid="first-element"
10+
>
11+
first
12+
</div>
13+
<div
14+
data-testid="second-element"
15+
>
16+
second
17+
</div>
18+
<div
19+
data-testid="third-element"
20+
>
21+
third
22+
</div>
23+
</py-box>
24+
</div>
25+
`;
26+
27+
exports[`PyBox check if match snapshots with set width 1`] = `
28+
<div>
29+
<py-box
30+
widths="2/3;1/6;1/6"
31+
>
32+
<div
33+
data-testid="first-element"
34+
>
35+
first
36+
</div>
37+
<div
38+
data-testid="second-element"
39+
>
40+
second
41+
</div>
42+
<div
43+
data-testid="third-element"
44+
>
45+
third
46+
</div>
47+
</py-box>
48+
</div>
49+
`;
50+
51+
exports[`PyBox check if match snapshots without pyscript provider 1`] = `
52+
<div>
53+
<py-box />
54+
</div>
55+
`;
56+
57+
exports[`PyBox ensure that PyBox doesn't work with latest pyscript provider 1`] = `
58+
<div>
59+
<py-box>
60+
<div
61+
data-testid="first-element"
62+
>
63+
first
64+
</div>
65+
<div
66+
data-testid="second-element"
67+
>
68+
second
69+
</div>
70+
<div
71+
data-testid="third-element"
72+
>
73+
third
74+
</div>
75+
</py-box>
76+
</div>
77+
`;

source/library/components/py-box/py-box.story.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ PyBoxWithMultipleElementsExample.args = {
2929
<div key="element-2">Second element</div>,
3030
<div key="element-3">Third element</div>,
3131
],
32+
widths: "2/3;1/6;1/6",
3233
};
3334

3435
export const PyBoxWithSingleElementExample: StoryFn<typeof PyBox> =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { render } from "@testing-library/react";
2+
import PyScriptProvider from "../py-script-provider";
3+
import PyBox from "./py-box";
4+
5+
const children = [
6+
<div data-testid="first-element" key="first-element">
7+
first
8+
</div>,
9+
<div data-testid="second-element" key="second-element">
10+
second
11+
</div>,
12+
<div data-testid="third-element" key="third-element">
13+
third
14+
</div>,
15+
];
16+
describe("PyBox", () => {
17+
it("check if match snapshots without pyscript provider", () => {
18+
const { container } = render(<PyBox />);
19+
expect(container).toMatchSnapshot();
20+
});
21+
it("check if match snapshots with alpha pyscript provider", () => {
22+
const { container } = render(
23+
<PyScriptProvider
24+
jsSource="https://pyscript.net/alpha/pyscript.js"
25+
cssSource="https://pyscript.net/alpha/pyscript.css"
26+
>
27+
<PyBox widths="2/3;1/6;1/6" children={children} />
28+
</PyScriptProvider>,
29+
);
30+
expect(container).toMatchSnapshot();
31+
});
32+
it("ensure that PyBox doesn't work with latest pyscript provider ", () => {
33+
const { container } = render(
34+
<PyScriptProvider>
35+
<PyBox children={children} />
36+
</PyScriptProvider>,
37+
);
38+
expect(container).toMatchSnapshot();
39+
});
40+
});

0 commit comments

Comments
 (0)