refs #3520 feat:uncheckedTicket

This commit is contained in:
Sergio De la torre 2024-03-26 12:40:44 +01:00
parent caf99a9738
commit b805a5de0a
3 changed files with 38 additions and 3 deletions

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);
};