test: add component tests

This commit is contained in:
2026-02-08 13:01:59 +05:00
parent 1a0d99828e
commit 1b0675e4b2
16 changed files with 479 additions and 4 deletions
@@ -0,0 +1,45 @@
import Preview from "$components/panel/Preview.svelte";
import { render, cleanup } from "@testing-library/svelte";
import { describe, expect, it, afterEach } from "vitest";
afterEach(() => {
cleanup();
});
describe("Preview.svelte", () => {
it("should render without crashing", () => {
const { container } = render(Preview, {
props: {
text: "Test text",
stage: undefined,
},
});
expect(container).toBeInTheDocument();
});
it("should have stage element", () => {
const { container } = render(Preview, {
props: {
text: "Test",
stage: undefined,
},
});
const stage = container.querySelector("canvas");
expect(stage).toBeInTheDocument();
});
it("should have correct stage dimensions", () => {
const { container } = render(Preview, {
props: {
text: "Test",
stage: undefined,
},
});
const stage = container.querySelector("canvas");
expect(stage).toHaveAttribute("width", "320");
expect(stage).toHaveAttribute("height", "100");
});
});