74 lines
1.6 KiB
JavaScript
74 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const StorageReceivingService = require('../../../../../app/service/systemMethods/storage/receiving');
|
|
|
|
function createHarness(storeId = 100321) {
|
|
const calls = {};
|
|
|
|
const ctx = {
|
|
app: {
|
|
config: {},
|
|
},
|
|
user: {
|
|
store_id: storeId,
|
|
},
|
|
service: {
|
|
systems: {
|
|
operationLog: {
|
|
async queryReceivingLogs(query) {
|
|
calls.queryReceivingLogs = query;
|
|
return {
|
|
list: [{ id: 1 }],
|
|
pagination: {
|
|
page: Number(query.page || 1),
|
|
pageSize: Number(query.pageSize || 20),
|
|
total: 1,
|
|
totalPages: 1,
|
|
},
|
|
};
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
return {
|
|
service: new StorageReceivingService(ctx),
|
|
calls,
|
|
};
|
|
}
|
|
|
|
describe('test/app/service/systemMethods/storage/queryReceivingLogs.test.js', () => {
|
|
it('should inject current store_id and support pagination object', async () => {
|
|
const { service, calls } = createHarness(100321);
|
|
|
|
const result = await service.queryReceivingLogs({
|
|
receiving_id: 99,
|
|
pagination: {
|
|
page: 3,
|
|
pageSize: 15,
|
|
},
|
|
});
|
|
|
|
assert.deepEqual(calls.queryReceivingLogs, {
|
|
id: 99,
|
|
page: 3,
|
|
pageSize: 15,
|
|
warehouseId: 100321,
|
|
});
|
|
assert.equal(result.flag, 'success');
|
|
assert.equal(result.message, 'ok');
|
|
assert.equal(result.code, 200);
|
|
assert.deepEqual(result.data, {
|
|
list: [{ id: 1 }],
|
|
pagination: {
|
|
page: 3,
|
|
pageSize: 15,
|
|
total: 1,
|
|
totalPages: 1,
|
|
},
|
|
});
|
|
});
|
|
});
|