mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-03-15 04:41:01 +08:00
CB-6964 ported manual tests
Fixed up style Fixed typo in addEventListener
This commit is contained in:
parent
fe2b8fb5db
commit
fa1bcac78a
@ -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');
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user