import sut from '../src/ternary' ; import type { Map } from '../src/types/map' ; describe ( 'ternary' , ( ) => { describe ( 'when predicate returns "true"' , ( ) => { let left ; let right ; let result ; beforeEach ( ( ) => { left = ( value ) => value + 1 ; right = jest . fn ( ) ; result = sut ( ( ) => true , left , right ) ( 1 ) ; } ) ; it ( 'should return value from "left"' , ( ) => { expect ( result ) . toBe ( 2 ) ; } ) ; it ( 'should not call "right"' , ( ) => { expect ( right ) . not . toHaveBeenCalled ( ) ; } ) ; } ) ; describe ( 'when predicate returns "false"' , ( ) => { let left ; let right ; let result ; beforeEach ( ( ) => { left = jest . fn ( ) ; right = ( value ) => value + 1 ; result = sut ( ( ) => false , left , right ) ( 1 ) ; } ) ; it ( 'should return value from "right"' , ( ) => { expect ( result ) . toBe ( 2 ) ; } ) ; it ( 'should not call "left"' , ( ) => { expect ( left ) . not . toHaveBeenCalled ( ) ; } ) ; } ) ; } ) ;