#1437 unitarios back guessPriority
This commit is contained in:
parent
921af523f8
commit
a0f0230e76
|
@ -0,0 +1,41 @@
|
||||||
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('route guessPriority()', () => {
|
||||||
|
const targetRouteId = 2;
|
||||||
|
let routeTicketsToRestore;
|
||||||
|
|
||||||
|
afterAll(async done => {
|
||||||
|
let restoreFixtures = [];
|
||||||
|
routeTicketsToRestore.forEach(ticket => {
|
||||||
|
restoreFixtures.push(ticket.updateAttribute('priority', null));
|
||||||
|
});
|
||||||
|
await Promise.all(restoreFixtures);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should confirm the tickets in the target route have no priority yet', async() => {
|
||||||
|
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
|
||||||
|
|
||||||
|
expect(routeTicketsToRestore.length).toEqual(3);
|
||||||
|
expect(routeTicketsToRestore[0].priority).toBeNull();
|
||||||
|
expect(routeTicketsToRestore[0].id).toEqual(7);
|
||||||
|
expect(routeTicketsToRestore[1].priority).toBeNull();
|
||||||
|
expect(routeTicketsToRestore[1].id).toEqual(8);
|
||||||
|
expect(routeTicketsToRestore[2].priority).toBeNull();
|
||||||
|
expect(routeTicketsToRestore[2].id).toEqual(9);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call guessPriority() and then check the tickets in the target route now have their priorities defined', async() => {
|
||||||
|
await app.models.Route.guessPriority(targetRouteId);
|
||||||
|
let routeTickets = await app.models.Ticket.find({where: {routeFk: targetRouteId}, fields: ['id', 'priority']});
|
||||||
|
|
||||||
|
expect(routeTickets.length).toEqual(3);
|
||||||
|
expect(routeTickets[0].priority).toEqual(1);
|
||||||
|
expect(routeTickets[0].id).toEqual(7);
|
||||||
|
expect(routeTickets[1].priority).toEqual(3);
|
||||||
|
expect(routeTickets[1].id).toEqual(8);
|
||||||
|
expect(routeTickets[2].priority).toEqual(2);
|
||||||
|
expect(routeTickets[2].id).toEqual(9);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue