Files
client-web/src/modules/first-leg/utils/inboundBilling.test.mjs
T

28 lines
1.3 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('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\)\}`/)
})