Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onChangeHandler(e) {
- const { state } = this.props;
- this.setState({ search: e.target.value }, () => {
- const { search } = this.state;
- autocomplete(search).then((suggestions) => {
- if (suggestions.length > 0) {
- this.setState({
- suggestions,
- });
- }
- });
- })
- }
- const field = mount(shallow(<Geolocation {...baseProps} />).get(0));
- field.find('.UiField__input').simulate('change', { target: { value: 'place' } });
- autocompleteStub = sinon.stub(calls, 'autocomplete').returns(Promise.resolve(suggestions));
- field.setState({ search: field.state('search') }, () => {
- expect(field.state('search')).to.eql('place');
- autocompleteStub().then(sugg => field.setState({ suggestions: sugg })).then(() => {
- expect(field.state('suggestions')).to.eql(suggestions);
- });
- });
Add Comment
Please, Sign In to add comment