refs #3520 feat:uncheckedTicket
This commit is contained in:
parent
caf99a9738
commit
b805a5de0a
|
@ -1,5 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('getUncheckedTicket', {
|
Self.remoteMethod('hasUncheckedTicket', {
|
||||||
description:
|
description:
|
||||||
'Get boolean if the collection of ticket has a ticket not checked',
|
'Get boolean if the collection of ticket has a ticket not checked',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
|
@ -14,7 +14,7 @@ module.exports = Self => {
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
path: `/getUncheckedTicket`,
|
path: `/hasUncheckedTicket`,
|
||||||
verb: 'GET'
|
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 => {
|
module.exports = Self => {
|
||||||
require('../methods/ticket-collection/getUncheckedTicket')(Self);
|
require('../methods/ticket-collection/hasUncheckedTicket')(Self);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue