codeFontStack.test.ts 904 B

12345678910111213141516171819202122232425
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. const styles = readFileSync("packages/ui/src/styles.css", "utf8");
  4. const codeViewerSource = readFileSync(
  5. "packages/ui/src/components/ui/code-viewer.tsx",
  6. "utf8",
  7. );
  8. const diffViewerSource = readFileSync(
  9. "packages/ui/src/components/ui/diff-viewer.tsx",
  10. "utf8",
  11. );
  12. describe("code font stack", () => {
  13. it("uses sans-serif CJK fallbacks before generic monospace", () => {
  14. expect(styles).toMatch(
  15. /--font-mono:[^;]*Consolas[^;]*"Microsoft YaHei UI"[^;]*"Microsoft YaHei"[^;]*"PingFang SC"[^;]*"Noto Sans CJK SC"[^;]*monospace;/u,
  16. );
  17. });
  18. it("shares the CJK-safe mono token with code and diff viewers", () => {
  19. expect(codeViewerSource).toContain('"--diffs-font-family": "var(--font-mono)"');
  20. expect(diffViewerSource).toContain('"--diffs-font-family": "var(--font-mono)"');
  21. });
  22. });