#685 PROCEDURE unit test vn.logAddWithUser

This commit is contained in:
Carlos Jimenez 2018-09-28 13:55:21 +02:00
parent 8ce2912344
commit 146f3c8139
2 changed files with 32 additions and 0 deletions

View File

@ -121,6 +121,7 @@ module.exports = Self => {
insertIntoClaimEnd(createdSales, id, worker.id, {transaction: transaction});
await Self.rawSql('CALL vn.ticketCalculateClon(?)', [newRefundTicket], {transaction: transaction});
await transaction.commit();
return newRefundTicket;
} catch (e) {
await transaction.rollback();
throw e;

View File

@ -0,0 +1,31 @@
const app = require(`../../../ticket/server/server`);
describe('logAddWithUser()', () => {
it('should log any action taken by the user in a table ending in Log', async() => {
let params = {
ticketFk: 1,
userId: 9,
actionCode: 'update',
targetEntity: 'ticket',
description: 'we are testing stuff'
};
let query = `
START TRANSACTION;
CALL vn.logAddWithUser(?, ?, ?, ?, ?);
SELECT * FROM vn.ticketLog WHERE description = ?;
ROLLBACK;`;
let result = await app.models.Ticket.rawSql(query, [
params.ticketFk,
params.userId,
params.actionCode,
params.targetEntity,
params.description,
params.description
]);
savedDescription = result[2][0].description;
expect(savedDescription).toEqual(params.description);
});
});