2018-08-21 06:08:39 +00:00
|
|
|
const app = require(`${servicesDir}/ticket/server/server`);
|
|
|
|
|
|
|
|
describe('ticket new()', () => {
|
2018-10-03 08:50:09 +00:00
|
|
|
let ticketId;
|
|
|
|
let today = new Date();
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await app.models.Ticket.destroyById(ticketId);
|
|
|
|
});
|
|
|
|
|
2018-08-21 06:08:39 +00:00
|
|
|
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,
|
2018-09-06 08:42:43 +00:00
|
|
|
addressFk: 1,
|
2018-08-21 06:08:39 +00:00
|
|
|
agencyModeFk: 1,
|
2018-10-03 08:50:09 +00:00
|
|
|
userId: 9,
|
|
|
|
shipped: today,
|
|
|
|
landed: today
|
2018-08-21 06:08:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ticketId = await app.models.Ticket.new(params);
|
|
|
|
|
|
|
|
let newestTicketIdInFixtures = 21;
|
|
|
|
|
|
|
|
expect(ticketId).toBeGreaterThan(newestTicketIdInFixtures);
|
|
|
|
});
|
|
|
|
});
|