import { pipe , R , A } from '../..' ; describe ( 'match' , ( ) => { it ( 'returns a result of errorFn' , ( ) => { expect ( pipe ( R . fromNullable ( null , 'this is bad' ) , R . match ( _ => 'this is fine' , error => `${ error }!` ) ) ) . toEqual ( 'this is bad!' ) ; } ) ; it ( 'returns a result of okFn' , ( ) => { expect ( pipe ( R . fromNullable ( 'this is fine' , 'this is bad' ) , R . match ( str => `${ str }!` , error => error ) ) ) . toEqual ( 'this is fine!' ) ; } ) ; it ( '*' , ( ) => { let xs = [ 'hello' , 'world' ] ; expect ( pipe ( R . fromNullable ( xs , 'cannot be nullable' ) , R . map ( A . join ( ' ' ) ) , R . match ( str => `${ str }!` , ( ) => 'oops!' ) ) ) . toEqual ( 'hello world!' ) ; xs = null as unknown as ReadonlyArray < string > | null ; expect ( pipe ( R . fromNullable ( xs , 'cannot be nullable' ) , R . map ( A . join ( ' ' ) ) , R . match ( str => `${ str }!` , error => `${ error }!` ) ) ) . toEqual ( 'cannot be nullable!' ) ; } ) ; } ) ;