salix/services/db/tests/vn/logAddWithUser.spec.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
describe('logAddWithUser()', () => {
2018-11-21 10:50:30 +00:00
it('should log any action taken by the user in a table ending in Log', async () => {
let stmts = [];
let stmt;
stmts.push('START TRANSACTION');
let params = {
ticketFk: 1,
userId: 9,
actionCode: 'update',
targetEntity: 'ticket',
description: 'we are testing stuff'
};
stmt = new ParameterizedSQL('CALL vn.logAddWithUser(?, ?, ?, ?, ?)', [
params.ticketFk,
params.userId,
params.actionCode,
params.targetEntity,
params.description
]);
stmts.push(stmt);
stmt = new ParameterizedSQL('SELECT * FROM vn.ticketLog WHERE description = ?', [
params.description
]);
let ticketLogIndex = stmts.push(stmt) - 1;
stmts.push('ROLLBACK');
let sql = ParameterizedSQL.join(stmts, ';');
let result = await app.models.Ticket.rawStmt(sql);
savedDescription = result[ticketLogIndex][0].description;
expect(savedDescription).toEqual(params.description);
});
});