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

This commit is contained in:
Carlos Satorres 2024-11-18 10:53:52 +01:00
parent bbe62ece6e
commit 0c4985604b
1 changed files with 35 additions and 31 deletions

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,
// }
// };
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);