publiclab / leaflet-blurred-location

A Leaflet-based interface for selecting a "blurred" or low-resolution location, to preserve privacy
https://publiclab.github.io/leaflet-blurred-location/examples/
GNU General Public License v3.0
35 stars 32 forks source link

Testing: Mock the google maps geocoding API in Jasmine #235

Closed nstjean closed 4 years ago

nstjean commented 4 years ago

233

Be aware that if the google maps api ever changes we will also have to change our mock object in testing.

I suspect I will have to do a similar mock/stub in LBLD and possibly LEL to correct the same error with the blurredLocation object in testing.

nstjean commented 4 years ago

I figured out how to move it to a helper file! The existing support/jasmine.json file was NOT being checked by the script. I had to add a helper directory in Gruntfile.js!

nstjean commented 4 years ago

I have added error checks in Geocoding.js so that the functions will only execute if there is a google object - either a real one or a mock one. It was a bit tricky getting it set up so that it didn't mess up the mock object I just created in the tests, but I think I got it! I tested this on gh-pages, you can see that "the search for a place name" and "placename" display still work properly : https://publiclab.github.io/leaflet-blurred-location/examples/index.html

If this works properly it SHOULD mean that my fixes in LBLD and LEL are no longer needed! This should mean no warnings or errors even when there's no google api key given.

jywarren commented 4 years ago

Awesome!

nstjean commented 4 years ago

@jywarren This is all set to merge! And once merged can you publish to npm?

jywarren commented 4 years ago

Sorry I missed this! Doing it now, thank you!!!

jywarren commented 4 years ago

Done!