fix: refs #8515 Fix test optimizePriority
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Guillermo Bonet 2025-02-04 07:47:28 +01:00
parent 8240dd655d
commit fb8973a358
1 changed files with 12 additions and 2 deletions

View File

@ -1,7 +1,16 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const routeId = 1; const routeId = 1;
describe('route optimizePriority())', function() { fdescribe('route optimizePriority()', function() {
beforeEach(() => {
spyOn(models.OsrmConfig, 'optimize').and.returnValue(
Promise.resolve([
{addressId: 1, position: 0},
{addressId: 2, position: 1}
])
);
});
it('should execute without throwing errors', async function() { it('should execute without throwing errors', async function() {
const tx = await models.Route.beginTransaction({}); const tx = await models.Route.beginTransaction({});
let error; let error;
@ -20,9 +29,10 @@ describe('route optimizePriority())', function() {
} }
expect(error).toBeUndefined(); expect(error).toBeUndefined();
expect(models.OsrmConfig.optimize).toHaveBeenCalled();
}); });
it('should execute with error', async function() { it('should execute with error when all tickets have a route order', async function() {
let error; let error;
try { try {
await models.Route.optimizePriority(routeId); await models.Route.optimizePriority(routeId);