31 lines
1.7 KiB
TypeScript
31 lines
1.7 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { overseasHttp } from '@/shared/api/overseasHttp'
|
|
import { getInventorySummary, listInventoryBalances, listInventoryLedger, listInventoryPositions } 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 = { 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: { page: 1, size: 200, skuCode: 'SKU-1', warehouseLocationCode: 'A-01' } })
|
|
})
|
|
|
|
it('uses the read-only position and ledger endpoints without customer scope', async () => {
|
|
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', data: [] })
|
|
|
|
await listInventoryPositions('190000000000000099')
|
|
await listInventoryLedger({ page: 1, size: 20, skuCode: 'SKU-1' })
|
|
|
|
expect(overseasHttp.get).toHaveBeenNthCalledWith(1, '/platform/v1/last-leg/inventory/balances/190000000000000099/positions', { params: {} })
|
|
expect(overseasHttp.get).toHaveBeenNthCalledWith(2, '/platform/v1/last-leg/inventory/ledger', { params: { page: 1, size: 20, skuCode: 'SKU-1' } })
|
|
})
|
|
})
|