7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
3 changed files with 38 additions and 3 deletions
Showing only changes of commit b805a5de0a - Show all commits

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethod('getUncheckedTicket', {
Self.remoteMethod('hasUncheckedTicket', {
description:
'Get boolean if the collection of ticket has a ticket not checked',
accessType: 'READ',
@ -14,7 +14,7 @@ module.exports = Self => {
root: true
},
http: {
path: `/getUncheckedTicket`,
path: `/hasUncheckedTicket`,
verb: 'GET'
}
});

View File

@ -0,0 +1,35 @@
const {models} = require('vn-loopback/server/server');
describe('ticketCollection hasUncheckedTicket()', () => {
fit('should return false because there are not tickets not checked', async() => {
const ticketFk = 1;
const result = await models.TicketCollection.hasUncheckedTicket(ticketFk);
expect(result).toBe(false);
});
it('should return true because there is a ticket not checked', async() => {
const ticketFk = 1;
const tx = await models.TicketTracking.beginTransaction({});
const myOptions = {transaction: tx};
const filter = {where: {
ticketFk: 1,
stateFk: 16}
};
try {
const ticketTracking = await models.TicketTracking.findOne(filter, myOptions);
await ticketTracking.updateAttributes({
stateFk: 7
});
const result = await models.TicketCollection.hasUncheckedTicket(ticketFk, myOptions);
expect(result).toBe(true);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -1,3 +1,3 @@
module.exports = Self => {
require('../methods/ticket-collection/getUncheckedTicket')(Self);
require('../methods/ticket-collection/hasUncheckedTicket')(Self);
};