greuge filter backend unit test

This commit is contained in:
Carlos Jimenez 2018-01-25 11:40:54 +01:00
parent 506d6e0688
commit 092efc80c1
2 changed files with 18 additions and 1 deletions

View File

@ -12,7 +12,6 @@ module.exports = function(Client) {
delete params.size;
if (params.search) {
hasAnd = true;
filters.where.and = [
{
or: [

View File

@ -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));
});
});