Merge pull request 'fix: refs #8515 Fix test optimizePriority' (!3414) from 8515-fixTestOptimizePriority into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #3414
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Guillermo Bonet 2025-02-04 11:39:41 +00:00
commit 3bb0d52dde
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() { describe('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);