35 lines
1.7 KiB
JavaScript
35 lines
1.7 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import test from 'node:test'
|
|
|
|
const source = readFileSync(new URL('./inboundBilling.ts', import.meta.url), 'utf8')
|
|
|
|
test('formats zero values, currencies, measurements, and backend dates without hardcoded business factors', () => {
|
|
assert.match(source, /value === null \|\| value === undefined/)
|
|
assert.match(source, /Intl\.NumberFormat\('zh-CN'/)
|
|
assert.match(source, /style: 'currency'/)
|
|
assert.match(source, /Intl\.DateTimeFormat\('zh-CN'/)
|
|
assert.doesNotMatch(source, /\b167\b|\b363\b/)
|
|
})
|
|
|
|
test('translates backend rounding modes into customer-facing calculation labels', () => {
|
|
assert.match(source, /export function getRoundingModeLabel/)
|
|
assert.match(source, /CEILING: '向上取整'/)
|
|
assert.match(source, /HALF_UP: '四舍五入'/)
|
|
assert.match(source, /return value \? labels\[value\] \|\| value : '-'/)
|
|
})
|
|
|
|
test('translates carton calculation rules into customer-facing labels', () => {
|
|
assert.match(source, /export function getCalculationRuleLabel/)
|
|
assert.match(source, /ACTUAL_DIMENSION_V1/)
|
|
assert.match(source, /按实际箱规计算/)
|
|
assert.match(source, /CUSTOMER_DIMENSION_\(SMALL\|MEDIUM\|LARGE\|EXTRA_LARGE\)_V/)
|
|
})
|
|
|
|
test('renders conversion metadata as one complete label or a single empty marker', () => {
|
|
assert.match(source, /export function formatConversionPrecision/)
|
|
assert.match(source, /roundingScale === null \|\| roundingScale === undefined/)
|
|
assert.match(source, /\|\| !roundingMode\) return '-'/)
|
|
assert.match(source, /`系数 \$\{formatInboundNumber\(conversionFactor\)\} · 保留 \$\{roundingScale\} 位 \$\{getRoundingModeLabel\(roundingMode\)\}`/)
|
|
})
|