feat(admin): filter booking agents by carrier
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isActiveBookingAgent } from './bookingAgents'
|
||||
import { shouldClearBookingAgent } from './bookingAgents'
|
||||
|
||||
describe('ocean booking agent candidates', () => {
|
||||
it('accepts an active booking supplier', () => {
|
||||
expect(isActiveBookingAgent({ category: 'BOOKING', status: 'ACTIVE' })).toBe(true)
|
||||
const options = [{ supplierId: '11', name: '代理A', carrierCodes: ['MATSON', 'COSCO'] as const }]
|
||||
|
||||
it('keeps an agent returned by the server-filtered carrier candidates', () => {
|
||||
expect(shouldClearBookingAgent('11', options.map((item) => ({ ...item, carrierCodes: [...item.carrierCodes] })))).toBe(false)
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ category: 'BOOKING', status: 'INACTIVE' },
|
||||
{ category: 'TRUCKING', status: 'ACTIVE' },
|
||||
])('rejects a non-eligible supplier: %o', (supplier) => {
|
||||
expect(isActiveBookingAgent(supplier)).toBe(false)
|
||||
it('clears an agent missing from the newly selected carrier candidates', () => {
|
||||
expect(shouldClearBookingAgent('12', options.map((item) => ({ ...item, carrierCodes: [...item.carrierCodes] })))).toBe(true)
|
||||
})
|
||||
|
||||
it('does not clear an empty selection', () => {
|
||||
expect(shouldClearBookingAgent(null, [])).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user