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

This commit is contained in:
Carlos Satorres 2024-11-18 08:32:44 +01:00
parent 57a77628dc
commit 5e7dea94b1
1 changed files with 12 additions and 17 deletions

View File

@ -3,8 +3,16 @@ const models = require('vn-loopback/server/server').models;
describe('AgencyTerm filter()', () => { describe('AgencyTerm filter()', () => {
const authUserId = 9; const authUserId = 9;
let ctx;
const today = Date.vnNew(); const today = Date.vnNew();
today.setHours(2, 0, 0, 0); today.setHours(2, 0, 0, 0);
beforeAll(async() => {
ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
}
};
});
it('should return all results matching the filter', async() => { it('should return all results matching the filter', async() => {
const tx = await models.AgencyTerm.beginTransaction({}); const tx = await models.AgencyTerm.beginTransaction({});
@ -12,7 +20,6 @@ describe('AgencyTerm filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const filter = {}; const filter = {};
const ctx = {req: {accessToken: {userId: authUserId}}};
const agencyTerms = await models.AgencyTerm.filter(ctx, filter, options); const agencyTerms = await models.AgencyTerm.filter(ctx, filter, options);
const firstAgencyTerm = agencyTerms[0]; const firstAgencyTerm = agencyTerms[0];
@ -28,9 +35,8 @@ describe('AgencyTerm filter()', () => {
}); });
it('should return results matching "search" searching by integer', async() => { it('should return results matching "search" searching by integer', async() => {
let ctx = { ctx = {
args: { args: {
ctx: {req: {accessToken: {userId: authUserId}}},
search: 1, search: 1,
} }
}; };
@ -42,9 +48,8 @@ describe('AgencyTerm filter()', () => {
}); });
it('should return results matching "search" searching by string', async() => { it('should return results matching "search" searching by string', async() => {
let ctx = { ctx = {
args: { args: {
ctx: {req: {accessToken: {userId: authUserId}}},
search: 'Plants SL', search: 'Plants SL',
} }
}; };
@ -65,14 +70,6 @@ describe('AgencyTerm filter()', () => {
const to = Date.vnNew(); const to = Date.vnNew();
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
const ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
from: from,
to: to
}
};
const results = await models.AgencyTerm.filter(ctx, options); const results = await models.AgencyTerm.filter(ctx, options);
expect(results.length).toBe(5); expect(results.length).toBe(5);
@ -85,9 +82,8 @@ describe('AgencyTerm filter()', () => {
}); });
it('should return results matching "agencyModeFk"', async() => { it('should return results matching "agencyModeFk"', async() => {
let ctx = { ctx = {
args: { args: {
ctx: {req: {accessToken: {userId: authUserId}}},
agencyModeFk: 1, agencyModeFk: 1,
} }
}; };
@ -99,9 +95,8 @@ describe('AgencyTerm filter()', () => {
}); });
it('should return results matching "agencyFk"', async() => { it('should return results matching "agencyFk"', async() => {
let ctx = { ctx = {
args: { args: {
ctx: {req: {accessToken: {userId: authUserId}}},
agencyFk: 2, agencyFk: 2,
} }
}; };