windowCaptionControls.test.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. createWindowsCaptionControlsStyle,
  4. WINDOWS_CAPTION_CONTROLS_RIGHT_INSET_VAR,
  5. WINDOWS_CAPTION_CONTROL_CLASS,
  6. WINDOWS_CAPTION_CONTROL_WIDTH_VAR,
  7. } from "@/windowCaptionControls.js";
  8. describe("windowCaptionControls", () => {
  9. it("uses fixed CSS spacing independent of legacy native metrics", () => {
  10. const style = createWindowsCaptionControlsStyle(181);
  11. expect(style).toEqual({
  12. "--windows-caption-controls-right-inset":
  13. "136px",
  14. "--windows-caption-control-width": "calc(var(--windows-caption-controls-right-inset) / 3)",
  15. });
  16. expect(WINDOWS_CAPTION_CONTROLS_RIGHT_INSET_VAR).toBe(
  17. "var(--windows-caption-controls-right-inset)",
  18. );
  19. expect(WINDOWS_CAPTION_CONTROL_WIDTH_VAR).toBe("var(--windows-caption-control-width)");
  20. });
  21. it("falls back to the baseline inset and derives custom control width", () => {
  22. expect(createWindowsCaptionControlsStyle(Number.NaN)).toEqual(
  23. expect.objectContaining({
  24. "--windows-caption-controls-right-inset": "136px",
  25. }),
  26. );
  27. expect(WINDOWS_CAPTION_CONTROL_CLASS).toContain(
  28. "w-[var(--windows-caption-control-width,46px)]",
  29. );
  30. });
  31. });