test: verify paid ticket order payload
This commit is contained in:
@@ -30,12 +30,14 @@ const adultProduct = {
|
||||
id: 'adult-ticket',
|
||||
name: '成人门票',
|
||||
allocation: 120,
|
||||
refundAllocation: 120,
|
||||
third_party: true,
|
||||
},
|
||||
{
|
||||
id: 'shuttle',
|
||||
name: '摆渡车',
|
||||
allocation: 40,
|
||||
refundAllocation: 40,
|
||||
self: true,
|
||||
},
|
||||
],
|
||||
@@ -155,9 +157,11 @@ test('creates a paid order with entitlements and credentials', () => {
|
||||
assert.equal(order.id, `ORDER-${now.getTime()}`)
|
||||
assert.equal(order.gateCredential.qrToken, `GATE-${order.id}`)
|
||||
assert.equal(order.selfCredential.qrToken, `SELF-${order.id}`)
|
||||
assert.deepEqual(order.insurance, { price: 5, amount: 5 })
|
||||
assert.equal(order.logs[0].message, '订单支付成功')
|
||||
|
||||
const secondTraveler = { ...eligibleTraveler, id: 't-2', idNumber: '110101199101020010' }
|
||||
const thirdTraveler = { ...eligibleTraveler, id: 't-3', idNumber: '110101199201020010' }
|
||||
const uninsuredOrder = createPaidOrder({
|
||||
product: adultProduct,
|
||||
draft: {
|
||||
@@ -177,6 +181,32 @@ test('creates a paid order with entitlements and credentials', () => {
|
||||
assert.deepEqual(uninsuredOrder.entitlements.map((entitlement) => entitlement.quantity), [2, 2])
|
||||
assert.deepEqual(uninsuredOrder.entitlements.map((entitlement) => entitlement.status), ['pending', 'pending'])
|
||||
assert.equal(uninsuredOrder.insurance, undefined)
|
||||
|
||||
const insuredOrder = createPaidOrder({
|
||||
product: adultProduct,
|
||||
draft: {
|
||||
...createBookingDraft(adultProduct),
|
||||
visitDate: '2026-08-01',
|
||||
timeSlot: '08:00—09:30',
|
||||
quantity: 2,
|
||||
travelerIds: ['t-1', 't-2', 't-3'],
|
||||
contactName: '林晓',
|
||||
phone: '13800138000',
|
||||
insuranceSelected: true,
|
||||
},
|
||||
travelers: [eligibleTraveler, secondTraveler, thirdTraveler],
|
||||
now,
|
||||
})
|
||||
|
||||
assert.deepEqual(insuredOrder.travelers.map((traveler) => traveler.id), ['t-1', 't-2'])
|
||||
assert.deepEqual(insuredOrder.entitlements.map((entitlement) => entitlement.quantity), [2, 2])
|
||||
assert.deepEqual(insuredOrder.entitlements.map((entitlement) => entitlement.refundAllocation), [120, 40])
|
||||
assert.notEqual(insuredOrder.entitlements[0], adultProduct.entitlements[0])
|
||||
assert.deepEqual(adultProduct.entitlements, [
|
||||
{ id: 'adult-ticket', name: '成人门票', allocation: 120, refundAllocation: 120, third_party: true },
|
||||
{ id: 'shuttle', name: '摆渡车', allocation: 40, refundAllocation: 40, self: true },
|
||||
])
|
||||
assert.deepEqual(insuredOrder.insurance, { price: 5, amount: 10 })
|
||||
})
|
||||
|
||||
test('applies refunds and pops view history without mutation', () => {
|
||||
|
||||
Reference in New Issue
Block a user