WIP: fix: refs #7917 fix methods, tests, acls #3085

Draft
carlossa wants to merge 12 commits from 7917-freelancerRoute into dev
1 changed files with 35 additions and 31 deletions
Showing only changes of commit 0c4985604b - Show all commits

View File

@ -2,17 +2,9 @@ const app = require('vn-loopback/server/server');
const models = require('vn-loopback/server/server').models;
describe('AgencyTerm filter()', () => {
const authUserId = 9;
let ctx;
const today = Date.vnNew();
today.setHours(2, 0, 0, 0);
beforeAll(async() => {
ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
}
};
});
let ctx = beforeAll.getCtx();
it('should return all results matching the filter', async() => {
const tx = await models.AgencyTerm.beginTransaction({});
@ -35,26 +27,33 @@ describe('AgencyTerm filter()', () => {
});
it('should return results matching "search" searching by integer', async() => {
ctx = {
args: {
search: 1,
}
// ctx = {
// args: {
// search: 1,
// }

posau comú en la par superior, en el beforeall hi ha exemples

posau comú en la par superior, en el beforeall hi ha exemples
// };
const filter = {
order: 'isActive ASC, name',
search: 1
};
let result = await app.models.AgencyTerm.filter(ctx);
let result = await app.models.AgencyTerm.filter(ctx, filter);
expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(1);
});
it('should return results matching "search" searching by string', async() => {
ctx = {
args: {
search: 'Plants SL',
}
// ctx = {
// args: {
// search: 'Plants SL',
// }
// };
const filter = {
search: 'Plants SL'
};
let result = await app.models.AgencyTerm.filter(ctx);
let result = await app.models.AgencyTerm.filter(ctx, filter);
expect(result.length).toEqual(2);
});
@ -82,26 +81,31 @@ describe('AgencyTerm filter()', () => {
});
it('should return results matching "agencyModeFk"', async() => {
ctx = {
args: {
// ctx = {
// args: {
// agencyModeFk: 1,
// }
// };
const filter = {
agencyModeFk: 1,
}
};
let result = await app.models.AgencyTerm.filter(ctx);
let result = await app.models.AgencyTerm.filter(ctx, filter);
expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(1);
});
it('should return results matching "agencyFk"', async() => {
ctx = {
args: {
agencyFk: 2,
}
};
// ctx = {
// args: {
// agencyFk: 2,
// }
// };
let result = await app.models.AgencyTerm.filter(ctx);
const filter = {
agencyFk: 2
};
let result = await app.models.AgencyTerm.filter(ctx, filter);
expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(2);