diff --git a/modules/route/back/methods/agency-term/specs/filter.spec.js b/modules/route/back/methods/agency-term/specs/filter.spec.js index c47b14c95..b6729db2b 100644 --- a/modules/route/back/methods/agency-term/specs/filter.spec.js +++ b/modules/route/back/methods/agency-term/specs/filter.spec.js @@ -5,6 +5,14 @@ describe('AgencyTerm filter()', () => { const today = Date.vnNew(); today.setHours(2, 0, 0, 0); let ctx = beforeAll.getCtx(); + beforeAll(async() => { + ctx = { + req: { + accessToken: {}, + headers: {origin: 'http://localhost'}, + } + }; + }); it('should return all results matching the filter', async() => { const tx = await models.AgencyTerm.beginTransaction({}); diff --git a/modules/route/back/methods/route/specs/summary.spec.js b/modules/route/back/methods/route/specs/summary.spec.js index 6eaeba3d4..522a19bd4 100644 --- a/modules/route/back/methods/route/specs/summary.spec.js +++ b/modules/route/back/methods/route/specs/summary.spec.js @@ -1,35 +1,51 @@ const app = require('vn-loopback/server/server'); describe('route summary()', () => { + let ctx = beforeAll.getCtx(); + beforeAll(async() => { + ctx = { + req: { + accessToken: {}, + headers: {origin: 'http://localhost'}, + } + }; + }); + it('should return a summary object containing data from one route', async() => { - const result = await app.models.Route.summary(ctx, 1); + const filter = { + id: 1 + }; + const result = await app.models.Route.summary(ctx, filter); expect(result.route.id).toEqual(1); }); it(`should return a summary object containing it's agency`, async() => { - const result = await app.models.Route.summary(ctx, 1); + const filter = { + id: 1 + }; + const result = await app.models.Route.summary(ctx, filter); const agency = result.route.agencyMode(); expect(agency.name).toEqual('inhouse pickup'); }); it(`should return a summary object containing it's vehicle`, async() => { - const result = await app.models.Route.summary(ctx, 1); + const result = await app.models.Route.summary(ctx, filter); const vehicle = result.route.vehicle(); expect(vehicle.numberPlate).toEqual('3333-BAT'); }); it(`should return a summary object containing it's worker`, async() => { - const result = await app.models.Route.summary(ctx, 1); + const result = await app.models.Route.summary(ctx, filter); const worker = result.route.worker().user(); expect(worker.name).toEqual('delivery'); }); it(`should return a summary object containing data from the tickets`, async() => { - const result = await app.models.Route.summary(ctx, 2); + const result = await app.models.Route.summary(ctx, filter); expect(result.tickets.length).toEqual(1); });