优化
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { cargoRequirementNegativeCases } from './orders.mjs'
|
||||
|
||||
const payload = { destinationType: 'FBA', fulfillmentType: 'STANDARD', customsInspection: true,
|
||||
shipmentId: 'SHIP-1', cargoes: [{ skuNo: 'SKU-1', packageCount: 2, unitsPerPackage: 3,
|
||||
totalQuantity: 6, referenceId: 'TRACK-1', woodenProduct: false, lengthCm: 10, packingGroupNo: 'GROUP-1' }] }
|
||||
|
||||
test('FBA negatives independently remove order identifiers and per-line identifiers without mutating source', () => {
|
||||
const before = structuredClone(payload)
|
||||
const cases = cargoRequirementNegativeCases(payload)
|
||||
assert.equal(cases.length, 5)
|
||||
assert.equal(cases.find(item => item.name.includes('订单货件')).body.shipmentId, null)
|
||||
assert.equal(cases.find(item => item.name.includes('逐行跟踪')).body.cargoes[0].referenceId, null)
|
||||
assert.deepEqual(payload, before)
|
||||
})
|
||||
|
||||
test('overseas and private standard paths retain destination type and common declaration constraints', () => {
|
||||
for (const destinationType of ['OVERSEAS', 'PRIVATE']) {
|
||||
const cases = cargoRequirementNegativeCases({ ...payload, destinationType })
|
||||
assert.equal(cases.length, 3)
|
||||
assert.ok(cases.every(item => item.body.destinationType === destinationType))
|
||||
assert.ok(cases.every(item => !item.name.startsWith('FBA')))
|
||||
}
|
||||
})
|
||||
|
||||
test('dropship checks required SKU and inconsistent physical carton grouping', () => {
|
||||
const cases = cargoRequirementNegativeCases({ ...payload, destinationType: 'OVERSEAS', fulfillmentType: 'ONE_CLICK_DROPSHIP' })
|
||||
assert.equal(cases.length, 5)
|
||||
assert.equal(cases.find(item => item.name.includes('缺少SKU')).body.cargoes[0].skuNo, null)
|
||||
const mixed = cases.find(item => item.name.includes('混箱')).body.cargoes
|
||||
assert.equal(mixed[0].packingGroupNo, mixed[1].packingGroupNo)
|
||||
assert.notEqual(mixed[0].lengthCm, mixed[1].lengthCm)
|
||||
})
|
||||
Reference in New Issue
Block a user