34 lines
1.7 KiB
JavaScript
34 lines
1.7 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import test from 'node:test'
|
|
import ts from 'typescript'
|
|
|
|
const source = readFileSync(new URL('./unifiedOrders.ts', import.meta.url), 'utf8')
|
|
|
|
test('forwards optional tax mode and pagination through the current GET endpoint', async () => {
|
|
const calls = []
|
|
const code = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText
|
|
const api = {}
|
|
new Function('require', 'exports', code)(id => {
|
|
assert.equal(id, '@/api/http')
|
|
return { apiRequest: async config => { calls.push(config); return { records: [] } } }
|
|
}, api)
|
|
await api.getMerchantUnifiedOrders({ page: 2, size: 200, taxMode: 'TAX_REFUND' })
|
|
await api.getMerchantUnifiedOrders({ taxMode: 'BUY_DECLARATION' })
|
|
await api.getMerchantUnifiedOrders()
|
|
assert.deepEqual(calls, [
|
|
{ method: 'GET', url: '/merchant/v1/orders', params: { page: 2, size: 200, taxMode: 'TAX_REFUND' } },
|
|
{ method: 'GET', url: '/merchant/v1/orders', params: { page: 1, size: 200, taxMode: 'BUY_DECLARATION' } },
|
|
{ method: 'GET', url: '/merchant/v1/orders', params: { page: 1, size: 200 } },
|
|
])
|
|
})
|
|
|
|
test('keeps the merchant unified-order boundary and one-click palletization status', () => {
|
|
assert.match(source, /const unifiedOrderBaseUrl = '\/merchant\/v1\/orders'/)
|
|
assert.match(source, /ApiUnifiedOrderMainStatus[\s\S]*?'WAIT_PALLETIZE'/)
|
|
assert.match(source, /ApiUnifiedOrderMainStatus[\s\S]*?'WAIT_SPLIT'/)
|
|
assert.match(source, /fulfillmentType\?: 'STANDARD' \| 'ONE_CLICK_DROPSHIP' \| null/)
|
|
assert.match(source, /lxCode\?: string \| null/)
|
|
assert.match(source, /mainStatus\?: ApiUnifiedOrderMainStatus/)
|
|
})
|