models
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8b68fcf088
commit
a46b2113dc
|
@ -1,18 +1,9 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('route getSuggestedTickets()', () => {
|
||||
const routeID = 1;
|
||||
const ticketId = 12;
|
||||
beforeAll(() => {
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jasmine.clock().install();
|
||||
const baseTime = new Date('January 19, 2022 08:00:00');
|
||||
jasmine.clock().mockDate(baseTime);
|
||||
});
|
||||
|
||||
it('should return an array of suggested tickets', async() => {
|
||||
const activeCtx = {
|
||||
|
@ -24,18 +15,18 @@ describe('route getSuggestedTickets()', () => {
|
|||
active: activeCtx
|
||||
});
|
||||
|
||||
const tx = await app.models.Ticket.beginTransaction({});
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ticketInRoute = await app.models.Ticket.findById(ticketId, null, options);
|
||||
const ticketInRoute = await models.Ticket.findById(ticketId, null, options);
|
||||
|
||||
await ticketInRoute.updateAttributes({
|
||||
routeFk: null,
|
||||
landed: new Date()
|
||||
}, options);
|
||||
|
||||
const result = await app.models.Route.getSuggestedTickets(routeID, options);
|
||||
const result = await models.Route.getSuggestedTickets(routeID, options);
|
||||
|
||||
const length = result.length;
|
||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||
|
|
Loading…
Reference in New Issue