Files
admin-web/src/modules/overseas-warehouse/api/inboundPlans.test.ts
T

19 lines
1.4 KiB
TypeScript
Raw Normal View History

2026-08-20 18:02:52 +08:00
import { beforeEach, describe, expect, it, vi } from 'vitest'
2026-09-29 17:56:00 +08:00
import { http } from '@/shared/api/http'
2026-08-20 18:02:52 +08:00
import { getInboundPlan, listInboundPlans } from './inboundPlans'
2026-09-29 17:56:00 +08:00
vi.mock('@/shared/api/http', async (importOriginal) => ({ ...(await importOriginal<typeof import('@/shared/api/http')>()), http: { get: vi.fn() } }))
2026-08-20 18:02:52 +08:00
describe('inbound plan overseas API', () => {
2026-09-29 17:56:00 +08:00
beforeEach(() => vi.mocked(http.get).mockReset())
2026-08-20 18:02:52 +08:00
it('pages plans with explicit customer scope', async () => {
2026-09-29 17:56:00 +08:00
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'ok', data: { records: [], page: 1, size: 20, total: 0, pages: 0 } })
2026-08-20 18:02:52 +08:00
await listInboundPlans({ customerId: '190000000000000001', page: 1, size: 20, inboundCode: 'IN-1' })
2026-09-29 17:56:00 +08:00
expect(http.get).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans', { params: { customerId: '190000000000000001', page: 1, size: 20, inboundCode: 'IN-1' } })
2026-08-20 18:02:52 +08:00
})
it('gets detail by encoded plan number', async () => {
2026-09-29 17:56:00 +08:00
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'ok', data: { id: '1', planNo: 'IP/1', customerId: '2', sourceOrderId: '190000000000000099', lineCount: 0, palletCount: 0, totalGrossWeightKg: 0, totalNetWeightKg: 0, totalVolumeCbm: 0, lines: [], pallets: [], allocations: [] } })
2026-08-20 18:02:52 +08:00
await getInboundPlan('IP/1', '2')
2026-09-29 17:56:00 +08:00
expect(http.get).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans/IP%2F1', { params: { customerId: '2' } })
2026-08-20 18:02:52 +08:00
})
})