-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* studio, web - coverage thresholds * studio - unit tests fixed
- Loading branch information
1 parent
9d6e815
commit 28ff1cc
Showing
6 changed files
with
51 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,20 @@ | ||
import { describe, it, expect, beforeEach } from "vitest"; | ||
import { createRouter, createWebHistory } from "vue-router"; | ||
import { mount } from "@vue/test-utils"; | ||
import { describe, it, expect } from "vitest"; | ||
import { createRoutes } from "@/router/routes"; | ||
import HomeView from "@/views/HomeView.vue"; | ||
import AboutView from "@/views/HomeView.vue"; | ||
import LoginView from "@/views/LoginView.vue"; | ||
import App from "@/App.vue"; | ||
|
||
const setupTest = async (path: string) => { | ||
const router = createRouter({ | ||
history: createWebHistory(), | ||
routes: createRoutes(), | ||
const validateRoutes = (routes: ReturnType<typeof createRoutes>) => { | ||
routes.forEach((route) => { | ||
expect(route.path).toBeDefined(); | ||
expect(route.component).toBeDefined(); | ||
if (route.children) { | ||
validateRoutes(route.children); | ||
} | ||
}); | ||
router.push(path); | ||
await router.isReady(); | ||
const wrapper = mount(App, { | ||
global: { | ||
plugins: [router], | ||
}, | ||
}); | ||
return { router, wrapper }; | ||
}; | ||
|
||
describe("router", () => { | ||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it("renders a default route", async () => { | ||
const { wrapper } = await setupTest("/"); | ||
|
||
expect(wrapper.findComponent(HomeView).exists()).toBe(true); | ||
}); | ||
|
||
it("renders the about route", async () => { | ||
const { wrapper, router } = await setupTest("/"); | ||
router.push("/about"); | ||
await router.isReady(); | ||
|
||
expect(wrapper.findComponent(AboutView).exists()).toBe(true); | ||
}); | ||
|
||
it("renders the login route", async () => { | ||
const { wrapper } = await setupTest("/login"); | ||
|
||
expect(wrapper.findComponent(LoginView).exists()).toBe(true); | ||
describe("routes", () => { | ||
it("creates routes", () => { | ||
const routes = createRoutes(); | ||
expect(routes).toHaveLength(2); | ||
validateRoutes(routes); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import HomeView from "./HomeView.vue"; | ||
import { mount } from "@vue/test-utils"; | ||
|
||
describe("HomeView", () => { | ||
it("renders properly", () => { | ||
const wrapper = mount(HomeView); | ||
expect(wrapper.find(".main-wrapper")).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import LoginView from "./LoginView.vue"; | ||
import { mount } from "@vue/test-utils"; | ||
|
||
describe("LoginView", () => { | ||
it("renders properly", () => { | ||
const wrapper = mount(LoginView); | ||
expect(wrapper.text()).toContain("login"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters