feat: list group buy orders for dispatch
This commit is contained in:
40
admin-web/src/api/groupBuyApi.test.ts
Normal file
40
admin-web/src/api/groupBuyApi.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { filterPendingDeliveryGroupBuyOrders, groupBuyOrderDispatchLabel } from './groupBuyApi'
|
||||
import type { GroupBuyOrder } from '../types'
|
||||
|
||||
describe('group buy dispatch helpers', () => {
|
||||
it('keeps only group buy orders waiting for delivery', () => {
|
||||
const orders = [
|
||||
groupBuyOrder({ id: 1, status: 'PENDING_DELIVERY' }),
|
||||
groupBuyOrder({ id: 2, status: 'DELIVERING' }),
|
||||
groupBuyOrder({ id: 3, status: 'PENDING_PICKUP' })
|
||||
]
|
||||
|
||||
expect(filterPendingDeliveryGroupBuyOrders(orders).map((item) => item.id)).toEqual([1])
|
||||
})
|
||||
|
||||
it('builds a readable dispatch label', () => {
|
||||
expect(groupBuyOrderDispatchLabel(groupBuyOrder({
|
||||
orderNo: 'GB00000001',
|
||||
groupBuyTitle: 'Today eggs',
|
||||
quantity: 2,
|
||||
amountCent: 5980
|
||||
}))).toBe('GB00000001 Today eggs x2 ¥59.80')
|
||||
})
|
||||
})
|
||||
|
||||
function groupBuyOrder(overrides: Partial<GroupBuyOrder>): GroupBuyOrder {
|
||||
return {
|
||||
id: 1,
|
||||
orderNo: 'GB00000001',
|
||||
groupBuyId: 1,
|
||||
groupBuyTitle: 'Today eggs',
|
||||
quantity: 1,
|
||||
priceCent: 2990,
|
||||
amountCent: 2990,
|
||||
deliveryMethod: 'IMMEDIATE',
|
||||
status: 'PENDING_DELIVERY',
|
||||
offlinePayStatus: 'UNPAID',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user