21 lines
1.5 KiB
TypeScript
21 lines
1.5 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|||
|
|
import { overseasHttp } from '@/shared/api/overseasHttp'
|
||
|
|
import { listContainerArrivalTimes, updateContainerExpectedArrival } from './containerArrivalTimes'
|
||
|
|
|
||
|
|
vi.mock('@/shared/api/overseasHttp', () => ({ overseasHttp: { post: vi.fn(), put: vi.fn() } }))
|
||
|
|
|
||
|
|
describe('container arrival-time overseas API', () => {
|
||
|
|
beforeEach(() => vi.clearAllMocks())
|
||
|
|
|
||
|
|
it('queries visible containers and updates the whole-container expected arrival', async () => {
|
||
|
|
vi.mocked(overseasHttp.post).mockResolvedValue({ code: '200', data: [{ sourceContainerBookingId: '9001', estimatedWarehouseArrivalAt: null, actualWarehouseArrivalAt: null, version: 0 }] })
|
||
|
|
vi.mocked(overseasHttp.put).mockResolvedValue({ code: '200', data: { sourceContainerBookingId: '9001', estimatedWarehouseArrivalAt: '2026-09-25T15:31:00', actualWarehouseArrivalAt: null, version: 1 } } as never)
|
||
|
|
|
||
|
|
await listContainerArrivalTimes(['9001'])
|
||
|
|
await updateContainerExpectedArrival('9001', { estimatedWarehouseArrivalAt: '2026-09-25T15:31:00', expectedVersion: 0 })
|
||
|
|
|
||
|
|
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/orders/container-arrival-times/query', { sourceContainerBookingIds: ['9001'] })
|
||
|
|
expect(overseasHttp.put).toHaveBeenCalledWith('/platform/v1/last-leg/orders/container-summaries/9001/expected-arrival', { estimatedWarehouseArrivalAt: '2026-09-25T15:31:00', expectedVersion: 0 }, { headers: { 'Idempotency-Key': expect.stringContaining('container-expected-arrival-9001-') } })
|
||
|
|
})
|
||
|
|
})
|