feat: present miniapp orders with formatted status

This commit is contained in:
王鹏
2026-07-07 17:56:56 +08:00
parent 48dc5a0c13
commit 18bd5497cd
4 changed files with 65 additions and 32 deletions

View File

@@ -0,0 +1,17 @@
const { toOrderCards } = require('./orderPresenter')
describe('toOrderCards', () => {
test('normalizes mixed orders for list display', () => {
const cards = toOrderCards({
goodsOrders: [{ id: 1, orderNo: 'GO00000001', payableAmountCent: 1590, status: 'PENDING_DELIVERY' }],
expressOrders: [{ id: 2, orderNo: 'EO00000001', expressCompany: 'SF', pickupCode: 'A1', feeCent: 400, status: 'PENDING_PICKUP' }],
groupBuyOrders: [{ id: 3, orderNo: 'GB00000001', groupBuyTitle: 'Today eggs', amountCent: 5980, status: 'PENDING_CONFIRM' }]
})
expect(cards).toEqual([
expect.objectContaining({ id: 1, type: 'goods', title: 'GO00000001', amountText: '¥15.90', statusText: '待配送' }),
expect.objectContaining({ id: 2, type: 'express', title: 'SF A1', amountText: '¥4.00', statusText: '待自提' }),
expect.objectContaining({ id: 3, type: 'group', title: 'Today eggs', amountText: '¥59.80', statusText: '待确认' })
])
})
})