19 lines
811 B
TypeScript
19 lines
811 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { shouldClearBookingAgent } from './bookingAgents'
|
|
|
|
describe('ocean booking agent candidates', () => {
|
|
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('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)
|
|
})
|
|
})
|