#568 ticket-packaging.js Backend unit tests

This commit is contained in:
Carlos Jimenez 2018-08-07 15:04:06 +02:00
parent 83381b4c70
commit e094fe4456
1 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket model TicketTracking', () => {
let ticketTrackingId;
afterAll(async() => {
await app.models.TicketPackaging.destroyById(ticketTrackingId);
});
it('should save a ticketTraing as the quantity is greater than 0', async() => {
let result = await app.models.TicketPackaging.create({ticketFk: 1, quantity: 1, packagingFk: 1});
expect(result).toBeTruthy();
ticketTrackingId = result.id;
});
it('should return an error as the quantity is 0', async() => {
let error;
try {
await app.models.TicketPackaging.create({ticketFk: 1, quantity: 0, packagingFk: 1});
} catch (e) {
error = e;
}
expect(error.message).toContain('Enter an integer different to zero');
});
it('should return an error as the quantity isnt a number', async() => {
let error;
try {
await app.models.TicketPackaging.create({ticketFk: 1, quantity: 'random string', packagingFk: 1});
} catch (e) {
error = e;
}
expect(error.message).toContain('Enter an integer different to zero');
});
});