markdownTableVirtualScrollbar.test.ts 905 B

12345678910111213141516171819202122232425262728293031
  1. import { describe, expect, it } from "vitest";
  2. import { resolveMarkdownTableVirtualScrollMax } from "@/components/ai-elements/markdown-table.js";
  3. describe("resolveMarkdownTableVirtualScrollMax", () => {
  4. it("keeps the fractional layout width as the stable overflow authority", () => {
  5. const tableWidth = 491.5703125;
  6. const layoutTrackWidth = 490.3125;
  7. const scrollMax = resolveMarkdownTableVirtualScrollMax({
  8. tableWidth,
  9. trackWidth: layoutTrackWidth,
  10. });
  11. expect(scrollMax).toBeCloseTo(1.2578125, 8);
  12. });
  13. it("does not report overflow at or below the existing one-pixel threshold", () => {
  14. expect(
  15. resolveMarkdownTableVirtualScrollMax({
  16. tableWidth: 491,
  17. trackWidth: 490,
  18. }),
  19. ).toBe(1);
  20. expect(
  21. resolveMarkdownTableVirtualScrollMax({
  22. tableWidth: 489.5,
  23. trackWidth: 490,
  24. }),
  25. ).toBe(0);
  26. });
  27. });