Skip to content

Commit 1922d89

Browse files
committed
Update ActivitySettings test for Vue Test Utils v2
- Use global mount options instead of localVue - Add router to global plugins - Merge getLocalVue() stubs with test-specific stubs
1 parent efb86dc commit 1922d89

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

client/src/components/ActivityBar/ActivitySettings.test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createTestingPinia } from "@pinia/testing";
2-
import { getLocalVue } from "@tests/vitest/helpers";
2+
import { createTestRouter, getLocalVue } from "@tests/vitest/helpers";
33
import { mount } from "@vue/test-utils";
44
import { beforeEach, describe, expect, it, vi } from "vitest";
55
import { nextTick } from "vue";
@@ -10,8 +10,6 @@ import { useActivityStore } from "@/stores/activityStore";
1010

1111
import mountTarget from "./ActivitySettings.vue";
1212

13-
const localVue = getLocalVue();
14-
1513
const { server, http } = useServerMock();
1614
const activityItemSelector = ".activity-settings-item";
1715

@@ -42,6 +40,7 @@ describe("ActivitySettings", () => {
4240

4341
beforeEach(async () => {
4442
const pinia = createTestingPinia({ createSpy: vi.fn, stubActions: false });
43+
const router = createTestRouter();
4544
// Mock the response of the API call
4645
server.use(
4746
http.get("/api/unprivileged_tools", ({ params, query, response }) => {
@@ -50,14 +49,16 @@ describe("ActivitySettings", () => {
5049
);
5150
activityStore = useActivityStore(undefined);
5251
wrapper = mount(mountTarget, {
53-
localVue,
54-
pinia,
52+
global: {
53+
...getLocalVue(),
54+
plugins: [...(getLocalVue().plugins || []), pinia, router],
55+
stubs: {
56+
FontAwesomeIcon: { template: "<div></div>" },
57+
},
58+
},
5559
props: {
5660
query: "",
57-
activityBarId: undefined,
58-
},
59-
stubs: {
60-
FontAwesomeIcon: { template: "<div></div>" },
61+
activityBarId: "test-activity-bar",
6162
},
6263
});
6364
await activityStore.sync();

0 commit comments

Comments
 (0)