file-tab-scroll.test.ts 965 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { describe, expect, test } from "bun:test"
  2. import { nextTabListScrollLeft } from "./file-tab-scroll"
  3. describe("nextTabListScrollLeft", () => {
  4. test("does not scroll when width shrinks", () => {
  5. const left = nextTabListScrollLeft({
  6. prevScrollWidth: 500,
  7. scrollWidth: 420,
  8. clientWidth: 300,
  9. prevContextOpen: false,
  10. contextOpen: false,
  11. })
  12. expect(left).toBeUndefined()
  13. })
  14. test("scrolls to start when context tab opens", () => {
  15. const left = nextTabListScrollLeft({
  16. prevScrollWidth: 400,
  17. scrollWidth: 500,
  18. clientWidth: 320,
  19. prevContextOpen: false,
  20. contextOpen: true,
  21. })
  22. expect(left).toBe(0)
  23. })
  24. test("scrolls to right edge for new file tabs", () => {
  25. const left = nextTabListScrollLeft({
  26. prevScrollWidth: 500,
  27. scrollWidth: 780,
  28. clientWidth: 300,
  29. prevContextOpen: true,
  30. contextOpen: true,
  31. })
  32. expect(left).toBe(480)
  33. })
  34. })