diff --git a/packages/common/src/services/__tests__/utilities.spec.ts b/packages/common/src/services/__tests__/utilities.spec.ts index 10139ebe1..21659d89a 100644 --- a/packages/common/src/services/__tests__/utilities.spec.ts +++ b/packages/common/src/services/__tests__/utilities.spec.ts @@ -747,16 +747,14 @@ describe('Service/Utilies', () => { expect(output2).toBe(expectation); }); - it('should return OperatoryType associated to "<>", "!=", "neq" or "NEQ"', () => { + it('should return OperatoryType associated to "!=", "neq" or "NEQ"', () => { const expectation = OperatorType.notEqual; - const output1 = mapOperatorType('<>'); - const output2 = mapOperatorType('!='); - const output3 = mapOperatorType('NE'); + const output1 = mapOperatorType('!='); + const output2 = mapOperatorType('NE'); expect(output1).toBe(expectation); expect(output2).toBe(expectation); - expect(output3).toBe(expectation); }); it('should return OperatoryType associated to "*", "a*", ".*", "startsWith"', () => { @@ -814,11 +812,13 @@ describe('Service/Utilies', () => { it('should return OperatoryType associated to "not_contains", "Not_Contains", "notContains"', () => { const expectation = OperatorType.notContains; - const output1 = mapOperatorType('Not_Contains'); - const output2 = mapOperatorType('NOT_CONTAINS'); + const output1 = mapOperatorType('<>'); + const output2 = mapOperatorType('Not_Contains'); + const output3 = mapOperatorType('NOT_CONTAINS'); expect(output1).toBe(expectation); expect(output2).toBe(expectation); + expect(output3).toBe(expectation); }); it('should return default OperatoryType associated to contains', () => { diff --git a/packages/common/src/services/utilities.ts b/packages/common/src/services/utilities.ts index 4b770ba33..e1d47a7cc 100644 --- a/packages/common/src/services/utilities.ts +++ b/packages/common/src/services/utilities.ts @@ -425,7 +425,6 @@ export function mapOperatorType(operator: OperatorType | OperatorString): Operat case 'GE': map = OperatorType.greaterThanOrEqual; break; - case '<>': case '!=': case 'NE': map = OperatorType.notEqual; @@ -451,6 +450,7 @@ export function mapOperatorType(operator: OperatorType | OperatorString): Operat case 'NOT_IN': map = OperatorType.notIn; break; + case '<>': case 'Not_Contains': case 'NOT_CONTAINS': map = OperatorType.notContains; diff --git a/packages/graphql/src/services/__tests__/graphql.service.spec.ts b/packages/graphql/src/services/__tests__/graphql.service.spec.ts index d167da4bc..50208f7d3 100644 --- a/packages/graphql/src/services/__tests__/graphql.service.spec.ts +++ b/packages/graphql/src/services/__tests__/graphql.service.spec.ts @@ -758,7 +758,23 @@ describe('GraphqlService', () => { expect(removeSpaces(query)).toBe(removeSpaces(expectation)); }); - it('should return a query with multiple filters when the filters object has multiple search and they are passed as a filter trigger by a filter event and is of type ColumnFilters', () => { + it('should return a query with multiple filters when the filters object has multiple search with Equal & "<>" and they are passed as a filter trigger by a filter event and is of type ColumnFilters', () => { + const expectation = `query{users(first:10, offset:0, filterBy:[{field:gender, operator:EQ, value:"female"}, {field:company, operator:Not_Contains, value:"abc"}]) { totalCount,nodes{ id,company,gender,name } }}`; + const mockColumnGender = { id: 'gender', field: 'gender' } as Column; + const mockColumnCompany = { id: 'company', field: 'company' } as Column; + const mockColumnFilters = { + gender: { columnId: 'gender', columnDef: mockColumnGender, searchTerms: ['female'], operator: 'EQ', type: FieldType.string, }, + company: { columnId: 'company', columnDef: mockColumnCompany, searchTerms: ['abc'], operator: '<>', type: FieldType.string, }, + } as ColumnFilters; + + service.init(serviceOptions, paginationOptions, gridStub); + service.updateFilters(mockColumnFilters, false); + const query = service.buildQuery(); + + expect(removeSpaces(query)).toBe(removeSpaces(expectation)); + }); + + it('should return a query with multiple filters when the filters object has multiple search with Equal & Not Contains and they are passed as a filter trigger by a filter event and is of type ColumnFilters', () => { const expectation = `query{users(first:10, offset:0, filterBy:[{field:gender, operator:EQ, value:"female"}, {field:company, operator:Not_Contains, value:"abc"}]) { totalCount,nodes{ id,company,gender,name } }}`; const mockColumnGender = { id: 'gender', field: 'gender' } as Column; const mockColumnCompany = { id: 'company', field: 'company' } as Column;