sidePaneTabStripLayout.test.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { describe, expect, it } from "vitest";
  2. import { resolveSidePaneTabsOverflow } from "../src/app-shell/sidePaneLayout.js";
  3. describe("side pane tab strip layout", () => {
  4. it.each([
  5. { tabCount: 3, insideViewportWidth: 220, outsideViewportWidth: 188 },
  6. { tabCount: 4, insideViewportWidth: 284, outsideViewportWidth: 252 },
  7. { tabCount: 5, insideViewportWidth: 348, outsideViewportWidth: 316 },
  8. ])(
  9. "keeps the overflow decision stable when the add button moves for $tabCount tabs",
  10. ({ tabCount, insideViewportWidth, outsideViewportWidth }) => {
  11. expect(
  12. resolveSidePaneTabsOverflow({
  13. addButtonInside: true,
  14. addButtonWidth: 32,
  15. tabCount,
  16. viewportWidth: insideViewportWidth,
  17. }),
  18. ).toBe(true);
  19. expect(
  20. resolveSidePaneTabsOverflow({
  21. addButtonInside: false,
  22. addButtonWidth: 32,
  23. tabCount,
  24. viewportWidth: outsideViewportWidth,
  25. }),
  26. ).toBe(true);
  27. expect(
  28. resolveSidePaneTabsOverflow({
  29. addButtonInside: true,
  30. addButtonWidth: 32,
  31. tabCount,
  32. viewportWidth: insideViewportWidth + 10,
  33. }),
  34. ).toBe(false);
  35. expect(
  36. resolveSidePaneTabsOverflow({
  37. addButtonInside: false,
  38. addButtonWidth: 32,
  39. tabCount,
  40. viewportWidth: outsideViewportWidth + 10,
  41. }),
  42. ).toBe(false);
  43. },
  44. );
  45. });