menuOptionSpacing.test.ts 951 B

1234567891011121314151617181920212223242526272829
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. const dropdownMenuSource = readFileSync(
  4. new URL("../src/components/ui/dropdown-menu.tsx", import.meta.url),
  5. "utf8",
  6. );
  7. const contextMenuSource = readFileSync(
  8. new URL("../src/components/ui/context-menu.tsx", import.meta.url),
  9. "utf8",
  10. );
  11. const selectSource = readFileSync(
  12. new URL("../src/components/ui/select.tsx", import.meta.url),
  13. "utf8",
  14. );
  15. describe("shared menu option spacing", () => {
  16. it("keeps dropdown menu roots, submenus, and groups 2px apart", () => {
  17. expect(dropdownMenuSource.match(/flex flex-col gap-0\.5/g)).toHaveLength(4);
  18. });
  19. it("keeps context menu roots and submenus 2px apart", () => {
  20. expect(contextMenuSource.match(/flex flex-col gap-0\.5/g)).toHaveLength(2);
  21. });
  22. it("keeps select viewports and groups 2px apart", () => {
  23. expect(selectSource.match(/flex flex-col gap-0\.5/g)).toHaveLength(2);
  24. });
  25. });