diff --git a/.travis.yml b/.travis.yml index dd92f46..39c7751 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: node_js node_js: - - "6" - - "5" - - "4" + - "7.2.1" + - "6.9.2" - "stable" notifications: diff --git a/README.md b/README.md index d88b1db..4468db8 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ var result = gmAPI.streetView(params); ### Further examples -Please refer to the code, [tests](http://github.com/moshen/node-googlemaps/tree/master/test/) and the [Google Maps API docs](http://code.google.com/apis/maps/documentation/webservices/index.html) for further usage information. +Please refer to the code, [tests](http://github.com/moshen/node-googlemaps/tree/master/test/) and the [Google Maps API docs](https://developers.google.com/maps/web-services/) for further usage information. ### Contributions diff --git a/lib/config/constants.json b/lib/config/constants.json index d033b56..7ecb8aa 100644 --- a/lib/config/constants.json +++ b/lib/config/constants.json @@ -1,5 +1,4 @@ { - "ACCEPTED_CONFIG_KEYS": { "encode_polylines": "boolean", "google_client_id": "string", @@ -11,7 +10,7 @@ }, "ACCEPTED_PARAMS": { - "place-search": { + "place-search-nearby": { "keyword": "string", "language": "string", "location": "string", @@ -26,18 +25,18 @@ "types": "string" }, "place-search-text": { - "location": "string", - "radius": "string", - "language": "string", - "maxprice": "number", - "minprice": "number", - "opennow": "boolean", - "pagetoken": "string", - "sensor": "string", - "type": "string", - "types": "string", + "location": "string", + "radius": "string", + "language": "string", + "maxprice": "number", + "minprice": "number", + "opennow": "boolean", + "pagetoken": "string", + "sensor": "string", + "type": "string", + "types": "string", "zagatselected": "string", - "query": "string" + "query": "string" }, "place-details": { "placeid": "string", @@ -45,13 +44,13 @@ "language": "string" }, "place-autocomplete": { - "input": "string", - "offset": "number", - "location": "string", - "radius": "number", - "language": "string", - "types": "string", - "components":"string" + "input": "string", + "offset": "number", + "location": "string", + "radius": "number", + "language": "string", + "types": "string", + "components": "string" }, "geocode": { "address": "string", @@ -94,8 +93,8 @@ }, "elevation": { "locations": "string", - "path": "string", - "samples": "string" + "path": "string", + "samples": "string" }, "static-map": { "center": "string", @@ -112,11 +111,11 @@ "style": "array" }, "timezone": { - "location": "string", - "timestamp":"number", - "language": "string" + "location": "string", + "timestamp": "number", + "language": "string" }, - "street-map": { + "street-view": { "location": "string", "pano": "string", "size": "string", @@ -128,30 +127,33 @@ }, "MAX_REQUEST_LENGTHS": { - "directions": 2048, - "distance-matrix": 2048, - "elevation": -1, - "geocode": 2048, - "place-details": 2048, - "place-search": 2048, - "place-autocomplete": 2048, - "static-map": 2048, - "timezone": 2048, - "street-view": 2048 + "directions": 2048, + "distance-matrix": 2048, + "elevation": -1, + "geocode": 2048, + "place-details": 2048, + "place-search-nearby": 2048, + "place-search-text": 2048, + "place-autocomplete": 2048, + "reverse-geocode": 2048, + "static-map": 2048, + "timezone": 2048, + "street-view": 2048 }, "GOOGLEMAPS_ENDPOINTS": { - "directions": "/maps/api/directions/json", - "distance-matrix": "/maps/api/distancematrix/json", - "elevation": "/maps/api/elevation/json", - "geocode": "/maps/api/geocode/json", - "place-details": "/maps/api/place/details/json", - "place-search": "/maps/api/place/nearbysearch/json", - "place-search-text": "/maps/api/place/textsearch/json", - "place-autocomplete":"/maps/api/place/autocomplete/json", - "static-map": "/maps/api/staticmap", - "timezone": "/maps/api/timezone/json", - "street-view": "/maps/api/streetview" + "directions": "/maps/api/directions/json", + "distance-matrix": "/maps/api/distancematrix/json", + "elevation": "/maps/api/elevation/json", + "geocode": "/maps/api/geocode/json", + "place-details": "/maps/api/place/details/json", + "place-search-nearby": "/maps/api/place/nearbysearch/json", + "place-search-text": "/maps/api/place/textsearch/json", + "place-autocomplete": "/maps/api/place/autocomplete/json", + "reverse-geocode": "/maps/api/geocode/json", + "static-map": "/maps/api/staticmap", + "timezone": "/maps/api/timezone/json", + "street-view": "/maps/api/streetview" } } diff --git a/lib/directions.js b/lib/directions.js index f2bc70f..650b470 100644 --- a/lib/directions.js +++ b/lib/directions.js @@ -17,6 +17,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'directions'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -31,7 +33,7 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['directions']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); // validate directions specific args if (args.origin == null) { @@ -51,6 +53,6 @@ module.exports = function(params, callback) { _travelUtils.convertTargetTimes(args); - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['directions'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['directions']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/distance.js b/lib/distance.js index 3e08779..df96b0a 100644 --- a/lib/distance.js +++ b/lib/distance.js @@ -17,6 +17,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'distance-matrix'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -31,7 +33,7 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['distance-matrix']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); // validate distance matrix args if (args.origins == null) { @@ -51,6 +53,6 @@ module.exports = function(params, callback) { _travelUtils.convertTargetTimes(args); - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['distance-matrix'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['distance-matrix']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/elevationFromLocations.js b/lib/elevationFromLocations.js index 441f967..a71988b 100644 --- a/lib/elevationFromLocations.js +++ b/lib/elevationFromLocations.js @@ -17,6 +17,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'elevation'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -31,7 +33,7 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['elevation']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.locations == null) { return callback(new Error('params.locations is required')); @@ -41,6 +43,6 @@ module.exports = function(params, callback) { args.locations = 'enc:' + _encodePolyline(args.locations); } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['elevation'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['elevation']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/geocode.js b/lib/geocode.js index 2fd3ae8..e05546e 100644 --- a/lib/geocode.js +++ b/lib/geocode.js @@ -16,6 +16,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'geocode'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -26,12 +28,12 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['geocode']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (!args.address && !args.components) { return callback(new Error('params.address/params.components is required')); } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['geocode'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['geocode']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/index.js b/lib/index.js index 8b1df68..f6b3bce 100755 --- a/lib/index.js +++ b/lib/index.js @@ -21,8 +21,8 @@ var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; var api = { - placeText: require('./placeText'), - placeSearch: require('./placeSearch'), + placeSearchText: require('./placeSearchText'), + placeSearch: require('./placeSearchNearby'), placeDetails: require('./placeDetails'), placeAutocomplete: require('./placeAutocomplete'), geocode: require('./geocode'), @@ -91,7 +91,7 @@ GoogleMapsAPI.prototype.placeSearch = api.placeSearch * TODO: Maps API for Work customers should not include a client or signature parameter with their requests. * TODO: params zagatselected */ -GoogleMapsAPI.prototype.placeText = api.placeText +GoogleMapsAPI.prototype.placeSearchText = api.placeSearchText /** * diff --git a/lib/placeAutocomplete.js b/lib/placeAutocomplete.js index cf72f2c..bc96fd4 100644 --- a/lib/placeAutocomplete.js +++ b/lib/placeAutocomplete.js @@ -16,6 +16,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'place-autocomplete'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -30,12 +32,12 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['place-autocomplete']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.input == null) { return callback(new Error('params.input is required')); } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['place-autocomplete'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['place-autocomplete']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/placeDetails.js b/lib/placeDetails.js index 965cc5b..6a7ffcd 100644 --- a/lib/placeDetails.js +++ b/lib/placeDetails.js @@ -16,6 +16,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'place-details'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -30,12 +32,12 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['place-details']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.placeid == null) { return callback(new Error('params.placeid is required')); } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['place-details'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['place-details']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/placeSearch.js b/lib/placeSearchNearby.js similarity index 88% rename from lib/placeSearch.js rename to lib/placeSearchNearby.js index 854c093..67297e0 100644 --- a/lib/placeSearch.js +++ b/lib/placeSearchNearby.js @@ -21,6 +21,7 @@ var MAX_RADIUS = 50000; var PLACES_RANKBY_DEFAULT = 'prominence'; var PLACES_RANKBY_DISTANCE = 'distance'; +var METHOD_KEY = 'place-search-nearby'; module.exports = function(params, callback) { @@ -29,14 +30,14 @@ module.exports = function(params, callback) { } if (this.config.key == null) { - return callback(new Error('The placeSearch API requires a key. You can add it to the config.')); + return callback(new Error('The placeSearchNearby API requires a key. You can add it to the config.')); } if (!check.object(params)) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['place-search']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.location == null) { return callback(new Error('params.location is required')); @@ -84,5 +85,5 @@ module.exports = function(params, callback) { } } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['place-search'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['place-search']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/placeText.js b/lib/placeSearchText.js similarity index 74% rename from lib/placeText.js rename to lib/placeSearchText.js index 4ca552a..27ee67d 100644 --- a/lib/placeText.js +++ b/lib/placeSearchText.js @@ -14,6 +14,9 @@ var _constants = require('./config/constants'); var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; +var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; + +var METHOD_KEY = 'place-search-text'; module.exports = function(params, callback) { @@ -22,19 +25,19 @@ module.exports = function(params, callback) { } if (this.config.key == null) { - return callback(new Error('The placeTextSearch API requires a key. You can add it to the config.')); + return callback(new Error('The placeSearchText API requires a key. You can add it to the config.')); } if (!check.object(params)) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['place-search-text']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.query == null) { return callback(new Error('params.query is required')); } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['place-search-text'], args, _jsonParser(callback)); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/reverseGeocode.js b/lib/reverseGeocode.js index 6f1bf86..886ccc1 100644 --- a/lib/reverseGeocode.js +++ b/lib/reverseGeocode.js @@ -16,6 +16,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'reverse-geocode'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -26,12 +28,12 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['reverse-geocode']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.latlng == null && args.place_id == null) { return callback(new Error('params.latlng/params.place_id is required')); } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['geocode'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['geocode']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/lib/staticMap.js b/lib/staticMap.js index 87bb160..3aac9e8 100644 --- a/lib/staticMap.js +++ b/lib/staticMap.js @@ -19,6 +19,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'static-map'; + function _errorHandler(callback, error) { if (typeof callback === 'function') { return callback(error); @@ -42,7 +44,7 @@ module.exports = function(params, callback) { return _errorHandler(callback, new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['static-map']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); // If a marker param or path param is provided then center and zoom param is not required if (args.markers == null && args.path == null) { @@ -111,6 +113,6 @@ module.exports = function(params, callback) { } } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['static-map'], args, callback, MAX_REQUEST_LENGTHS['static-map'], 'binary'); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, callback, MAX_REQUEST_LENGTHS[METHOD_KEY], 'binary'); }; diff --git a/lib/streetView.js b/lib/streetView.js index a6183bb..b00f3dc 100644 --- a/lib/streetView.js +++ b/lib/streetView.js @@ -16,6 +16,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'street-view'; + function _errorHandler(callback, error) { if (typeof callback === 'function') { return callback(error); @@ -39,7 +41,7 @@ module.exports = function(params, callback) { return _errorHandler(callback, new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['street-map']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.location == null && args.pano == null) { return _errorHandler(callback, new Error('params.location or params.pano is required')); @@ -70,6 +72,6 @@ module.exports = function(params, callback) { } } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['street-view'], args, callback, MAX_REQUEST_LENGTHS['street-view'], 'binary'); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, callback, MAX_REQUEST_LENGTHS[METHOD_KEY], 'binary'); }; diff --git a/lib/timezone.js b/lib/timezone.js index ac6cfa4..e29c44d 100644 --- a/lib/timezone.js +++ b/lib/timezone.js @@ -16,6 +16,8 @@ var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; +var METHOD_KEY = 'timezone'; + module.exports = function(params, callback) { if (typeof callback !== 'function') { @@ -30,7 +32,7 @@ module.exports = function(params, callback) { return callback(new TypeError('params must be an object')); } - var args = _assignParams({}, params, ACCEPTED_PARAMS['timezone']); + var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); if (args.location == null) { return callback(new Error('params.location is required')); @@ -39,6 +41,6 @@ module.exports = function(params, callback) { return callback(new Error('params.timestamp is required')); } - return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['timezone'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['timezone']); + return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); }; diff --git a/package.json b/package.json index 0794f99..11af6db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "googlemaps", - "version": "1.11.1", + "version": "1.12.0", "main": "lib/index", "description": "A simple way to query the Google Maps API from Node.js", "license": "MIT", @@ -33,7 +33,7 @@ "dependencies": { "check-types": "~1.3.2", "qs": "^4.0.0", - "request": "~2.74.0", + "request": "^2.79.0", "waitress": ">=0.0.2" }, "scripts": { diff --git a/test/integration/placeTextTest.js b/test/integration/placeTextTest.js index fa4be00..9e642e9 100644 --- a/test/integration/placeTextTest.js +++ b/test/integration/placeTextTest.js @@ -2,13 +2,13 @@ var assert = require('assert'), GoogleMapsAPI = require('../../lib/index') config = require('../simpleConfig'); -describe('placeText', function() { +describe('placeSearchText', function() { var gm = new GoogleMapsAPI(config); describe('Search for restaurants near Sydney.', function() { var result; before(function(done){ - gm.placeText({ + gm.placeSearchText({ query: 'restaurants+in+Sydney', }, function(err, data) { assert.ifError(err); @@ -30,7 +30,7 @@ describe('placeText', function() { describe('Search for an incomplete address, in this case, a street address that does not include a city or state or country', function() { var result; before(function(done){ - gm.placeText({ + gm.placeSearchText({ query: '123+main+street', }, function(err, data) { assert.ifError(err); @@ -51,7 +51,7 @@ describe('placeText', function() { describe('Search for the same incomplete addres, and includes location and radius parameters to bias the results to a region of interest.', function() { var result; before(function(done){ - gm.placeText({ + gm.placeSearchText({ query: '123+main+street', location: '42.3675294,-71.186966', radius: 10000 @@ -71,4 +71,4 @@ describe('placeText', function() { }) }); -}); \ No newline at end of file +}); diff --git a/test/mocks/placeSearch.json b/test/mocks/placeSearchNearby.json similarity index 100% rename from test/mocks/placeSearch.json rename to test/mocks/placeSearchNearby.json diff --git a/test/mocks/placeText.json b/test/mocks/placeSearchText.json similarity index 100% rename from test/mocks/placeText.json rename to test/mocks/placeSearchText.json diff --git a/test/unit/directionsTest.js b/test/unit/directionsTest.js index 755ca53..726536e 100644 --- a/test/unit/directionsTest.js +++ b/test/unit/directionsTest.js @@ -2,7 +2,7 @@ var should = require('should'); var GoogleMapsAPI = require('../../lib/index'); -var direstionsMockResult = require('../mocks/direction'); +var directionsMockResult = require('../mocks/direction'); var gmAPI; @@ -28,7 +28,7 @@ describe('directions', function() { var res = { statusCode: 200 }; - var data = JSON.stringify(direstionsMockResult); + var data = JSON.stringify(directionsMockResult); return callback(null, res, data); }; diff --git a/test/unit/placeSearchTest.js b/test/unit/placeSearchTest.js index 60f6cbf..007f76f 100644 --- a/test/unit/placeSearchTest.js +++ b/test/unit/placeSearchTest.js @@ -2,12 +2,12 @@ var should = require('should'); var GoogleMapsAPI = require('../../lib/index'); -var placeSearchMoskResult = require('../mocks/placeSearch'); +var placeSearchMoskResult = require('../mocks/placeSearchNearby'); var gmAPI; -describe('placeSearch', function() { +describe('placeSearchNearby', function() { before(function() { var config = { @@ -76,7 +76,7 @@ describe('placeSearch', function() { customGmAPI.placeSearch( params, function(err, results) { should.not.exist(results); should.exist(err); - err.message.should.equal('The placeSearch API requires a key. You can add it to the config.'); + err.message.should.equal('The placeSearchNearby API requires a key. You can add it to the config.'); done(); }); diff --git a/test/unit/placeTextTest.js b/test/unit/placeTextTest.js index b557fe6..f5e18a7 100644 --- a/test/unit/placeTextTest.js +++ b/test/unit/placeTextTest.js @@ -2,11 +2,11 @@ var should = require('should'); var GoogleMapsAPI = require('../../lib/index'); -var direstionsMockResult = require('../mocks/placeText'); +var placeSearchTextMockResult = require('../mocks/placeSearchText'); var gmAPI; -describe('placeText', function() { +describe('placeSearchText', function() { before(function() { var config = { @@ -23,7 +23,7 @@ describe('placeText', function() { var res = { statusCode: 200 }; - var data = JSON.stringify(direstionsMockResult); + var data = JSON.stringify(placeSearchTextMockResult); return callback(null, res, data); }; @@ -70,10 +70,10 @@ describe('placeText', function() { var customGmAPI = new GoogleMapsAPI( config, mockRequest ); var params = {}; - customGmAPI.placeText( params, function(err, results) { + customGmAPI.placeSearchText( params, function(err, results) { should.not.exist(results); should.exist(err); - err.message.should.equal('The placeTextSearch API requires a key. You can add it to the config.'); + err.message.should.equal('The placeSearchText API requires a key. You can add it to the config.'); done(); }); }); @@ -84,7 +84,7 @@ describe('placeText', function() { function(invalid) { return function() { it('should not accept ' + invalid + ' as params', function(done){ - gmAPI.placeText( invalid, function(err, results) { + gmAPI.placeSearchText( invalid, function(err, results) { should.not.exist(results); should.exist(err); err.message.should.equal('params must be an object'); @@ -104,7 +104,7 @@ describe('placeText', function() { radius: 10000 }; - gmAPI.placeText( params, function(err, results) { + gmAPI.placeSearchText( params, function(err, results) { should.not.exist(results); should.exist(err); err.message.should.equal('params.query is required'); @@ -122,7 +122,7 @@ describe('placeText', function() { query: '123+main+street' }; - gmAPI.placeText(params, function(err, result){ + gmAPI.placeSearchText(params, function(err, result){ should.not.exist(err); should.exist(result); result.status.should.equal('OK'); @@ -138,7 +138,7 @@ describe('placeText', function() { query: '123+main+street' }; - gmAPI.placeText(params, function(err, result){ + gmAPI.placeSearchText(params, function(err, result){ should.not.exist(err); should.exist(result); result.status.should.equal('OK'); @@ -154,7 +154,7 @@ describe('placeText', function() { query: '123+main+street' }; - gmAPI.placeText(params, function(err, result){ + gmAPI.placeSearchText(params, function(err, result){ should.not.exist(err); should.exist(result); result.status.should.equal('OK'); @@ -167,4 +167,4 @@ describe('placeText', function() { }); -}); \ No newline at end of file +});