Last active
October 16, 2017 16:14
-
-
Save mgenov/e3d90ef501632e1fd83abded5a86403d to your computer and use it in GitHub Desktop.
Revisions
-
mgenov revised this gist
Oct 16, 2017 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import React, { Component } from 'react' import { TextInput } from 'react-native' import { shallow, configure } from 'enzyme' import Adapter from 'enzyme-adapter-react-16' import renderer from 'react-test-renderer' import { SearchBar } from 'react-native-elements' configure({ adapter: new Adapter() }) class MyInput extends Component { @@ -12,7 +15,7 @@ class MyInput extends Component { render() { return ( <SearchBar style={{ height: 40, borderColor: 'gray', borderWidth: 1 }} onChangeText={text => { this.setState({ text }) @@ -27,7 +30,7 @@ describe('(MyInput) is ', () => { it('sends notification on input changes', () => { const wrapper = shallow(<MyInput />) wrapper .find(SearchBar) .first() .simulate('ChangeText', '42') expect(wrapper.state()).toEqual({ text: '42' }) -
mgenov created this gist
Oct 16, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ import React, { Component } from 'react' import { TextInput } from 'react-native' import { shallow, configure } from 'enzyme' import Adapter from 'enzyme-adapter-react-16' configure({ adapter: new Adapter() }) class MyInput extends Component { constructor(props) { super(props) this.state = { text: 'Useless Placeholder' } } render() { return ( <TextInput style={{ height: 40, borderColor: 'gray', borderWidth: 1 }} onChangeText={text => { this.setState({ text }) }} value={this.state.text} /> ) } } describe('(MyInput) is ', () => { it('sends notification on input changes', () => { const wrapper = shallow(<MyInput />) wrapper .find('TextInput') .first() .simulate('ChangeText', '42') expect(wrapper.state()).toEqual({ text: '42' }) }) })