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