WIP: fix: refs #7917 fix methods, tests, acls #3085
|
@ -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({});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue