-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInspectionButton.nuxt.test.js
More file actions
75 lines (66 loc) · 2.21 KB
/
Copy pathInspectionButton.nuxt.test.js
File metadata and controls
75 lines (66 loc) · 2.21 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { describe, expect, test, vi } from "vitest"
import { mountSuspended } from "@nuxt/test-utils/runtime"
import { flushPromises } from "@vue/test-utils"
import * as components from "vuetify/components"
import { setActivePinia } from "pinia"
import { createTestingPinia } from "@pinia/testing"
import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
import InspectorInspectionButton from "@ogw_front/components/Inspector/InspectionButton"
import { useGeodeStore } from "@ogw_front/stores/geode"
import { vuetify } from "../../../utils"
const schema = schemas.opengeodeweb_back.inspect_file
describe("Inspector/InspectionButton", async () => {
const pinia = createTestingPinia({
stubActions: false,
createSpy: vi.fn,
})
setActivePinia(pinia)
const geodeStore = useGeodeStore()
geodeStore.base_url = ""
test(`Test with issues`, async () => {
var inspection_result = {
title: "Brep inspection",
nb_issues: 3,
children: [
{
title: "Brep inspection",
nb_issues: 2,
issues: ["issue 1", "issue 2"],
},
{
title: "Brep inspection",
nb_issues: 1,
issues: ["issue 1"],
},
],
}
geodeStore.request = vi.fn((schema, params, callbacks) => {
if (callbacks?.response_function) {
callbacks.response_function({
_data: { inspection_result },
})
}
return Promise.resolve({
_data: { inspection_result },
})
})
const geode_object_type = "BRep"
const filename = "test.txt"
const wrapper = await mountSuspended(InspectorInspectionButton, {
global: {
plugins: [vuetify, pinia],
},
props: { geode_object_type, filename },
})
expect(wrapper.exists()).toBe(true)
const v_btn = await wrapper.findComponent(components.VBtn)
await v_btn.trigger("click")
await flushPromises()
expect(wrapper.emitted()).toHaveProperty("update_values")
expect(wrapper.emitted().update_values).toHaveLength(1)
expect(wrapper.emitted().update_values[0][0]).toStrictEqual({
inspection_result: [inspection_result],
})
expect(wrapper.emitted()).toHaveProperty("increment_step")
})
})