64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const StorageAllocationMethodService = require('../../../../../app/service/systemMethods/order/storageAllocation');
|
|
|
|
/**
|
|
* 创建系统方法测试上下文。
|
|
*
|
|
* @return {{ ctx: Object, capture: Object }} 测试上下文。
|
|
*/
|
|
function createHarness() {
|
|
const capture = {
|
|
request: null,
|
|
};
|
|
|
|
const ctx = {
|
|
app: {},
|
|
service: {
|
|
systems: {
|
|
orderStorageAllocation: {
|
|
async allocateStorage(request) {
|
|
capture.request = request;
|
|
return {
|
|
code: 200,
|
|
message: '储位分配完成',
|
|
data: {
|
|
ok: true,
|
|
},
|
|
};
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
return {
|
|
ctx,
|
|
capture,
|
|
};
|
|
}
|
|
|
|
describe('test/app/service/systemMethods/order/storageAllocation.test.js', () => {
|
|
it('should normalize allocation input before delegating to the public service', async () => {
|
|
const { ctx, capture } = createHarness();
|
|
const service = new StorageAllocationMethodService(ctx);
|
|
|
|
const result = await service.allocateStorage({
|
|
allowStorageLocation: true,
|
|
ids: '1,2,3',
|
|
warehouseId: 100000,
|
|
});
|
|
|
|
assert.deepEqual(capture.request, {
|
|
allow_storage_location: true,
|
|
order_ids: '1,2,3',
|
|
warehouse_id: 100000,
|
|
});
|
|
assert.equal(result.flag, 'success');
|
|
assert.equal(result.message, '储位分配完成');
|
|
assert.equal(result.code, 200);
|
|
assert.deepEqual(result.data, { ok: true });
|
|
});
|
|
});
|