Skip to content

Commit 75097c8

Browse files
test resultPanel
1 parent c8cc9ed commit 75097c8

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed
Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @vitest-environment nuxt
22

33
import { describe, expect, test } from "vitest"
4-
import { mount } from "@vue/test-utils"
4+
import { mountSuspended } from "@nuxt/test-utils/runtime"
55

66
import { createVuetify } from "vuetify"
77
import * as components from "vuetify/components"
@@ -14,43 +14,59 @@ const vuetify = createVuetify({
1414
directives,
1515
})
1616

17-
const inpection_result = [
18-
{
19-
title: "Brep inspection",
20-
nb_issues: 27,
21-
children: [
17+
describe("Inspector/ResultPanel.vue", async () => {
18+
test(`Test with issues`, async () => {
19+
const inspection_result = [
2220
{
23-
title: "Model topology inspection",
24-
nb_issues: 25,
21+
title: "Brep inspection",
22+
nb_issues: 26,
2523
children: [
26-
{ title: "test topology 1", nb_issues: 25 },
27-
{ title: "test topology 2", nb_issues: 0 },
2824
],
2925
},
26+
]
27+
28+
const wrapper = await mountSuspended(InspectorResultPanel, {
29+
global: {
30+
plugins: [vuetify],
31+
},
32+
props: { inspection_result },
33+
})
34+
35+
expect(wrapper.exists()).toBe(true)
36+
expect(wrapper.componentVM.opened_panels._value).toStrictEqual([0])
37+
expect(wrapper.componentVM.props.inspection_result).toStrictEqual(
38+
inspection_result,
39+
)
40+
41+
const child_result_panel_wrapper =
42+
await wrapper.findComponent(InspectorResultPanel)
43+
expect(child_result_panel_wrapper.exists()).toBe(true)
44+
expect(
45+
child_result_panel_wrapper.componentVM.props.inspection_result,
46+
).toStrictEqual(inspection_result[0].children)
47+
})
48+
49+
50+
test(`Test without issues`, async () => {
51+
const inspection_result = [
3052
{
31-
title: "Meshes inspection",
32-
nb_issues: 2,
53+
title: "Brep inspection",
54+
nb_issues: 0,
3355
children: [
34-
{ title: "test meshes 1", nb_issues: 1 },
35-
{ title: "test meshes 2", nb_issues: 1 },
3656
],
3757
},
38-
],
39-
},
40-
]
41-
42-
describe("Inspector/ResultPanel.vue", async () => {
43-
test(`Test render`, async () => {
44-
const wrapper = mount(InspectorResultPanel, {
58+
]
59+
const wrapper = await mountSuspended(InspectorResultPanel, {
4560
global: {
4661
plugins: [vuetify],
4762
},
48-
props: { inpection_result },
63+
props: { inspection_result },
4964
})
5065

51-
const v_expansion_panels = wrapper.findComponent(
52-
components.VExpansionPanels,
66+
expect(wrapper.exists()).toBe(true)
67+
expect(wrapper.componentVM.opened_panels._value).toStrictEqual([])
68+
expect(wrapper.componentVM.props.inspection_result).toStrictEqual(
69+
inspection_result,
5370
)
54-
console.log("v_expansion_panels", v_expansion_panels)
5571
})
5672
})

0 commit comments

Comments
 (0)