Files
memos/web/tests/switch.test.tsx
T
johnnyjoygh c640884067 chore(ui): refine shared controls and floating surfaces
Use neutral, theme-aware surfaces and consistent density for hints,
menus, dialogs, and form controls. Restore visible field focus and use
Base UI tabs for keyboard navigation and RTL support.
2026-10-21 21:32:32 +08:00

17 lines
694 B
TypeScript

import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { Switch } from "@/components/ui/switch";
describe("Switch", () => {
it("moves the checked thumb toward the inline end in both text directions", () => {
render(<Switch aria-label="Example setting" defaultChecked />);
const root = screen.getByRole("switch", { name: "Example setting" });
const thumb = root.querySelector('[data-slot="switch-thumb"]');
expect(root).toHaveAttribute("aria-checked", "true");
expect(thumb).toHaveAttribute("data-checked");
expect(thumb).toHaveClass("data-checked:translate-x-3", "rtl:data-checked:-translate-x-3");
});
});