8713-testToMaster #3523
|
@ -71,8 +71,6 @@ module.exports = Self => {
|
||||||
return /^\d+$/.test(value)
|
return /^\d+$/.test(value)
|
||||||
? {'v.id': value}
|
? {'v.id': value}
|
||||||
: {numberPlate: {like: `%${value}%`}};
|
: {numberPlate: {like: `%${value}%`}};
|
||||||
case 'id':
|
|
||||||
return {'v.id': value};
|
|
||||||
case 'description':
|
case 'description':
|
||||||
case 'tradeMark':
|
case 'tradeMark':
|
||||||
case 'numberPlate':
|
case 'numberPlate':
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
fdescribe('Vehicle filter()', () => {
|
describe('Vehicle filter()', () => {
|
||||||
const deliveryAssiId = 123;
|
const deliveryAssiId = 123;
|
||||||
const ctx = beforeAll.getCtx(deliveryAssiId);
|
const ctx = beforeAll.getCtx(deliveryAssiId);
|
||||||
let options;
|
let options;
|
||||||
|
@ -30,7 +30,7 @@ fdescribe('Vehicle filter()', () => {
|
||||||
expect(searchResult2.numberPlate).toEqual(numberPlate);
|
expect(searchResult2.numberPlate).toEqual(numberPlate);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the vehicles matching "company"', async() => {
|
it('should return the vehicles matching "companyFk"', async() => {
|
||||||
const company = await models.Company.findOne({where: {code: 'VNL'}}, options);
|
const company = await models.Company.findOne({where: {code: 'VNL'}}, options);
|
||||||
ctx.args = {companyFk: company.id};
|
ctx.args = {companyFk: company.id};
|
||||||
const searchResult = await models.Vehicle.filter(ctx, null, options);
|
const searchResult = await models.Vehicle.filter(ctx, null, options);
|
||||||
|
@ -64,59 +64,64 @@ fdescribe('Vehicle filter()', () => {
|
||||||
ctx.args = {warehouseFk: warehouse.id};
|
ctx.args = {warehouseFk: warehouse.id};
|
||||||
const searchResult = await models.Vehicle.filter(ctx);
|
const searchResult = await models.Vehicle.filter(ctx);
|
||||||
searchResult.forEach(record => {
|
searchResult.forEach(record => {
|
||||||
expect(record.warehouseFk).toEqual(warehouse.id);
|
expect(record.warehouse).toEqual(warehouse.name);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should return the vehicles matching "chassis"', async() => {
|
it('should return the vehicles matching "chassis"', async() => {
|
||||||
// const ctx = {
|
const {chassis} = await models.Vehicle.findById(1, null, options);
|
||||||
// args: {
|
ctx.args = {chassis};
|
||||||
// chassis: 'CH12345',
|
const [searchResult] = await models.Vehicle.filter(ctx);
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const result = await models.Vehicle.filter(ctx);
|
expect(searchResult.chassis).toEqual(chassis);
|
||||||
|
});
|
||||||
|
|
||||||
// expect(result.length).toBeGreaterThan(0);
|
it('should return the vehicles matching "leasing"', async() => {
|
||||||
// expect(result[0].chassis).toEqual('CH12345');
|
const leasing = 'Wayne leasing';
|
||||||
// });
|
ctx.args = {leasing};
|
||||||
|
const searchResult = await models.Vehicle.filter(ctx);
|
||||||
|
searchResult.forEach(record => {
|
||||||
|
expect(record.leasing).toEqual(leasing);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// it('should return the vehicles matching "leasing"', async() => {
|
it('should return the vehicles matching "countryCodeFk"', async() => {
|
||||||
// const ctx = {
|
const countryCodeFk = 'ES';
|
||||||
// args: {
|
ctx.args = {countryCodeFk};
|
||||||
// leasing: 'LeasingCompany',
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const result = await models.Vehicle.filter(ctx);
|
const searchResult = await models.Vehicle.filter(ctx);
|
||||||
|
searchResult.forEach(record => {
|
||||||
|
expect(record.countryCodeFk).toEqual(countryCodeFk);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// expect(result.length).toBeGreaterThan(0);
|
it('should return the vehicles matching "vehicleTypeFk"', async() => {
|
||||||
// expect(result[0].leasing).toEqual('LeasingCompany');
|
const {name, id} = await models.VehicleType.findById(1, null, options);
|
||||||
// });
|
ctx.args = {vehicleTypeFk: id};
|
||||||
|
|
||||||
// it('should return the vehicles matching "countryCodeFk"', async() => {
|
const searchResult = await models.Vehicle.filter(ctx);
|
||||||
// const ctx = {
|
searchResult.forEach(record => {
|
||||||
// args: {
|
expect(record.type).toEqual(name);
|
||||||
// countryCodeFk: 'US',
|
});
|
||||||
// }
|
});
|
||||||
// };
|
|
||||||
|
|
||||||
// const result = await models.Vehicle.filter(ctx);
|
it('should return the vehicles matching "vehicleStateFk"', async() => {
|
||||||
|
const {state, id} = await models.VehicleState.findById(3);
|
||||||
|
ctx.args = {vehicleStateFk: id};
|
||||||
|
|
||||||
// expect(result.length).toBeGreaterThan(0);
|
const searchResult = await models.Vehicle.filter(ctx);
|
||||||
// expect(result[0].countryCodeFk).toEqual('US');
|
searchResult.forEach(record => {
|
||||||
// });
|
expect(record.state).toEqual(state);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// it('should return the vehicles matching "vehicleTypeFk"', async() => {
|
it('should return the vehicles matching "description"', async() => {
|
||||||
// const ctx = {
|
const {description} = await models.Vehicle.findById(2);
|
||||||
// args: {
|
ctx.args = {description};
|
||||||
// vehicleTypeFk: 3,
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const result = await models.Vehicle.filter(ctx);
|
const searchResult = await models.Vehicle.filter(ctx);
|
||||||
|
searchResult.forEach(record => {
|
||||||
// expect(result.length).toBeGreaterThan(0);
|
expect(record.description).toEqual(description);
|
||||||
// expect(result[0].vehicleTypeFk).toEqual(3);
|
});
|
||||||
// });
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue