diff --git a/tests/main.spec.ts b/tests/main.spec.ts index e4054c1..7e8461b 100644 --- a/tests/main.spec.ts +++ b/tests/main.spec.ts @@ -1,52 +1,55 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { createApp } from 'vue'; -import App from '../src/App.vue'; -import vuetify from '../src/plugins/vuetify'; -import router from '../src/router'; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { createApp } from "vue"; +import App from "~/App.vue"; +import vuetify from "~/plugins/vuetify"; +import router from "~/router"; -vi.mock('vue', async () => { - const actual = await vi.importActual('vue'); +vi.mock("vue", async () => { + const actual = await vi.importActual("vue"); return { ...actual, createApp: vi.fn(), }; }); -vi.mock('./assets/main.css', () => ({})); +vi.mock("./assets/main.css", () => ({})); -vi.mock('./plugins/vuetify', () => ({ +vi.mock("./plugins/vuetify", () => ({ default: { install: vi.fn(), }, })); -vi.mock('./router', () => ({ +vi.mock("./router", () => ({ default: { install: vi.fn(), }, })); -describe('main.ts', () => { +describe("main.ts", () => { beforeEach(() => { document.body.innerHTML = '
'; - vi.mocked(createApp).mockImplementation(() => ({ - use: vi.fn(), - mount: vi.fn(), - } as any)); + vi.mocked(createApp).mockImplementation( + () => + ({ + use: vi.fn(), + mount: vi.fn(), + }) as any + ); }); - it('creates app and uses plugins', async () => { - await import("../src/main"); + it("creates app and uses plugins", async () => { + await import("~/main"); expect(createApp).toHaveBeenCalledTimes(1); expect(createApp).toHaveBeenCalledWith(App); - const appMock = vi.mocked(createApp).mock.results[0].value; + const appMock = vi.mocked(createApp).mock.results[0]?.value; expect(appMock.use).toHaveBeenCalledTimes(2); expect(appMock.use).toHaveBeenCalledWith(vuetify); expect(appMock.use).toHaveBeenCalledWith(router); expect(appMock.mount).toHaveBeenCalledTimes(1); - expect(appMock.mount).toHaveBeenCalledWith('#app'); + expect(appMock.mount).toHaveBeenCalledWith("#app"); }); });