Files
admin-web/src/modules/overseas-warehouse/lastMilePresentation.test.ts
T

36 lines
1.9 KiB
TypeScript
Raw Normal View History

2026-08-20 09:10:36 +08:00
import { describe, expect, it } from 'vitest'
2026-08-28 14:33:57 +08:00
import { formatOverseasDateTime, toLastMileOrderListItem } from './lastMilePresentation'
2026-08-20 09:10:36 +08:00
describe('last-mile order presentation adapter', () => {
2026-08-28 14:33:57 +08:00
it('formats overseas timestamps with zero-padded seconds', () => {
expect(formatOverseasDateTime('2026-08-27T16:19:46')).toBe('2026-08-27 16:19:46')
expect(formatOverseasDateTime('2026-08-07T06:09:04')).toBe('2026-08-07 06:09:04')
expect(formatOverseasDateTime('2026-08-07')).toMatch(/^2026-08-07 /)
expect(formatOverseasDateTime(new Date(2026, 7, 7, 6, 9, 4))).toBe('2026-08-07 06:09:04')
expect(formatOverseasDateTime('')).toBe('—')
expect(formatOverseasDateTime('not-a-date')).toBe('not-a-date')
})
2026-08-20 09:10:36 +08:00
it('maps backend codes, associations and long ids without inventing data', () => {
const row = toLastMileOrderListItem({
2026-08-21 11:20:09 +08:00
id: '190000000000000099', customerId: '190000000000000001', orderNo: 'LL-001', orderType: 'ONE_CLICK_DROPSHIP', currentStatus: 'PENDING_ASSIGNMENT',
2026-08-28 14:33:57 +08:00
abnormal: true, detained: false, packageCount: 12, palletMergeFlag: 'REQUIRED', deliveryOrderNo: 'DEL-READ-ONLY', outboundOrderNo: 'OUT-READ-ONLY',
2026-08-21 11:20:09 +08:00
})
2026-08-20 09:10:36 +08:00
expect(row).toMatchObject({
id: '190000000000000099', customerId: '190000000000000001', orderType: '一件代发', status: '待分配',
2026-08-28 14:33:57 +08:00
warning: '异常', abnormal: '是', held: '否', cartons: 12, consolidated: '待合托', palletMergeFlag: 'REQUIRED', dispatchOrderNo: 'DEL-READ-ONLY', outboundOrderNo: 'OUT-READ-ONLY',
2026-08-20 09:10:36 +08:00
})
expect(row.rejectedAt).toBe('—')
})
2026-08-22 12:24:15 +08:00
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)
})
2026-08-20 09:10:36 +08:00
})