Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

1.9 KB
Raw Blame
import { describe, expect, it, vi } from "vite-plus/test";

import { applyAppearanceContrast } from "./appearanceContrast";

function makeRoot() {
  const setProperty = vi.fn();

  return {
    root: { style: { setProperty } },
    setProperty,
  };
}

describe("applyAppearanceContrast", () => {
  it("boosts semantic contrast above the default", () => {
    const { root, setProperty } = makeRoot();

    applyAppearanceContrast(root, 135);

    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-base", "100%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-boost", "35%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-border-boost", "8.75%");
  });

  it("supports the maximum contrast boost", () => {
    const { root, setProperty } = makeRoot();

    applyAppearanceContrast(root, 200);

    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-base", "100%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-boost", "100%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-border-boost", "25%");
  });

  it("softens semantic contrast below the default", () => {
    const { root, setProperty } = makeRoot();

    applyAppearanceContrast(root, 70);

    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-base", "70%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-boost", "0%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-border-boost", "0%");
  });

  it("disables contrast mixing at the default", () => {
    const { root, setProperty } = makeRoot();

    applyAppearanceContrast(root, 100);

    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-base", "100%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-boost", "0%");
    expect(setProperty).toHaveBeenCalledWith("--appearance-contrast-border-boost", "0%");
  });
});