3684-agencyTerm_search-panel #900
|
@ -1,9 +1,12 @@
|
||||||
|
const app = require('vn-loopback/server/server');
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('AgencyTerm filter()', () => {
|
describe('AgencyTerm filter()', () => {
|
||||||
const authUserId = 9;
|
const authUserId = 9;
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(2, 0, 0, 0);
|
||||||
|
|
||||||
it('should return all the tickets 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({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -23,4 +26,84 @@ describe('AgencyTerm filter()', () => {
|
||||||
throw e;
|
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 = new Date();
|
||||||
|
from.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
const to = new Date();
|
||||||
|
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(3);
|
||||||
|
|
||||||
|
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