From 146f3c813963b13a29bb8e5521daaa2ba46daeb1 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 28 Sep 2018 13:55:21 +0200 Subject: [PATCH] #685 PROCEDURE unit test vn.logAddWithUser --- .../importToNewRefundTicket.js | 1 + services/db/tests/vn/logAddWithUser.spec.js | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 services/db/tests/vn/logAddWithUser.spec.js diff --git a/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js b/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js index dcdd0e914..971f83933 100644 --- a/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js +++ b/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js @@ -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; diff --git a/services/db/tests/vn/logAddWithUser.spec.js b/services/db/tests/vn/logAddWithUser.spec.js new file mode 100644 index 000000000..da85168e2 --- /dev/null +++ b/services/db/tests/vn/logAddWithUser.spec.js @@ -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); + }); +});