15 lines
1.0 KiB
TypeScript
15 lines
1.0 KiB
TypeScript
import { expect, it, vi } from 'vitest'
|
|||
|
|
import { http } from '@/shared/api/http'
|
||
|
|
import { listPlanningCargo } from './planningApi'
|
||
|
|
vi.mock('@/shared/api/http', () => ({ http: { get: vi.fn() }, unwrapApiResponse: <T>(value: { data: T }) => value.data }))
|
||
|
|
|
||
|
|
it('uses the gateway planning route and preserves stable source IDs and null predictions', async () => {
|
||
|
|
vi.mocked(http.get).mockResolvedValue({ data: { records: [{ sourceKey: 'ORDER:9007199254740993', orderId: '9007199254740993', estimatedArrivalAt: null }], page: '2', size: '20', total: '21', pages: '2' } })
|
||
|
|
const controller = new AbortController()
|
||
|
|
const result = await listPlanningCargo({ page: 2, size: 20, keyword: 'IN-A' }, controller.signal)
|
||
|
|
expect(http.get).toHaveBeenCalledWith('/platform/v1/last-leg/appointment-planning/cargo', { params: { page: 2, size: 20, keyword: 'IN-A' }, signal: controller.signal })
|
||
|
|
expect(result.records[0]!.orderId).toBe('9007199254740993')
|
||
|
|
expect(result.records[0]!.estimatedArrivalAt).toBeNull()
|
||
|
|
expect(result.total).toBe(21)
|
||
|
|
})
|