cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject cordova-plugin-geolocation git commit: CB-8443 Geolocation tests fail on Windows due to done is called multiple times
Date Thu, 05 Feb 2015 19:25:44 GMT
Repository: cordova-plugin-geolocation
Updated Branches:
  refs/heads/master a5618f990 -> acbceabfe


CB-8443 Geolocation tests fail on Windows due to done is called multiple times


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/acbceabf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/acbceabf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/acbceabf

Branch: refs/heads/master
Commit: acbceabfe5f12e4d8a2fb9a4cb730356214905bc
Parents: a5618f9
Author: sgrebnov <v-segreb@microsoft.com>
Authored: Thu Feb 5 22:25:39 2015 +0300
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Thu Feb 5 22:25:39 2015 +0300

----------------------------------------------------------------------
 tests/tests.js | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/acbceabf/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 4a99991..89fc957 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -25,7 +25,10 @@ exports.defineAutoTests = function () {
     },
     succeed = function (done) {
         expect(true).toBe(true);
-        done();
+        // callback could be called sync so we invoke done async to make sure we know watcher
id to .clear in afterEach 
+        setTimeout(function () {
+            done();
+        });
     };
     var isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows"
&& !WinJS.Utilities.isPhone);
 
@@ -135,11 +138,20 @@ exports.defineAutoTests = function () {
                 if (isWindowsStore) {
                     pending();
                 }
+                var self = this;
                 successWatch = navigator.geolocation.watchPosition(
                     function (p) {
+                        // prevents done() to be called several times
+                        if (self.done) return;
+                        self.done = true;
+
                         expect(p.coords).toBeDefined();
                         expect(p.timestamp).toBeDefined();
-                        done();
+                        // callback could be called sync so we invoke done async to make
sure we know watcher id to .clear in afterEach 
+                        setTimeout(function () {
+                            done();
+                        })
+                        
                     },
                     fail.bind(null, done),
                     {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message