#547 ticket/new.js Backend unit tests plus order new refactor
This commit is contained in:
parent
2bbbdcb55e
commit
e925146c73
|
@ -0,0 +1,33 @@
|
|||
const app = require(`${servicesDir}/ticket/server/server`);
|
||||
|
||||
describe('ticket new()', () => {
|
||||
it('should throw an error if the address doesnt exist', async() => {
|
||||
let error;
|
||||
let params = {addressFk: 'invalid address', clientFk: 101};
|
||||
|
||||
await app.models.Ticket.new(params)
|
||||
.catch(response => {
|
||||
expect(response.message).toEqual(`This address doesn't exist`);
|
||||
error = response;
|
||||
});
|
||||
|
||||
expect(error).toBeDefined();
|
||||
});
|
||||
|
||||
it('should return the id of the created ticket', async() => {
|
||||
let params = {
|
||||
warehouseFk: 1,
|
||||
clientFk: 101,
|
||||
companyFk: 442,
|
||||
addressFk: 25516,
|
||||
agencyModeFk: 1,
|
||||
userId: 9
|
||||
};
|
||||
|
||||
ticketId = await app.models.Ticket.new(params);
|
||||
|
||||
let newestTicketIdInFixtures = 21;
|
||||
|
||||
expect(ticketId).toBeGreaterThan(newestTicketIdInFixtures);
|
||||
});
|
||||
});
|
|
@ -59,7 +59,7 @@ describe('order new()', () => {
|
|||
|
||||
let orderId = await app.models.Order.new(params);
|
||||
|
||||
let highestOrderIdInFixtures = 4;
|
||||
let highestOrderIdInFixtures = 3;
|
||||
|
||||
expect(orderId).toBeGreaterThan(highestOrderIdInFixtures);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue