Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[all] Use argscheck in geolocation.js

  • Loading branch information...
commit f81be6623d3429f442a0e214adfe3f66fff32b1f 1 parent 58990da
@agrieve agrieve authored
Showing with 6 additions and 9 deletions.
  1. +4 −7 lib/common/plugin/geolocation.js
  2. +2 −2 test/test.geolocation.js
View
11 lib/common/plugin/geolocation.js
@@ -19,7 +19,8 @@
*
*/
-var utils = require('cordova/utils'),
+var argscheck = require('cordova/argscheck'),
+ utils = require('cordova/utils'),
exec = require('cordova/exec'),
PositionError = require('cordova/plugin/PositionError'),
Position = require('cordova/plugin/Position');
@@ -76,9 +77,7 @@ var geolocation = {
* @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
*/
getCurrentPosition:function(successCallback, errorCallback, options) {
- if (arguments.length === 0) {
- throw new Error("getCurrentPosition must be called with at least one argument.");
- }
+ argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
options = parseParameters(options);
// Timer var that will fire an error callback if no position is retrieved from native
@@ -154,9 +153,7 @@ var geolocation = {
* @return String The watch id that must be passed to #clearWatch to stop watching.
*/
watchPosition:function(successCallback, errorCallback, options) {
- if (arguments.length === 0) {
- throw new Error("watchPosition must be called with at least one argument.");
- }
+ argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
options = parseParameters(options);
var id = utils.createUUID();
View
4 test/test.geolocation.js
@@ -65,7 +65,7 @@ describe("geolocation", function () {
});
it("should throw an exception if used with no arguments", function() {
- expect(function() { geo.getCurrentPosition();}).toThrow("getCurrentPosition must be called with at least one argument.");
+ expect(function() { geo.getCurrentPosition();}).toThrow();
});
});
describe("position acquisition", function() {
@@ -197,7 +197,7 @@ describe("geolocation", function () {
});
it("should throw an exception if used with no arguments", function() {
- expect(function() { geo.watchPosition();}).toThrow("watchPosition must be called with at least one argument.");
+ expect(function() { geo.watchPosition();}).toThrow();
});
});
describe("position acquisition", function() {
Please sign in to comment.
Something went wrong with that request. Please try again.