import { getOperator , shouldOperate , Rule , Operator } from './operators_utils' ; describe ( 'getOperator(operator)' , ( ) => { test ( 'should return operator function' , ( ) => { const operatorName = Operator . Gte ; const operator = getOperator ( operatorName ) ; expect ( typeof operator ) . toBe ( 'function' ) ; } ) ; } ) ; describe ( 'shouldOperate(rule, value)' , ( ) => { test ( 'should operate, if value is not null and rule value is not null' , ( ) => { const rule = { value : 1 , operator : Operator . Gte , } ; const value = 2 ; expect ( shouldOperate ( rule , value ) ) . toBeTruthy ( ) ; } ) ; test ( 'should operate, if value is null and operator allows null value' , ( ) => { const rule = { operator : Operator . Empty , value : null , } ; const value = null ; expect ( shouldOperate ( rule , value ) ) . toBeTruthy ( ) ; } ) ; test ( "should not operate, if value is null and operator doesn't allow null values" , ( ) => { const rule = { operator : Operator . Gte , value : 2 , } ; const value = null ; expect ( shouldOperate ( rule , value ) ) . toBeFalsy ( ) ; } ) ; test ( "should not operate, if rule value is null and operator doesn't allow null values" , ( ) => { const rule = { operator : Operator . Gte , value : null , } ; const value = 3 ; expect ( shouldOperate ( rule , value ) ) . toBeFalsy ( ) ; } ) ; } ) ;