From 42e6f2c5a829549882bd04c51fabcf0cdbb7999e Mon Sep 17 00:00:00 2001 From: Liviu Burcusel Date: Tue, 25 Nov 2025 12:02:20 +0100 Subject: [PATCH] Added more tests. --- tests/App.spec.ts | 49 ++++++++++++++++++++++++++++++++++++++++++ tests/setup.vuetify.ts | 10 +++++++++ tsconfig.vitest.json | 6 +++++- vitest.config.ts | 9 ++++---- 4 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 tests/App.spec.ts create mode 100644 tests/setup.vuetify.ts diff --git a/tests/App.spec.ts b/tests/App.spec.ts new file mode 100644 index 0000000..f1cd48a --- /dev/null +++ b/tests/App.spec.ts @@ -0,0 +1,49 @@ +import { describe, expect, it } from "vitest"; +import { mount, type VueWrapper } from "@vue/test-utils"; +import { vuetify } from "./setup.vuetify"; + +import App from "~/App.vue"; + +describe("App.vue", () => { + const wrapper: VueWrapper = mount(App, { + global: { + plugins: [vuetify], + stubs: { + HeaderNavBar: true, + FooterComponent: true, + RouterView: true, + }, + }, + }); + + describe("Component Structure", () => { + it("renders the component", () => { + expect(wrapper.exists()).toBe(true); + }); + + it("renders v-app as the root element", () => { + expect(wrapper.find(".v-application").exists()).toBe(true); + }); + + it("renders HeaderNavBar component", () => { + expect(wrapper.findComponent({ name: "HeaderNavBar" }).exists()).toBe(true); + }); + + it("renders FooterComponent component", () => { + expect(wrapper.findComponent({ name: "FooterComponent" }).exists()).toBe(true); + }); + + it("renders v-main element", () => { + expect(wrapper.find(".v-main").exists()).toBe(true); + }); + + it("renders v-container inside v-main", () => { + const main = wrapper.find(".v-main"); + expect(main.find(".v-container").exists()).toBe(true); + }); + + it("renders RouterView component", () => { + expect(wrapper.findComponent({ name: "RouterView" }).exists()).toBe(true); + }); + }); +}); diff --git a/tests/setup.vuetify.ts b/tests/setup.vuetify.ts new file mode 100644 index 0000000..77f4765 --- /dev/null +++ b/tests/setup.vuetify.ts @@ -0,0 +1,10 @@ +import { createVuetify } from "vuetify"; +import * as components from "vuetify/components"; +import * as directives from "vuetify/directives"; + +const vuetify = createVuetify({ + components, + directives, +}); + +export { vuetify }; diff --git a/tsconfig.vitest.json b/tsconfig.vitest.json index 5c5ba21..caf1382 100644 --- a/tsconfig.vitest.json +++ b/tsconfig.vitest.json @@ -1,10 +1,14 @@ { "extends": "./tsconfig.app.json", - "include": ["tests/**/*.spec.ts", "env.d.ts", "src/**/*", "src/**/*.vue"], + "include": ["tests/**/*.ts", "env.d.ts", "src/**/*", "src/**/*.vue"], "exclude": [], "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo", "types": ["node", "happy-dom"] + }, + "paths": { + "~/*": ["./src/*"], + "@/*": ["./src/*"] } } diff --git a/vitest.config.ts b/vitest.config.ts index 8a14015..d3a7339 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -9,12 +9,11 @@ export default mergeConfig( environment: "happy-dom", exclude: [...configDefaults.exclude, "e2e/**"], root: fileURLToPath(new URL("./", import.meta.url)), - reporters: [ - 'default', - ['vitest-sonar-reporter', { outputFile: 'coverage/sonar-report.xml' }], - ], + setupFiles: ["./tests/setup.vuetify.ts"], + reporters: ["default", ["vitest-sonar-reporter", { outputFile: "coverage/sonar-report.xml" }]], coverage: { reporter: ["text", "lcov"], + exclude: [...(configDefaults.coverage.exclude || []), "**/*.css", "**/*.scss"], }, server: { deps: { @@ -22,5 +21,5 @@ export default mergeConfig( }, }, }, - }), + }) );