import * as O from '../src/index' ; describe ( 'valueOr' , ( ) => { type Source = { foo ? : string | undefined ; } ; const source1 = { foo : 'bar' } ; const source2 = { } ; const lens = O . optic_ < Source > ( ) . prop ( 'foo' ) . valueOr ( 42 ) ; type Focus = string | number ; it ( 'get defined' , ( ) => { const result = O . get ( lens ) ( source1 ) ; expect ( result ) . toEqual ( 'bar' ) ; } ) ; it ( 'get undefined' , ( ) => { const result = O . get ( lens ) ( source2 ) ; expect ( result ) . toEqual ( 42 ) ; } ) ; type Target = { foo : boolean ; } ; it ( 'set defined - polymorphic' , ( ) => { const result = O . set ( lens ) ( true ) ( source1 ) ; expect ( result ) . toEqual ( { foo : true } ) ; } ) ; it ( 'set undefined - polymorphic' , ( ) => { const result = O . set ( lens ) ( false ) ( source2 ) ; expect ( result ) . toEqual ( { foo : false } ) ; } ) ; } ) ;