Fixed error TS2532 and linted the code.
This commit is contained in:
parent
3ea3811819
commit
7cb80ced42
1 changed files with 22 additions and 19 deletions
|
|
@ -1,52 +1,55 @@
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { createApp } from 'vue';
|
import { createApp } from "vue";
|
||||||
import App from '../src/App.vue';
|
import App from "~/App.vue";
|
||||||
import vuetify from '../src/plugins/vuetify';
|
import vuetify from "~/plugins/vuetify";
|
||||||
import router from '../src/router';
|
import router from "~/router";
|
||||||
|
|
||||||
vi.mock('vue', async () => {
|
vi.mock("vue", async () => {
|
||||||
const actual = await vi.importActual('vue');
|
const actual = await vi.importActual("vue");
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
createApp: vi.fn(),
|
createApp: vi.fn(),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
vi.mock('./assets/main.css', () => ({}));
|
vi.mock("./assets/main.css", () => ({}));
|
||||||
|
|
||||||
vi.mock('./plugins/vuetify', () => ({
|
vi.mock("./plugins/vuetify", () => ({
|
||||||
default: {
|
default: {
|
||||||
install: vi.fn(),
|
install: vi.fn(),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock('./router', () => ({
|
vi.mock("./router", () => ({
|
||||||
default: {
|
default: {
|
||||||
install: vi.fn(),
|
install: vi.fn(),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('main.ts', () => {
|
describe("main.ts", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
document.body.innerHTML = '<div id="app"></div>';
|
document.body.innerHTML = '<div id="app"></div>';
|
||||||
vi.mocked(createApp).mockImplementation(() => ({
|
vi.mocked(createApp).mockImplementation(
|
||||||
|
() =>
|
||||||
|
({
|
||||||
use: vi.fn(),
|
use: vi.fn(),
|
||||||
mount: vi.fn(),
|
mount: vi.fn(),
|
||||||
} as any));
|
}) as any
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates app and uses plugins', async () => {
|
it("creates app and uses plugins", async () => {
|
||||||
await import("../src/main");
|
await import("~/main");
|
||||||
|
|
||||||
expect(createApp).toHaveBeenCalledTimes(1);
|
expect(createApp).toHaveBeenCalledTimes(1);
|
||||||
expect(createApp).toHaveBeenCalledWith(App);
|
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).toHaveBeenCalledTimes(2);
|
||||||
expect(appMock.use).toHaveBeenCalledWith(vuetify);
|
expect(appMock.use).toHaveBeenCalledWith(vuetify);
|
||||||
expect(appMock.use).toHaveBeenCalledWith(router);
|
expect(appMock.use).toHaveBeenCalledWith(router);
|
||||||
|
|
||||||
expect(appMock.mount).toHaveBeenCalledTimes(1);
|
expect(appMock.mount).toHaveBeenCalledTimes(1);
|
||||||
expect(appMock.mount).toHaveBeenCalledWith('#app');
|
expect(appMock.mount).toHaveBeenCalledWith("#app");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue