You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/11/22 21:47:47 UTC
[1/9] js commit: [all] Use argscheck in geolocation.js
Updated Branches:
refs/heads/master 6798d210b -> ee4a70cce
[all] Use argscheck in geolocation.js
https://issues.apache.org/jira/browse/CB-1892
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/f81be662
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/f81be662
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/f81be662
Branch: refs/heads/master
Commit: f81be6623d3429f442a0e214adfe3f66fff32b1f
Parents: 58990da
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Nov 22 15:39:24 2012 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Nov 22 15:45:06 2012 -0500
----------------------------------------------------------------------
lib/common/plugin/geolocation.js | 11 ++++-------
test/test.geolocation.js | 4 ++--
2 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f81be662/lib/common/plugin/geolocation.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/geolocation.js b/lib/common/plugin/geolocation.js
index a5d47ec..6af92ca 100644
--- a/lib/common/plugin/geolocation.js
+++ b/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();
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f81be662/test/test.geolocation.js
----------------------------------------------------------------------
diff --git a/test/test.geolocation.js b/test/test.geolocation.js
index dfd8bdc..ad3c508 100644
--- a/test/test.geolocation.js
+++ b/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() {