Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

1.7 KB
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */

import { describe, expect, it } from "vitest";
import { buttonVariants } from "../button";

describe("buttonVariants", () => {
  it.each([
    {
      variant: "destructive" as const,
      expected: [
        "bg-destructive",
        "text-destructive-foreground",
        "border-destructive-border",
        "hover:bg-destructive-hover",
      ],
    },
    {
      variant: "success" as const,
      expected: [
        "bg-success",
        "text-success-foreground",
        "border-success-border",
        "hover:bg-success-hover",
      ],
    },
    {
      variant: "warn" as const,
      expected: [
        "bg-action",
        "text-action-foreground",
        "border-action-border",
        "hover:bg-action-hover",
      ],
    },
  ])("uses semantic theme colors for $variant", ({ variant, expected }) => {
    const classes = buttonVariants({ variant });

    expect(classes).toEqual(expect.stringContaining(expected.join(" ")));
    expect(classes).not.toMatch(/--(?:red|grass|yellow)-/);
    expect(classes).not.toContain("dark:");
  });

  it("uses system colors in forced-color mode", () => {
    const classes = buttonVariants({ variant: "default" });

    expect(classes).toEqual(
      expect.stringContaining(
        [
          "forced-color-adjust-none",
          "forced-colors:border-[ButtonText]",
          "forced-colors:bg-[ButtonFace]",
          "forced-colors:text-[ButtonText]",
          "forced-colors:hover:bg-[Highlight]",
          "forced-colors:hover:text-[HighlightText]",
          "forced-colors:disabled:border-[GrayText]",
          "forced-colors:disabled:text-[GrayText]",
        ].join(" "),
      ),
    );
  });
});