Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request to allow multiple components of each type #192

Merged
merged 5 commits into from
Aug 22, 2018

Conversation

tqhoughton
Copy link
Contributor

In the current version of the client, you have to pass a components object, with a 1:1 mapping between each component type. An example would be:

GoogleMapsClient.placesAutoComplete({
  input: '123 Main Street',
  types: ['address'],
  components: {
    country: 'us'
  }
})

Because you can only specify a string value for each component type, using the client it is impossible to select multiples of the same type, like 2 countries for example, a feature which has been possible to do through the API for over a year now.

My PR will allow you to do this:

GoogleMapsClient.placesAutoComplete({
  input: '123 Main Street',
  types: ['address'],
  components: {
    country: ['us', 'ca']
  }
})

Basically, you can now pass in an array for each component type instead of a string. The old way will still work as well.

@stephenmcd
Copy link
Contributor

Looks good. Could you include a test that covers both single and multiple values for a component?

@tqhoughton
Copy link
Contributor Author

tqhoughton commented Aug 14, 2018

I added the unit test in the /spec/e2e/ directory. Let me know if I did it wrong.

@tqhoughton
Copy link
Contributor Author

Is there anything missing in this pull request? What is a timeline that I can expect this to be merged? I only ask because my company needs this functionality and when I try to reference my forked version of this repository in NPM I get a bunch of sessionToken errors.

@stephenmcd
Copy link
Contributor

The delay was merely due to not having a chance to look at this until now.

As for the change, I should have gone into more detail when I mentioned adding a test, sorry about that. We don't actually run the e2e tests anymore as the underlying data can change quite often which makes them brittle. What I should have mentioned is I think we just need a test that verifies adding single/multiple components params returns them as expected. There are probably some good examples in https://github.com/googlemaps/google-maps-services-js/blob/master/spec/unit/validate-spec.js (the new tests probably belong in there too).

Do you want to fix up the tests based on that?

@tqhoughton
Copy link
Contributor Author

I decided to create a new file for this test, since my changes were in the convert file and not really a part of the validate file, and I am directly testing the pipedKeyValues function.

@stephenmcd
Copy link
Contributor

That's perfect, thanks so much for addressing all the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants