import { shallow } from 'enzyme' ; import toJson from 'enzyme-to-json' ; import React from 'react' ; import { Button } from '../Button.ios' ; describe ( 'Components' , ( ) => { describe ( 'Button IOS' , ( ) => { const defaultOnPress = { onPress : ( ) => { return ; } , } ; it ( 'should renders correctly' , ( ) => { expect ( toJson ( shallow ( < Button { ... defaultOnPress } > Test < /Button>))).toMatchSnapshot(); expect ( toJson ( shallow ( < Button { ... defaultOnPress } title = "qdwdqw" / > ) ) ) . toMatchSnapshot ( ) ; expect ( toJson ( shallow ( < Button { ... defaultOnPress } title = "qdwdqw" loading = { true } loadingTitle = "My loading title" / > ) ) ) . toMatchSnapshot ( ) ; expect ( toJson ( shallow ( < Button { ... defaultOnPress } title = "qdwdqw" disabled = { true } / > ) ) ) . toMatchSnapshot ( ) ; } ) ; it ( 'should call onPress when taping the button' , ( ) => { const onPress = jest . fn ( ) ; const button = shallow ( < Button onPress = { onPress } / > ) ; button . find ( 'TouchableOpacity' ) . prop ( 'onPress' ) ( ) ; expect ( onPress ) . toHaveBeenCalledTimes ( 1 ) ; expect ( onPress ) . toHaveBeenCalledWith ( ) ; } ) ; } ) ; } ) ;