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

16 lines
957 B
JavaScript
Raw Normal View History

2026-10-09 17:36:34 +08:00
import assert from 'node:assert/strict'
import test from 'node:test'
import { readFileSync } from 'node:fs'
import ts from 'typescript'
const source = readFileSync(new URL('./orderProgress.ts', import.meta.url), 'utf8')
const code = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText
const exports = {}
new Function('exports', code)(exports)
test('prototype queues preserve order and distinguish partial progress from completion', () => {
assert.deepEqual(exports.ORDER_QUEUES.slice(0, 7).map(q => q.key), ['all','fee','loaded','declared','cleared','scheduled','delivering'])
assert.equal(exports.orderProgressLabel({ stage: 'scheduled', partial: true }), '部分已排车')
assert.equal(exports.orderProgressLabel({ stage: 'cleared', partial: false }), '已清关')
assert.equal(exports.orderProgressLabel({ stage: 'none', partial: false }), '—')
assert.equal(exports.orderProgressLabel(), '—')
})