import { describe, expect, it } from 'vitest' import { matchesSmartDispatchWarehouseTab } from './smartDispatchWarehouseTab' describe('smart dispatch warehouse tabs', () => { it('uses the overseas warehouse code when the warehouse name is unavailable', () => { const losAngeles = { overseasWarehouseCode: 'US-LAX-01', overseasWarehouseName: null } const newYork = { overseasWarehouseCode: 'US-NY-01', overseasWarehouseName: null } expect(matchesSmartDispatchWarehouseTab(losAngeles, 'LAX')).toBe(true) expect(matchesSmartDispatchWarehouseTab(losAngeles, 'NYC')).toBe(false) expect(matchesSmartDispatchWarehouseTab(newYork, 'NYC')).toBe(true) expect(matchesSmartDispatchWarehouseTab(newYork, 'LAX')).toBe(false) }) it('keeps the all tab unfiltered and supports warehouse names as a fallback', () => { const warehouse = { overseasWarehouseCode: null, overseasWarehouseName: '洛杉矶接柜仓' } expect(matchesSmartDispatchWarehouseTab(warehouse, 'ALL')).toBe(true) expect(matchesSmartDispatchWarehouseTab(warehouse, 'LAX')).toBe(true) }) })