7152-devToTest_2414 #2228
|
@ -212,5 +212,7 @@
|
|||
"This worker does not exist": "This worker does not exist",
|
||||
"this state does not exist": "This state does not exist",
|
||||
"The line could not be marked": "The line could not be marked",
|
||||
"The sale can not be tracked": "The sale can not be tracked"
|
||||
"The sale can not be tracked": "The sale can not be tracked",
|
||||
"Shelving not valid": "Shelving not valid"
|
||||
|
||||
}
|
|
@ -350,5 +350,6 @@
|
|||
"The line could not be marked": "No se ha podido marcar la línea",
|
||||
"No se ha podido marcar la línea": "No se ha podido marcar la línea",
|
||||
"The sale can not be tracked": "La línea no puede ser rastreada",
|
||||
"La línea no puede ser rastreada": "La línea no puede ser rastreada"
|
||||
"Shelving not valid": "Carro no válido",
|
||||
"Carro no válido": "Carro no válido"
|
||||
}
|
|
@ -16,6 +16,7 @@ module.exports = Self => {
|
|||
});
|
||||
Self.addLog = async(ctx, code, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const $t = ctx.req.__;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
@ -35,7 +36,7 @@ module.exports = Self => {
|
|||
}
|
||||
}, myOptions);
|
||||
|
||||
if (!shelving) throw new UserError('Shelving not valid');
|
||||
if (!shelving) throw new UserError($t('Shelving not valid'));
|
||||
|
||||
await models.ShelvingLog.create({
|
||||
changedModel: 'Shelving',
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('shelving addLog()', () => {
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'},
|
||||
accessToken: {userId: 66},
|
||||
__: value => value
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should add a log', async() => {
|
||||
const tx = await models.SaleTracking.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const code = 'AA6';
|
||||
|
||||
try {
|
||||
const shelvingLogsBefore = await models.ShelvingLog.find(null, options);
|
||||
await models.Shelving.addLog(ctx, code, options);
|
||||
const shelvingLogsAfter = await models.ShelvingLog.find(null, options);
|
||||
|
||||
expect(shelvingLogsAfter.length).toEqual(shelvingLogsBefore.length + 1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error when the code does not exist', async() => {
|
||||
const tx = await models.SaleTracking.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const code = 'DXI345';
|
||||
|
||||
try {
|
||||
await models.Shelving.addLog(ctx, code, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('Shelving not valid');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue