check-list-table-viewport-height.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import assert from 'node:assert/strict'
  2. import {
  3. LIST_TABLE_VIEWPORT_BOTTOM_GAP,
  4. LIST_TABLE_VIEWPORT_MIN_HEIGHT,
  5. calcListTableViewportHeight
  6. } from '../src/composables/listTableViewportHeight'
  7. assert.equal(LIST_TABLE_VIEWPORT_BOTTOM_GAP, 10)
  8. assert.equal(LIST_TABLE_VIEWPORT_MIN_HEIGHT, 240)
  9. // contentBottom=1000, tableTop=200, pager=48 → 1000-200-48-10 = 742
  10. assert.equal(
  11. calcListTableViewportHeight({
  12. contentViewportBottom: 1000,
  13. tableTop: 200,
  14. pagerHeight: 48
  15. }),
  16. 742
  17. )
  18. // 无分页
  19. assert.equal(
  20. calcListTableViewportHeight({
  21. contentViewportBottom: 800,
  22. tableTop: 100,
  23. pagerHeight: 0
  24. }),
  25. 690
  26. )
  27. // 过矮时夹到 minHeight
  28. assert.equal(
  29. calcListTableViewportHeight({
  30. contentViewportBottom: 400,
  31. tableTop: 300,
  32. pagerHeight: 48,
  33. minHeight: 240,
  34. bottomGap: 10
  35. }),
  36. 240
  37. )
  38. // 自定义 min / gap
  39. assert.equal(
  40. calcListTableViewportHeight({
  41. contentViewportBottom: 1000,
  42. tableTop: 100,
  43. pagerHeight: 40,
  44. minHeight: 100,
  45. bottomGap: 16
  46. }),
  47. 844
  48. )
  49. console.log('check-list-table-viewport-height: ok')