#1681 crear test para el endpoint getPossibleStowaways
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
f0253fd1ce
commit
c6507fc2bb
|
@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('getPossibleStowaways', {
|
Self.remoteMethod('getPossibleStowaways', {
|
||||||
description: 'Returns mana of a salesperson of a ticket',
|
description: 'Returns a list of allowed tickets for a stowaway ticket',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'id',
|
arg: 'id',
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
const app = require('vn-loopback/server/server');
|
||||||
|
let UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
describe('ticket getPossibleStowaways()', () => {
|
||||||
|
it(`should throw an error if Can't create stowaway for this ticket`, async() => {
|
||||||
|
let error;
|
||||||
|
let ticketId = 10;
|
||||||
|
|
||||||
|
await app.models.Ticket.getPossibleStowaways(ticketId)
|
||||||
|
.catch(e => {
|
||||||
|
error = e;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(error).toEqual(new UserError(`Can't create stowaway for this ticket`));
|
||||||
|
});
|
||||||
|
// EL TICKET 12 DEVUELVE UNA LISTA VACIA
|
||||||
|
it('should return an empty list of tickets for a valid ticket', async() => {
|
||||||
|
let ticketId = 12;
|
||||||
|
let possibleStowaways = await app.models.Ticket.getPossibleStowaways(ticketId);
|
||||||
|
|
||||||
|
expect(possibleStowaways.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return allowed list of tickets for a valid ticket', async() => {
|
||||||
|
let ticketId = 16;
|
||||||
|
let possibleStowaways = await app.models.Ticket.getPossibleStowaways(ticketId);
|
||||||
|
|
||||||
|
expect(possibleStowaways.length).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue