7152-devToTest_2414 #2228
|
@ -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'
|
||||
}
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/ticket-collection/getUncheckedTicket')(Self);
|
||||
require('../methods/ticket-collection/hasUncheckedTicket')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue