laid out last getCurrentPosition tests

Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/ee713bbc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/ee713bbc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/ee713bbc

Branch: refs/heads/master
Commit: ee713bbc962a9d9d096e051f91b9885ae0d33641
Parents: 95d979d
Author: Fil Maj <maj....@gmail.com>
Authored: Thu Mar 22 23:47:49 2012 -0700
Committer: Fil Maj <maj....@gmail.com>
Committed: Mon May 7 13:51:05 2012 -0700

----------------------------------------------------------------------
 test/test.geolocation.js |   80 ++++++++++++++++++++++++-----------------
 1 files changed, 47 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ee713bbc/test/test.geolocation.js
----------------------------------------------------------------------
diff --git a/test/test.geolocation.js b/test/test.geolocation.js
index e5fe4f2..87b1b24 100644
--- a/test/test.geolocation.js
+++ b/test/test.geolocation.js
@@ -11,44 +11,58 @@ describe("geolocation", function () {
         exec.reset();
     });
 
-    describe("when getting the current position", function () {
-        beforeEach(function() {
-            geo.lastPosition = null; // reset the cached position
-        });
+    describe("getCurrentPosition", function() {
+        describe("arguments", function () {
+            beforeEach(function() {
+                geo.lastPosition = null; // reset the cached position
+            });
 
-        it("uses default PositionOptions if none are specified", function () {
-            geo.getCurrentPosition(s, e);
-            expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [false, Infinity, 0]);
-        });
+            it("uses default PositionOptions if none are specified", function 
() {
+                geo.getCurrentPosition(s, e);
+                expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [false, Infinity, 0]);
+            });
 
-        it("uses the maximumAge option if specified", function () {
-            geo.getCurrentPosition(s, e, {maximumAge: 10});
-            expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [false, Infinity, 10]);
-        });
+            it("uses the maximumAge option if specified", function () {
+                geo.getCurrentPosition(s, e, {maximumAge: 10});
+                expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [false, Infinity, 10]);
+            });
 
-        it("uses the enableHighAccuracy option if specified", function () {
-            geo.getCurrentPosition(s, e, {enableHighAccuracy: true, 
maximumAge: 100});
-            expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [true, Infinity, 100]);
-        });
+            it("uses the enableHighAccuracy option if specified", function () {
+                geo.getCurrentPosition(s, e, {enableHighAccuracy: true, 
maximumAge: 100});
+                expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [true, Infinity, 100]);
+            });
 
-        it("uses the timeout option if specified and positive", function () {
-            geo.getCurrentPosition(s, e, {timeout: 1000});
-            expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [false, 1000, 0]);
-        });
-        it("uses a timeout value of 0 if specified and negative, which should 
call the error callback immediately (since we have no cached position)", 
function () {
-            geo.getCurrentPosition(s, e, {timeout: -1000});
-            expect(e).toHaveBeenCalledWith({
-                code:PositionError.TIMEOUT,
-                message:"timeout value in PositionOptions set to 0 and no 
cached Position object available, or cached Position object's age exceed's 
provided PositionOptions' maximumAge parameter."
+            it("uses the timeout option if specified and positive", function 
() {
+                geo.getCurrentPosition(s, e, {timeout: 1000});
+                expect(exec).toHaveBeenCalledWith(jasmine.any(Function), 
jasmine.any(Function), "Geolocation", "getLocation", [false, 1000, 0]);
+            });
+            it("uses a timeout value of 0 if specified and negative, which 
should call the error callback immediately (since we have no cached position)", 
function () {
+                geo.getCurrentPosition(s, e, {timeout: -1000});
+                expect(e).toHaveBeenCalledWith({
+                    code:PositionError.TIMEOUT,
+                    message:"timeout value in PositionOptions set to 0 and no 
cached Position object available, or cached Position object's age exceed's 
provided PositionOptions' maximumAge parameter."
+                });
+            });
+            it("can be used with one, two or three arguments", function() {
+                expect(function() { geo.getCurrentPosition(s); 
}).not.toThrow();
+                expect(function() { geo.getCurrentPosition(s,e); 
}).not.toThrow();
+                expect(function() { geo.getCurrentPosition(s,e,{}); 
}).not.toThrow();
+            });
+            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.");
+            });
+        })
+        describe("position acquisition", function() {
+            it("should provide a cached position if one exists and has a 
timestamp value conforming with passed in maximumAge", function() {
+            });
+            it("should fire error callback with TIMEOUT code after timeout 
period has elapsed and no position is available", function() {
+            });
+            it("should not fire error callback with TIMEOUT if a position is 
obtained within the timeout period", function() {
+            });
+            it("should fire error callback with POSITION_UNAVAILABLE if error 
occurs during acquisition before timeout expires", function() {
+            });
+            it("should not fire error callback with TIMEOUT if error occurs 
during acquisition before timeout expires", function() {
             });
-        });
-        it("can be used with one, two or three arguments", function() {
-            expect(function() { geo.getCurrentPosition(s); }).not.toThrow();
-            expect(function() { geo.getCurrentPosition(s,e); }).not.toThrow();
-            expect(function() { geo.getCurrentPosition(s,e,{}); 
}).not.toThrow();
-        });
-        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.");
         });
     });
 

Reply via email to