Skip to content

Commit 717bdf1

Browse files
committed
add vue wrapper
1 parent c2ba7c0 commit 717bdf1

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

apps/vue-starter/tests/Forms.spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { expect, test } from "vitest";
22
import { render } from "vitest-browser-vue";
33
import Forms from "./../src/pages/forms/FormsPage.vue";
4+
import Wrapper from "./Wrapper";
45

56
test("renders forms page", async () => {
6-
const { getByText, getByRole } = await render(Forms);
7+
const { getByText, getByRole } = await render(Wrapper, {
8+
props: { component: Forms },
9+
});
710

811
await expect.element(getByText("Forms")).toBeInTheDocument();
912
await expect
@@ -12,7 +15,9 @@ test("renders forms page", async () => {
1215
});
1316

1417
test("selects an inspection type and sets the select value", async () => {
15-
const { getByLabelText, getByRole } = await render(Forms);
18+
const { getByLabelText, getByRole } = await render(Wrapper, {
19+
props: { component: Forms },
20+
});
1621

1722
const inspectionType = getByLabelText("Inspection Type");
1823
await inspectionType.click();
@@ -22,7 +27,9 @@ test("selects an inspection type and sets the select value", async () => {
2227
});
2328

2429
test("changes the inspection mode radio button", async () => {
25-
const { getByRole } = await render(Forms);
30+
const { getByRole } = await render(Wrapper, {
31+
props: { component: Forms },
32+
});
2633

2734
const offlineSampling = getByRole("radio", { name: "Offline sampling" });
2835
await offlineSampling.click();

apps/vue-starter/tests/Wrapper.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import "@siemens/ix/dist/siemens-ix/siemens-ix.css";
2+
import { defineComponent, h, toRaw, type Component, type PropType } from "vue";
3+
4+
function setIxThemeAttributes() {
5+
if (typeof document === "undefined") {
6+
return;
7+
}
8+
9+
document.documentElement.setAttribute("data-ix-theme", "classic");
10+
document.documentElement.setAttribute("data-ix-color-schema", "dark");
11+
}
12+
13+
setIxThemeAttributes();
14+
15+
export default defineComponent({
16+
name: "Wrapper",
17+
props: {
18+
component: {
19+
type: Object as PropType<Component>,
20+
required: true,
21+
},
22+
},
23+
setup(props) {
24+
setIxThemeAttributes();
25+
26+
return () => h(toRaw(props.component));
27+
},
28+
});

0 commit comments

Comments
 (0)