Files
cc-switch/tests/components/Switch.test.tsx
T
Jason 8919d05cb3 fix(ui): use the action color for the apps page visibility switches
The neutral switch tone drew the checked track in dark gray next to a
medium-gray unchecked track, so on and off were nearly indistinguishable
in light mode. Drop the neutral tone (its only caller was the apps page
"Show" column) and let those switches use the same action color as every
other switch.

Closes #8010
2026-10-09 21:09:53 +08:00

22 lines
940 B
TypeScript

import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { Switch } from "@/components/ui/switch";
describe("Switch", () => {
it("keeps the default size and action color", () => {
render(<Switch aria-label="default" defaultChecked />);
const element = screen.getByRole("switch", { name: "default" });
expect(element).toHaveAttribute("data-size", "default");
expect(element.className).toContain("w-[30px]");
expect(element.className).toContain("data-[state=checked]:bg-action");
});
it("uses the action color for the small variant too", () => {
render(<Switch aria-label="small" size="sm" />);
const element = screen.getByRole("switch", { name: "small" });
expect(element).toHaveAttribute("data-size", "sm");
expect(element.className).toContain("w-[26px]");
expect(element.className).toContain("data-[state=checked]:bg-action");
});
});