fix: refs #7917 fix route filter freeLancer #3327
|
@ -18,7 +18,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
const firstAgencyTerm = agencyTerms[0];
|
const firstAgencyTerm = agencyTerms[0];
|
||||||
|
|
||||||
expect(firstAgencyTerm.routeFk).toEqual(1);
|
expect(firstAgencyTerm.routeFk).toEqual(1);
|
||||||
expect(agencyTerms.length).toEqual(5);
|
expect(agencyTerms.length).toEqual(7);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -36,7 +36,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
let result = await app.models.AgencyTerm.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(2);
|
||||||
expect(result[0].routeFk).toEqual(1);
|
expect(result[0].routeFk).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
let result = await app.models.AgencyTerm.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return results matching "from" and "to"', async() => {
|
it('should return results matching "from" and "to"', async() => {
|
||||||
|
@ -72,7 +72,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
|
|
||||||
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(7);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -90,7 +90,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
let result = await app.models.AgencyTerm.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(2);
|
||||||
expect(result[0].routeFk).toEqual(1);
|
expect(result[0].routeFk).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
let result = await app.models.AgencyTerm.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(2);
|
||||||
expect(result[0].routeFk).toEqual(2);
|
expect(result[0].routeFk).toEqual(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
const app = require('vn-loopback/server/server');
|
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
|
|
||||||
describe('AgencyTerm filter()', () => {
|
|
||||||
const authUserId = 9;
|
|
||||||
const today = Date.vnNew();
|
|
||||||
today.setHours(2, 0, 0, 0);
|
|
||||||
|
|
||||||
it('should return all results matching the filter', async() => {
|
|
||||||
const tx = await models.AgencyTerm.beginTransaction({});
|
|
||||||
|
|
||||||
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];
|
|
||||||
|
|
||||||
expect(firstAgencyTerm.routeFk).toEqual(1);
|
|
||||||
expect(agencyTerms.length).toEqual(5);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return results matching "search" searching by integer', async() => {
|
|
||||||
let ctx = {
|
|
||||||
args: {
|
|
||||||
search: 1,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
|
||||||
expect(result[0].routeFk).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return results matching "search" searching by string', async() => {
|
|
||||||
let ctx = {
|
|
||||||
args: {
|
|
||||||
search: 'Plants SL',
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return results matching "from" and "to"', async() => {
|
|
||||||
const tx = await models.Buy.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const from = Date.vnNew();
|
|
||||||
from.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
const to = Date.vnNew();
|
|
||||||
to.setHours(23, 59, 59, 999);
|
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
args: {
|
|
||||||
from: from,
|
|
||||||
to: to
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const results = await models.AgencyTerm.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toBe(5);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return results matching "agencyModeFk"', async() => {
|
|
||||||
let ctx = {
|
|
||||||
args: {
|
|
||||||
agencyModeFk: 1,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
|
||||||
expect(result[0].routeFk).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return results matching "agencyFk"', async() => {
|
|
||||||
let ctx = {
|
|
||||||
args: {
|
|
||||||
agencyFk: 2,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = await app.models.AgencyTerm.filter(ctx);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
|
||||||
expect(result[0].routeFk).toEqual(2);
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in New Issue