21 lines
1.1 KiB
TypeScript
21 lines
1.1 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|||
|
|
import { overseasHttp } from '@/shared/api/overseasHttp'
|
||
|
|
import { getInventorySummary, listInventoryBalances } from './inventory'
|
||
|
|
|
||
|
|
vi.mock('@/shared/api/overseasHttp', () => ({ overseasHttp: { get: vi.fn() } }))
|
||
|
|
|
||
|
|
describe('overseas inventory API', () => {
|
||
|
|
beforeEach(() => { vi.clearAllMocks() })
|
||
|
|
|
||
|
|
it('keeps skuCode and nullable location filters on real balance queries', async () => {
|
||
|
|
vi.mocked(overseasHttp.get).mockResolvedValueOnce({ code: '200', data: { records: [], page: 1, size: 20, total: 0, pages: 0 } }).mockResolvedValueOnce({ code: '200', data: { totalPackages: 0 } })
|
||
|
|
const query = { customerId: '100', page: 1, size: 20, skuCode: 'SKU-1', warehouseLocationCode: 'A-01' }
|
||
|
|
|
||
|
|
await listInventoryBalances(query)
|
||
|
|
await getInventorySummary(query)
|
||
|
|
|
||
|
|
expect(overseasHttp.get).toHaveBeenNthCalledWith(1, '/platform/v1/last-leg/inventory/balances', { params: query })
|
||
|
|
expect(overseasHttp.get).toHaveBeenNthCalledWith(2, '/platform/v1/last-leg/inventory/summary', { params: { customerId: '100', skuCode: 'SKU-1', warehouseLocationCode: 'A-01' } })
|
||
|
|
})
|
||
|
|
})
|