Files
token-tools/tests/components/workbench.test.tsx
T
2026-09-01 13:04:50 +02:00

25 lines
1.0 KiB
TypeScript

import { fireEvent, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it } from "vitest";
import { Workbench } from "../../src/components/Workbench";
describe("Workbench", () => {
it("switches themes and keeps aliases resolved", async () => {
const user = userEvent.setup();
render(<Workbench />);
await user.selectOptions(screen.getByLabelText("Theme"), "dark");
expect(screen.getByText("#f4f2ff")).toBeVisible();
expect(screen.getByText(/Sets: core → dark/u)).toBeVisible();
});
it("does not replace the active document with invalid JSON", async () => {
const user = userEvent.setup();
render(<Workbench />);
const source = screen.getByLabelText("Token document JSON");
fireEvent.change(source, { target: { value: "{" } });
await user.click(screen.getByRole("button", { name: "Apply JSON" }));
expect(screen.getByRole("alert")).toBeVisible();
expect(screen.getAllByText("color.brand").length).toBeGreaterThan(0);
});
});