33 lines
1.6 KiB
TypeScript
33 lines
1.6 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import test from 'node:test'
|
|
|
|
function readWorkOrdersPanel() {
|
|
return readFileSync(
|
|
fileURLToPath(new URL('../src/pages/admin/panels/WorkOrdersPanel.tsx', import.meta.url)),
|
|
'utf8',
|
|
)
|
|
}
|
|
|
|
test('工单表:发单金额后必须有独立「寄卖价格」列', () => {
|
|
const source = readWorkOrdersPanel()
|
|
assert.ok(source.includes("title: '发单金额'"), '找不到发单金额列')
|
|
assert.ok(source.includes("title: '寄卖价格'"), '缺少寄卖价格列')
|
|
assert.ok(source.includes('consignmentSaleTotalFen'), '主列必须读取整单寄卖总价')
|
|
assert.ok(source.includes('consignmentSaleQuantity'), '数量 > 1 时必须展示单价 × 数量')
|
|
const amountIndex = source.indexOf("title: '发单金额'")
|
|
const priceIndex = source.indexOf("title: '寄卖价格'", amountIndex)
|
|
assert.ok(priceIndex > amountIndex, '寄卖价格列必须在发单金额之后')
|
|
})
|
|
|
|
test('拼单明细:必须有「寄卖价格」列并展示单价 + 份额合计', () => {
|
|
const source = readWorkOrdersPanel()
|
|
assert.ok(source.includes("title: '份额报酬'"), '找不到份额报酬列')
|
|
const rewardIndex = source.indexOf("title: '份额报酬'")
|
|
const priceIndex = source.indexOf("title: '寄卖价格'", rewardIndex)
|
|
assert.ok(priceIndex > rewardIndex, '寄卖价格列必须在份额报酬之后')
|
|
assert.ok(source.includes('/份'), '寄卖价格必须展示每份单价')
|
|
assert.ok(source.includes('合计 {formatMoney(unitPriceFen * quantity)}'), '必须展示该份额合计')
|
|
})
|