1- import { FieldType , FilterConditionOption , OperatorType } from '../../models/index' ;
1+ import { FieldType , FilterConditionOption , OperatorType , SearchTerm } from '../../models/index' ;
22import { executeFilterConditionTest } from '../filterConditionProcesses' ;
33import { executeStringFilterCondition , getFilterParsedText } from '../stringFilterCondition' ;
44
55describe ( 'executeStringFilterCondition method' , ( ) => {
66 it ( 'should return True when no cell input value is provided which is equal to the default search term, neither search terms' , ( ) => {
7- const searchTerms = [ ] ;
7+ const searchTerms : SearchTerm [ ] = [ ] ;
88 const options = { dataKey : '' , operator : 'EQ' , cellValue : '' , fieldType : FieldType . string } as FilterConditionOption ;
99 const output = executeStringFilterCondition ( options , getFilterParsedText ( searchTerms ) ) ;
1010 expect ( output ) . toBe ( true ) ;
1111 } ) ;
1212
1313 it ( 'should return True when cell input value is null and is equal to the default search term, neither search terms' , ( ) => {
14- const searchTerms = [ ] ;
14+ const searchTerms : SearchTerm [ ] = [ ] ;
1515 const options = { dataKey : '' , operator : 'EQ' , cellValue : null , fieldType : FieldType . string } as FilterConditionOption ;
1616 const output = executeStringFilterCondition ( options , getFilterParsedText ( searchTerms ) ) ;
1717 expect ( output ) . toBe ( true ) ;
@@ -25,7 +25,7 @@ describe('executeStringFilterCondition method', () => {
2525 } ) ;
2626
2727 it ( 'should return False when any cell input value is provided without any search terms' , ( ) => {
28- const searchTerms = [ ] ;
28+ const searchTerms : SearchTerm [ ] = [ ] ;
2929 const options = { dataKey : '' , operator : 'EQ' , cellValue : 'foo' , fieldType : FieldType . string } as FilterConditionOption ;
3030 const output = executeStringFilterCondition ( options , getFilterParsedText ( searchTerms ) ) ;
3131 expect ( output ) . toBe ( false ) ;
@@ -60,7 +60,7 @@ describe('executeStringFilterCondition method', () => {
6060 } ) ;
6161
6262 it ( 'should return False when the cell value is equal to at least 1 of the searchTerms' , ( ) => {
63- const searchTerms = [ ] ;
63+ const searchTerms : SearchTerm [ ] = [ ] ;
6464 const options = { dataKey : '' , operator : 'EQ' , cellValue : 'foo' , fieldType : FieldType . string , searchTerms : [ 'bar' , 'foo' , 'John' ] } as FilterConditionOption ;
6565 const output = executeStringFilterCondition ( options , getFilterParsedText ( searchTerms ) ) ;
6666 expect ( output ) . toBe ( false ) ;
@@ -94,6 +94,20 @@ describe('executeStringFilterCondition method', () => {
9494 expect ( output ) . toBe ( true ) ;
9595 } ) ;
9696
97+ it ( 'should return False when search term is a substring of the cell value and the operator is "<>" (not contains)' , ( ) => {
98+ const searchTerms = [ 'bost' ] ;
99+ const options = { dataKey : '' , operator : '<>' , cellValue : 'abbostford' , fieldType : FieldType . string , searchTerms } as FilterConditionOption ;
100+ const output = executeStringFilterCondition ( options , getFilterParsedText ( searchTerms ) ) ;
101+ expect ( output ) . toBe ( false ) ;
102+ } ) ;
103+
104+ it ( 'should return True when search term is a substring of the cell value and the operator is "!=" (not contains) because "!=" compares agains the entire string' , ( ) => {
105+ const searchTerms = [ 'bost' ] ;
106+ const options = { dataKey : '' , operator : '!=' , cellValue : 'abbostford' , fieldType : FieldType . string , searchTerms } as FilterConditionOption ;
107+ const output = executeStringFilterCondition ( options , getFilterParsedText ( searchTerms ) ) ;
108+ expect ( output ) . toBe ( true ) ;
109+ } ) ;
110+
97111 it ( 'should return True when input value provided starts with same substring and the operator is empty string' , ( ) => {
98112 const searchTerms = [ 'abb' ] ;
99113 const options = { dataKey : '' , operator : '' , cellValue : 'abbostford' , fieldType : FieldType . string , searchTerms } as FilterConditionOption ;
0 commit comments