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/07 21:21:05 UTC

spec commit: Test both navigator.network.connection and navigator.connection

Updated Branches:
  refs/heads/master 2cfdcc800 -> 7f7ba8526


Test both navigator.network.connection and navigator.connection

in the auto tests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/7f7ba852
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/7f7ba852
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/7f7ba852

Branch: refs/heads/master
Commit: 7f7ba8526781ba052145c981f14ca2501ad67750
Parents: 2cfdcc8
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Nov 7 15:20:09 2012 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Nov 7 15:20:09 2012 -0500

----------------------------------------------------------------------
 autotest/tests/network.tests.js |   48 +++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/7f7ba852/autotest/tests/network.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/network.tests.js b/autotest/tests/network.tests.js
index 03f78ac..8a38c84 100644
--- a/autotest/tests/network.tests.js
+++ b/autotest/tests/network.tests.js
@@ -19,28 +19,36 @@
  *
 */
 
-describe('Network (navigator.network)', function () {
-	it("should exist", function() {
-        expect(navigator.network).toBeDefined();
-	});
+describe('Network (navigator.connection)', function () {
+    it("should exist", function() {
+        expect(navigator.network && navigator.network.connection).toBeDefined();
+        expect(navigator.connection).toBeDefined();
+    });
 
-    describe('Network Information API', function () {
-        it("connection should exist", function() {
-            expect(navigator.network.connection).toBeDefined();
-        });
+    it("should be set to a valid value", function() {
+        var validValues = {
+            'unknown': 1,
+            'ethernet': 1,
+            'wifi': 1,
+            '2g': 1,
+            '3g': 1,
+            '4g': 1,
+            'none': 1
+        };
+        expect(validValues[navigator.connection.type]).toBe(1);
+    });
 
-        it("should contain connection properties", function() {
-            expect(navigator.network.connection.type).toBeDefined();
-        });
+    it("should have the same value in deprecated and non-deprecated apis", function() {
+        expect(navigator.network.connection.type).toBe(navigator.connection.type);
+    });
 
-        it("should define constants for connection status", function() {
-            expect(Connection.UNKNOWN).toBe("unknown");
-            expect(Connection.ETHERNET).toBe("ethernet");
-            expect(Connection.WIFI).toBe("wifi");
-            expect(Connection.CELL_2G).toBe("2g");
-            expect(Connection.CELL_3G).toBe("3g");
-            expect(Connection.CELL_4G).toBe("4g");
-            expect(Connection.NONE).toBe("none");
-        });
+    it("should define constants for connection status", function() {
+        expect(Connection.UNKNOWN).toBe("unknown");
+        expect(Connection.ETHERNET).toBe("ethernet");
+        expect(Connection.WIFI).toBe("wifi");
+        expect(Connection.CELL_2G).toBe("2g");
+        expect(Connection.CELL_3G).toBe("3g");
+        expect(Connection.CELL_4G).toBe("4g");
+        expect(Connection.NONE).toBe("none");
     });
 });