Files
shanxia2.0/web-admin/src/utils/tinymce-table-edge-resize.test.ts
T
wuzilongandCursor 8e9536332a feat: 保存运输证件、报销付款和开发流程的当前实现。
补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 21:42:33 +08:00

53 lines
1.8 KiB
TypeScript

import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import {
applyColumnWidthDelta,
applyRowHeightDelta,
clampColumnWidthsToMax,
isInsideEdgeBand
} from './tinymce-table-edge-resize.ts'
describe('applyColumnWidthDelta', () => {
it('takes width from the next column and keeps the table width', () => {
const start = [100, 80, 60]
const { widths, tableWidth } = applyColumnWidthDelta(start, 1, 20)
assert.deepEqual(widths, [100, 100, 40])
assert.equal(tableWidth, 240)
assert.deepEqual(start, [100, 80, 60])
})
it('does not shrink a column below 28px or grow the table from the last column', () => {
const shrunk = applyColumnWidthDelta([100, 36, 46], 1, -100)
assert.deepEqual(shrunk.widths, [100, 28, 54])
assert.equal(shrunk.tableWidth, 182)
const last = applyColumnWidthDelta([100, 80, 60], 2, 40)
assert.deepEqual(last.widths, [100, 80, 60])
assert.equal(last.tableWidth, 240)
})
})
describe('clampColumnWidthsToMax', () => {
it('scales columns down to the page content width', () => {
const { widths, tableWidth } = clampColumnWidthsToMax([200, 200, 200], 300)
assert.equal(tableWidth, 300)
assert.equal(widths.reduce((sum, width) => sum + width, 0), 300)
assert.ok(widths.every((width) => width >= 28))
})
})
describe('isInsideEdgeBand', () => {
it('stays false until the pointer is inside the edge band', () => {
assert.equal(isInsideEdgeBand(9, true, 8), false)
assert.equal(isInsideEdgeBand(8, false, 8), false)
assert.equal(isInsideEdgeBand(8, true, 8), true)
})
})
describe('applyRowHeightDelta', () => {
it('keeps row height at or above 20px', () => {
assert.equal(applyRowHeightDelta(30, 10), 40)
assert.equal(applyRowHeightDelta(30, -40), 20)
})
})