markdownTableVirtualScrollbar.test.ts 947 B

1234567891011121314151617181920212223242526272829303132
  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. expect(scrollMax).toBeGreaterThan(1);
  13. });
  14. it("does not report overflow at or below the existing one-pixel threshold", () => {
  15. expect(
  16. resolveMarkdownTableVirtualScrollMax({
  17. tableWidth: 491,
  18. trackWidth: 490,
  19. }),
  20. ).toBe(1);
  21. expect(
  22. resolveMarkdownTableVirtualScrollMax({
  23. tableWidth: 489.5,
  24. trackWidth: 490,
  25. }),
  26. ).toBe(0);
  27. });
  28. });