const boilerplate = require ( '../lib/react-native-version' ) ; const get = boilerplate . getReactNativeVersion ; const DEFAULT = boilerplate . REACT_NATIVE_VERSION ; param { * } reactNativeVersion return { string } const mock = reactNativeVersion => get ( { parameters : { options : { 'react-native-version' : reactNativeVersion } } } ) ; test ( 'it handles strange inputs from code' , ( ) => { expect ( get ( ) ) . toBe ( DEFAULT ) ; expect ( get ( null ) ) . toBe ( DEFAULT ) ; expect ( get ( true ) ) . toBe ( DEFAULT ) ; expect ( get ( 8 ) ) . toBe ( DEFAULT ) ; expect ( get ( 'hello' ) ) . toBe ( DEFAULT ) ; expect ( get ( [ ] ) ) . toBe ( DEFAULT ) ; expect ( get ( { } ) ) . toBe ( DEFAULT ) ; expect ( get ( ( ) => true ) ) . toBe ( DEFAULT ) ; } ) ; test ( 'it handles strange input from the user' , ( ) => { expect ( mock ( true ) ) . toBe ( DEFAULT ) ; expect ( mock ( false ) ) . toBe ( DEFAULT ) ; expect ( mock ( [ ] ) ) . toBe ( DEFAULT ) ; expect ( mock ( { } ) ) . toBe ( DEFAULT ) ; } ) ; test ( 'it handles not-quite semver numbers' , ( ) => { expect ( mock ( 0 ) ) . toBe ( DEFAULT ) ; expect ( mock ( 0.25 ) ) . toBe ( DEFAULT ) ; } ) ; test ( 'it handles valid versions' , ( ) => { expect ( mock ( '0.41.0' ) ) . toBe ( '0.41.0' ) ; expect ( mock ( '0.41.0-beta.1' ) ) . toBe ( '0.41.0-beta.1' ) ; expect ( mock ( DEFAULT ) ) . toBe ( DEFAULT ) ; expect ( mock ( 'next' ) ) . toBe ( 'next' ) ; } ) ;