Files
admin-web/src/modules/overseas-warehouse/lastMilePresentation.test.ts
T
2026-08-22 12:24:15 +08:00

27 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { toLastMileOrderListItem } from './lastMilePresentation'
describe('last-mile order presentation adapter', () => {
it('maps backend codes, associations and long ids without inventing data', () => {
const row = toLastMileOrderListItem({
id: '190000000000000099', customerId: '190000000000000001', orderNo: 'LL-001', orderType: 'ONE_CLICK_DROPSHIP', currentStatus: 'PENDING_ASSIGNMENT',
abnormal: true, detained: false, packageCount: 12, deliveryOrderNo: 'DEL-READ-ONLY', outboundOrderNo: 'OUT-READ-ONLY',
})
expect(row).toMatchObject({
id: '190000000000000099', customerId: '190000000000000001', orderType: '一件代发', status: '待分配',
warning: '异常', abnormal: '是', held: '否', cartons: 12, dispatchOrderNo: 'DEL-READ-ONLY', outboundOrderNo: 'OUT-READ-ONLY',
})
expect(row.rejectedAt).toBe('—')
})
it.each([
['RELABEL_APPLICATION', '换标下单'],
['WAREHOUSE_TRANSFER', '仓储转运'],
['RETURN_RELABEL', '退货换标'],
['LOCAL_LOOSEBOARD', '本土散板'],
])('maps %s to its Chinese display name', (orderType, expected) => {
const row = toLastMileOrderListItem({ id: '1', customerId: '100', orderNo: 'LL-1', orderType })
expect(row.orderType).toBe(expected)
})
})