Guest User

Untitled

a guest
Oct 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. onChangeHandler(e) {
  2. const { state } = this.props;
  3. this.setState({ search: e.target.value }, () => {
  4. const { search } = this.state;
  5. autocomplete(search).then((suggestions) => {
  6. if (suggestions.length > 0) {
  7. this.setState({
  8. suggestions,
  9. });
  10. }
  11. });
  12. })
  13. }
  14.  
  15. const field = mount(shallow(<Geolocation {...baseProps} />).get(0));
  16. field.find('.UiField__input').simulate('change', { target: { value: 'place' } });
  17. autocompleteStub = sinon.stub(calls, 'autocomplete').returns(Promise.resolve(suggestions));
  18. field.setState({ search: field.state('search') }, () => {
  19. expect(field.state('search')).to.eql('place');
  20. autocompleteStub().then(sugg => field.setState({ suggestions: sugg })).then(() => {
  21. expect(field.state('suggestions')).to.eql(suggestions);
  22. });
  23. });
Add Comment
Please, Sign In to add comment