This commit is contained in:
2026-08-28 14:33:57 +08:00
parent 7b50e92baf
commit ae48f46c9f
21 changed files with 282 additions and 24 deletions
@@ -1,15 +1,24 @@
import { describe, expect, it } from 'vitest'
import { toLastMileOrderListItem } from './lastMilePresentation'
import { formatOverseasDateTime, toLastMileOrderListItem } from './lastMilePresentation'
describe('last-mile order presentation adapter', () => {
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')
})
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',
abnormal: true, detained: false, packageCount: 12, palletMergeFlag: 'REQUIRED', 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',
warning: '异常', abnormal: '是', held: '否', cartons: 12, consolidated: '待合托', palletMergeFlag: 'REQUIRED', dispatchOrderNo: 'DEL-READ-ONLY', outboundOrderNo: 'OUT-READ-ONLY',
})
expect(row.rejectedAt).toBe('—')
})