import { exceptionListType , ExceptionListTypeEnum } from '.' ; import { pipe } from 'fp-ts/lib/pipeable' ; import { left } from 'fp-ts/lib/Either' ; import { foldLeftRight , getPaths } from '@kbn/securitysolution-io-ts-utils' ; describe ( 'exceptionListType' , ( ) => { test ( 'it should validate for "detection"' , ( ) => { const payload = 'detection' ; const decoded = exceptionListType . decode ( payload ) ; const message = pipe ( decoded , foldLeftRight ) ; expect ( getPaths ( left ( message . errors ) ) ) . toEqual ( [ ] ) ; expect ( message . schema ) . toEqual ( payload ) ; } ) ; test ( 'it should validate for "endpoint"' , ( ) => { const payload = 'endpoint' ; const decoded = exceptionListType . 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 ( exceptionListType . keys ) . sort ( ) . join ( ',' ) . toLowerCase ( ) ; const enumKeys = Object . keys ( ExceptionListTypeEnum ) . sort ( ) . join ( ',' ) . toLowerCase ( ) ; expect ( keys ) . toEqual ( enumKeys ) ; } ) ; } ) ;