diff --git a/services/client/common/methods/client/filter.js b/services/client/common/methods/client/filter.js index 51f5785b0..2c79e0556 100644 --- a/services/client/common/methods/client/filter.js +++ b/services/client/common/methods/client/filter.js @@ -12,7 +12,6 @@ module.exports = function(Client) { delete params.size; if (params.search) { - hasAnd = true; filters.where.and = [ { or: [ diff --git a/services/client/common/methods/client/specs/filter.spec.js b/services/client/common/methods/client/specs/filter.spec.js new file mode 100644 index 000000000..ab4bd5caa --- /dev/null +++ b/services/client/common/methods/client/specs/filter.spec.js @@ -0,0 +1,18 @@ +import filter from '../filter'; + +describe('Greuge filterClients()', () => { + it('should call the filterClients method', () => { + let params = { + page: 1, + size: 1, + search: 'Bruce Wayne', + phone: 555555555 + }; + let expectedResponse = {where: {and: [{or: [{id: 'Bruce Wayne'}, {name: {regexp: 'Bruce Wayne'}}]}, {or: [{phone: 555555555}, {mobile: 555555555}]}]}, skip: 0, limit: 1}; + let client = jasmine.createSpyObj('client', ['installMethod']); + filter(client); + let filterClients = client.installMethod.calls.allArgs()[0][1]; + + expect(Object.keys(filterClients(params))).toEqual(Object.keys(expectedResponse)); + }); +});