cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [4/7] git commit: CB-6964 ported manual tests
Date Thu, 07 Aug 2014 20:36:39 GMT
CB-6964 ported manual tests

Fixed up style

Fixed typo in addEventListener


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

Branch: refs/heads/master
Commit: fa1bcac78a4e22f0c01b78dcf87a5b64c2959938
Parents: fe2b8fb
Author: Staci Cooper <smcooper@us.ibm.com>
Authored: Wed Jul 16 13:51:46 2014 -0400
Committer: Staci Cooper <smcooper@us.ibm.com>
Committed: Mon Jul 28 16:40:42 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 45 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/fa1bcac7/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 83f28d3..26163b6 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -19,14 +19,14 @@
  *
 */
 
-exports.defineAutoTests = function() {
+exports.defineAutoTests = function () {
     describe('Network (navigator.connection)', function () {
-        it("network.spec.1 should exist", function() {
+        it("network.spec.1 should exist", function () {
             expect(navigator.network && navigator.network.connection).toBeDefined();
             expect(navigator.connection).toBeDefined();
         });
 
-        it("network.spec.2 should be set to a valid value", function() {
+        it("network.spec.2 should be set to a valid value", function () {
             var validValues = {
                 'unknown': 1,
                 'ethernet': 1,
@@ -40,11 +40,11 @@ exports.defineAutoTests = function() {
             expect(validValues[navigator.connection.type]).toBe(1);
         });
 
-        it("network.spec.3 should have the same value in deprecated and non-deprecated apis",
function() {
+        it("network.spec.3 should have the same value in deprecated and non-deprecated apis",
function () {
             expect(navigator.network.connection.type).toBe(navigator.connection.type);
         });
 
-        it("network.spec.4 should define constants for connection status", function() {
+        it("network.spec.4 should define constants for connection status", function () {
             expect(Connection.UNKNOWN).toBe("unknown");
             expect(Connection.ETHERNET).toBe("ethernet");
             expect(Connection.WIFI).toBe("wifi");
@@ -56,3 +56,43 @@ exports.defineAutoTests = function() {
         });
     });
 };
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+exports.defineManualTests = function (contentEl, createActionButton) {
+    function eventOutput(s) {
+        var el = document.getElementById("results");
+        el.innerHTML = el.innerHTML + s + "<br>";
+    }
+
+    function printNetwork() {
+        eventOutput("navigator.connection.type=" + navigator.connection.type);
+        eventOutput("navigator.network.connection.type=" + navigator.network.connection.type);
+    }
+
+    function onEvent(e) {
+        eventOutput('Event of type: ' + e.type);
+        printNetwork();
+    }
+
+    /******************************************************************************/
+
+    var html = '<div id="info">' +
+        '<b>Results:</b><br>' +
+        '<span id="results"></span>' +
+        '</div><div id="actions"></div>';
+
+    document.addEventListener("online", onEvent, false);
+    document.addEventListener("offline", onEvent, false);
+    contentEl.innerHTML = html;
+
+    createActionButton('Show Network Connection', function () {
+        printNetwork();
+    }, 'actions');
+
+    createActionButton('Clear Log', function () {
+        document.getElementById('results').innerHTML = '';
+    }, 'actions');
+};


Mime
View raw message