59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const { strict: assert } = require('node:assert');
|
|
const { app } = require('egg-mock/bootstrap');
|
|
|
|
describe('test/app/controller/system.test.js', () => {
|
|
|
|
it('POST /system someAction 调用 new_wms.queryOrder', async () => {
|
|
const res = await app.httpRequest()
|
|
.post('/system')
|
|
.send({
|
|
name: 'someAction',
|
|
data: { barcode: 'TEST001', warehouseId: 'WH001' },
|
|
});
|
|
|
|
console.log('状态码:', res.status);
|
|
console.log('响应内容:', JSON.stringify(res.body, null, 2));
|
|
assert(res.body.data !== undefined);
|
|
});
|
|
|
|
it('POST /system query 调用 new_wms.queryOrder', async () => {
|
|
const res = await app.httpRequest()
|
|
.post('/system')
|
|
.send({
|
|
name: 'query',
|
|
data: { barcode: 'TEST002', warehouseId: 'WH001' },
|
|
});
|
|
|
|
console.log('状态码:', res.status);
|
|
console.log('响应内容:', JSON.stringify(res.body, null, 2));
|
|
assert(res.body.data !== undefined);
|
|
});
|
|
|
|
it('POST /system 缺少 name 应返回 400', async () => {
|
|
const res = await app.httpRequest()
|
|
.post('/system')
|
|
.send({
|
|
data: { barcode: 'TEST003', warehouseId: 'WH001' },
|
|
})
|
|
.expect(400);
|
|
|
|
assert(res.body.data.success === false);
|
|
assert(res.body.data.message === '缺少 name 参数');
|
|
});
|
|
|
|
it('POST /system 缺少必要参数应返回错误', async () => {
|
|
const res = await app.httpRequest()
|
|
.post('/system')
|
|
.send({
|
|
name: 'someAction',
|
|
data: {},
|
|
})
|
|
.expect(200);
|
|
|
|
console.log('响应内容:', JSON.stringify(res.body, null, 2));
|
|
assert(res.body.data.success === false);
|
|
});
|
|
});
|