|
1 | 1 | import { flushPromises, mount, VueWrapper } from "@vue/test-utils"; |
2 | 2 | import { createVuetify } from "vuetify"; |
3 | 3 | import MockAdapter from "axios-mock-adapter"; |
4 | | -import { expect, describe, it, beforeEach } from "vitest"; |
| 4 | +import { expect, describe, it, beforeEach, afterEach } from "vitest"; |
5 | 5 | import { createPinia, setActivePinia } from "pinia"; |
6 | 6 | import TagSelector from "@/components/Tags/TagSelector.vue"; |
7 | 7 | import { router } from "@/router"; |
@@ -43,31 +43,22 @@ describe("Tag Selector", () => { |
43 | 43 | }); |
44 | 44 | }); |
45 | 45 |
|
46 | | - it("Is a Vue instance", () => { |
47 | | - expect(wrapper.vm).toBeTruthy(); |
| 46 | + afterEach(async () => { |
| 47 | + await flushPromises(); |
| 48 | + wrapper.unmount(); |
48 | 49 | }); |
49 | 50 |
|
50 | 51 | it("Renders the component", () => { |
51 | 52 | expect(wrapper.html()).toMatchSnapshot(); |
52 | 53 | }); |
53 | 54 |
|
54 | | - it("Data is defined", () => { |
55 | | - expect(wrapper.vm.$data).toBeDefined(); |
56 | | - }); |
57 | | - |
58 | 55 | it("Renders components", () => { |
59 | 56 | expect(wrapper.findComponent('[data-test="tags-btn"]').exists()).toBe(true); |
60 | 57 | }); |
61 | 58 |
|
62 | 59 | it("Successfully loads tags", async () => { |
63 | | - mockTagsApi |
64 | | - .onGet("http://localhost:3000/api/namespaces/fake-tenant-data/tags?filter=&page=1&per_page=10") |
65 | | - .reply(200, tags); |
66 | | - |
67 | 60 | await wrapper.findComponent('[data-test="tags-btn"]').trigger("click"); |
68 | | - |
69 | 61 | await flushPromises(); |
70 | | - |
71 | 62 | expect(wrapper.vm.fetchedTags).toEqual(tags); |
72 | 63 | }); |
73 | 64 | }); |
0 commit comments