| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import assert from 'node:assert/strict'
- import {
- LIST_TABLE_VIEWPORT_BOTTOM_GAP,
- LIST_TABLE_VIEWPORT_MIN_HEIGHT,
- calcListTableViewportHeight
- } from '../src/composables/listTableViewportHeight'
- assert.equal(LIST_TABLE_VIEWPORT_BOTTOM_GAP, 10)
- assert.equal(LIST_TABLE_VIEWPORT_MIN_HEIGHT, 240)
- // contentBottom=1000, tableTop=200, pager=48 → 1000-200-48-10 = 742
- assert.equal(
- calcListTableViewportHeight({
- contentViewportBottom: 1000,
- tableTop: 200,
- pagerHeight: 48
- }),
- 742
- )
- // 无分页
- assert.equal(
- calcListTableViewportHeight({
- contentViewportBottom: 800,
- tableTop: 100,
- pagerHeight: 0
- }),
- 690
- )
- // 过矮时夹到 minHeight
- assert.equal(
- calcListTableViewportHeight({
- contentViewportBottom: 400,
- tableTop: 300,
- pagerHeight: 48,
- minHeight: 240,
- bottomGap: 10
- }),
- 240
- )
- // 自定义 min / gap
- assert.equal(
- calcListTableViewportHeight({
- contentViewportBottom: 1000,
- tableTop: 100,
- pagerHeight: 40,
- minHeight: 100,
- bottomGap: 16
- }),
- 844
- )
- console.log('check-list-table-viewport-height: ok')
|