import { pipe } from 'fp-ts/lib/pipeable' ; import { left } from 'fp-ts/lib/Either' ; import { foldLeftRight , getPaths } from '@kbn/securitysolution-io-ts-utils' ; import { ListOperatorEnum as OperatorEnum , listOperator as operator } from '.' ; describe ( 'operator' , ( ) => { test ( 'it should validate for "included"' , ( ) => { const payload = 'included' ; const decoded = operator . decode ( payload ) ; const message = pipe ( decoded , foldLeftRight ) ; expect ( getPaths ( left ( message . errors ) ) ) . toEqual ( [ ] ) ; expect ( message . schema ) . toEqual ( payload ) ; } ) ; test ( 'it should validate for "excluded"' , ( ) => { const payload = 'excluded' ; const decoded = operator . decode ( payload ) ; const message = pipe ( decoded , foldLeftRight ) ; expect ( getPaths ( left ( message . errors ) ) ) . toEqual ( [ ] ) ; expect ( message . schema ) . toEqual ( payload ) ; } ) ; test ( 'it should contain same amount of keys as enum' , ( ) => { const keys = Object . keys ( operator . keys ) . sort ( ) . join ( ',' ) . toLowerCase ( ) ; const enumKeys = Object . keys ( OperatorEnum ) . sort ( ) . join ( ',' ) . toLowerCase ( ) ; expect ( keys ) . toEqual ( enumKeys ) ; } ) ; } ) ;