This commit is contained in:
parent
57a77628dc
commit
5e7dea94b1
|
@ -3,8 +3,16 @@ 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}}},
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should return all results matching the filter', async() => {
|
||||
const tx = await models.AgencyTerm.beginTransaction({});
|
||||
|
@ -12,7 +20,6 @@ describe('AgencyTerm filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
const filter = {};
|
||||
const ctx = {req: {accessToken: {userId: authUserId}}};
|
||||
|
||||
const agencyTerms = await models.AgencyTerm.filter(ctx, filter, options);
|
||||
const firstAgencyTerm = agencyTerms[0];
|
||||
|
@ -28,9 +35,8 @@ describe('AgencyTerm filter()', () => {
|
|||
});
|
||||
|
||||
it('should return results matching "search" searching by integer', async() => {
|
||||
let ctx = {
|
||||
ctx = {
|
||||
args: {
|
||||
ctx: {req: {accessToken: {userId: authUserId}}},
|
||||
search: 1,
|
||||
}
|
||||
};
|
||||
|
@ -42,9 +48,8 @@ describe('AgencyTerm filter()', () => {
|
|||
});
|
||||
|
||||
it('should return results matching "search" searching by string', async() => {
|
||||
let ctx = {
|
||||
ctx = {
|
||||
args: {
|
||||
ctx: {req: {accessToken: {userId: authUserId}}},
|
||||
search: 'Plants SL',
|
||||
}
|
||||
};
|
||||
|
@ -65,14 +70,6 @@ describe('AgencyTerm filter()', () => {
|
|||
const to = Date.vnNew();
|
||||
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);
|
||||
|
||||
expect(results.length).toBe(5);
|
||||
|
@ -85,9 +82,8 @@ describe('AgencyTerm filter()', () => {
|
|||
});
|
||||
|
||||
it('should return results matching "agencyModeFk"', async() => {
|
||||
let ctx = {
|
||||
ctx = {
|
||||
args: {
|
||||
ctx: {req: {accessToken: {userId: authUserId}}},
|
||||
agencyModeFk: 1,
|
||||
}
|
||||
};
|
||||
|
@ -99,9 +95,8 @@ describe('AgencyTerm filter()', () => {
|
|||
});
|
||||
|
||||
it('should return results matching "agencyFk"', async() => {
|
||||
let ctx = {
|
||||
ctx = {
|
||||
args: {
|
||||
ctx: {req: {accessToken: {userId: authUserId}}},
|
||||
agencyFk: 2,
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue