18 lines
979 B
JavaScript
18 lines
979 B
JavaScript
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: '待确认' })
|
|
])
|
|
})
|
|
})
|