98 lines
2.5 KiB
JavaScript
98 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const OrderPrintService = require('../../../app/service/systemMethods/order/print');
|
|
const { createServiceContext } = require('../../support/order_service_test_helper');
|
|
|
|
describe('test/app/controller/system.order.print.platformData.test.js', () => {
|
|
it('should delegate getWavePlatformPrintData to systems.orderPrint with destructured params', async () => {
|
|
const ctx = createServiceContext(100000);
|
|
let capturedPayload = null;
|
|
const expectedData = {
|
|
summary: {
|
|
total_waves: 1,
|
|
total_orders: 1,
|
|
total_platforms: 1,
|
|
},
|
|
waveGroups: [
|
|
{
|
|
wave_id: 9001,
|
|
wave_no: 'W9001',
|
|
order_count: 1,
|
|
platforms: [
|
|
{
|
|
platform: 'jd',
|
|
platform_name: '京东',
|
|
order_count: 1,
|
|
orders: [
|
|
{
|
|
order_id: 123,
|
|
print_data: {
|
|
platform: 'jd',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
wave_ids: [ 9001 ],
|
|
platform_groups: [],
|
|
order_list: [],
|
|
ext: {
|
|
missing_wave_ids: [],
|
|
filtered_wave_ids: [],
|
|
},
|
|
};
|
|
|
|
ctx.service = {
|
|
systems: {
|
|
orderPrint: {
|
|
async getWavePlatformPrintData(payload) {
|
|
capturedPayload = payload;
|
|
return expectedData;
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const service = new OrderPrintService(ctx);
|
|
const result = await service.getWavePlatformPrintData({
|
|
wave_ids: [ 9001, '9002' ],
|
|
warehouse_id: 100000,
|
|
ignored_field: 'ignored',
|
|
});
|
|
|
|
assert.deepEqual(capturedPayload, {
|
|
waveIds: [ 9001, '9002' ],
|
|
warehouseId: 100000,
|
|
});
|
|
assert.equal(result.flag, 'success');
|
|
assert.equal(result.code, 200);
|
|
assert.equal(result.message, 'ok');
|
|
assert.deepEqual(result.data, expectedData);
|
|
});
|
|
|
|
it('should reject when wave_ids is empty', async () => {
|
|
const ctx = createServiceContext(100000);
|
|
ctx.service = {
|
|
systems: {
|
|
orderPrint: {
|
|
async getWavePlatformPrintData() {
|
|
return {};
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const service = new OrderPrintService(ctx);
|
|
|
|
await assert.rejects(async () => {
|
|
await service.getWavePlatformPrintData({
|
|
wave_ids: [],
|
|
warehouse_id: 100000,
|
|
});
|
|
}, /wave_ids 必填,且必须为非空数组/);
|
|
});
|
|
});
|