You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2016/01/27 11:02:35 UTC
cordova-plugin-inappbrowser git commit: CB-10441 Add auto tests for
InAppBrowser plugin
Repository: cordova-plugin-inappbrowser
Updated Branches:
refs/heads/CB-10441 [created] 79e35d979
CB-10441 Add auto tests for InAppBrowser plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/79e35d97
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/79e35d97
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/79e35d97
Branch: refs/heads/CB-10441
Commit: 79e35d9790df31369c47c742b63a016669f776dc
Parents: 2e0dc26
Author: sgrebnov <v-...@microsoft.com>
Authored: Wed Jan 27 12:35:44 2016 +0300
Committer: sgrebnov <v-...@microsoft.com>
Committed: Wed Jan 27 13:00:28 2016 +0300
----------------------------------------------------------------------
tests/tests.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/79e35d97/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index a827986..855403d 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -24,6 +24,78 @@ var isWindows = cordova.platformId == 'windows';
window.alert = window.alert || navigator.notification.alert;
+exports.defineAutoTests = function () {
+
+ describe('cordova.InAppBrowser', function () {
+
+ it("inappbrowser.spec.1 should exist", function () {
+ expect(cordova.InAppBrowser).toBeDefined();
+ });
+
+ it("inappbrowser.spec.2 should contain open function", function () {
+ expect(cordova.InAppBrowser.open).toBeDefined();
+ expect(typeof cordova.InAppBrowser.open === 'function').toBe(true);
+ });
+ });
+
+ describe('open method', function () {
+
+ var iabInsance;
+ var originalTimeout;
+ var url = 'http://apache.org/';
+
+ beforeEach(function () {
+ // increase timeout to ensure test url could be loaded within test time
+ originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
+ jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+
+ iabInsance = null;
+ });
+
+ afterEach(function () {
+ // restore original timeout
+ jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
+
+ if (iabInsance && iabInsance.close) {
+ iabInsance.close();
+ }
+ iabInsance = null;
+ });
+
+ function verifyEvent(evt, type) {
+ expect(evt).toBeDefined();
+ expect(evt.type).toEqual(type);
+ expect(evt.url).toEqual(url);
+ }
+
+ it("inappbrowser.spec.3 should retun InAppBrowser class instance", function () {
+ iabInsance = cordova.InAppBrowser.open(url, '_blank');
+
+ expect(iabInsance).toBeDefined();
+
+ expect(iabInsance.addEventListener).toBeDefined();
+ expect(typeof iabInsance.addEventListener === 'function').toBe(true);
+ expect(iabInsance.close).toBeDefined();
+ expect(typeof iabInsance.close === 'function').toBe(true);
+
+ });
+
+ it("inappbrowser.spec.4 should support loadstart and loadstop events", function (done) {
+ var onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) {
+ verifyEvent(evt, 'loadstart');
+ });
+
+ iabInsance = cordova.InAppBrowser.open(url, '_blank');
+ iabInsance.addEventListener('loadstart', onLoadStart);
+ iabInsance.addEventListener('loadstop', function (evt) {
+ verifyEvent(evt, 'loadstop');
+ expect(onLoadStart).toHaveBeenCalled();
+ done();
+ });
+ });
+ });
+};
+
exports.defineManualTests = function (contentEl, createActionButton) {
function doOpen(url, target, params, numExpectedRedirects, useWindowOpen) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org