Project import from github
All checks were successful
Production Build and Deploy / Build (push) Successful in 1m7s
Production Build and Deploy / Deploy (push) Successful in 21s

This commit is contained in:
Liviu Burcusel 2026-01-14 16:29:05 +01:00
commit 0add58254d
Signed by: liviu
GPG key ID: 6CDB37A4AD2C610C
179 changed files with 23756 additions and 0 deletions

52
tests/pages/index.test.ts Normal file
View file

@ -0,0 +1,52 @@
import { beforeEach, describe, expect, it } from "vitest";
import { mount, type VueWrapper } from "@vue/test-utils";
import IndexPage from "~/pages/index.vue";
describe("pages/index.vue", () => {
let wrapper: VueWrapper;
beforeEach(() => {
wrapper = mount(IndexPage);
});
it("loads without crashing", () => {
expect(wrapper.exists()).toBe(true);
});
it("displays initial state correctly", () => {
const displayElement = wrapper.find(".text-lime-500");
expect(displayElement.exists()).toBe(true);
expect(displayElement.text()).toBe("None");
});
it("updates text when Default button is clicked", async () => {
// Find button method 1: by text content inside button elements
const buttons = wrapper.findAll("button");
const defaultBtn = buttons.find((b) => b.text() === "Default");
expect(defaultBtn?.exists()).toBe(true);
await defaultBtn?.trigger("click");
expect(wrapper.find(".text-lime-500").text()).toBe("default");
});
it("updates text when other buttons are clicked", async () => {
const testCases = [
{ label: "Outline", expected: "outline" },
{ label: "Ghost", expected: "ghost" },
{ label: "Link", expected: "link" },
{ label: "Secondary", expected: "secondary" },
{ label: "Destructive", expected: "destructive" },
];
for (const { label, expected } of testCases) {
const buttons = wrapper.findAll("button");
const btn = buttons.find((b) => b.text() === label);
expect(btn?.exists(), `Button with label ${label} should exist`).toBe(true);
await btn?.trigger("click");
expect(wrapper.find(".text-lime-500").text()).toBe(expected);
}
});
});