You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/08/07 22:04:16 UTC
[3/5] git commit: CB-6965 Added manual tests
CB-6965 Added manual tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/1af76d83
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/1af76d83
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/1af76d83
Branch: refs/heads/master
Commit: 1af76d830ae37e748fdaa039e6b8d3b76a57754e
Parents: 25c1e2d
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Fri Jul 18 14:13:51 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Fri Jul 18 14:13:51 2014 -0400
----------------------------------------------------------------------
test/tests.js | 138 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 130 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/1af76d83/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index a3df525..99ddf6e 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -19,30 +19,152 @@
*
*/
-exports.defineAutoTests = function() {
+exports.defineAutoTests = function () {
describe('Notification (navigator.notification)', function () {
- it("should exist", function() {
- expect(navigator.notification).toBeDefined();
+ it("should exist", function () {
+ expect(navigator.notification).toBeDefined();
});
- it("should contain a beep function", function() {
+ it("should contain a beep function", function () {
expect(typeof navigator.notification.beep).toBeDefined();
expect(typeof navigator.notification.beep).toBe("function");
});
- it("should contain an alert function", function() {
+ it("should contain an alert function", function () {
expect(typeof navigator.notification.alert).toBeDefined();
expect(typeof navigator.notification.alert).toBe("function");
});
- it("should contain a confirm function", function() {
+ it("should contain a confirm function", function () {
expect(typeof navigator.notification.confirm).toBeDefined();
expect(typeof navigator.notification.confirm).toBe("function");
});
-
- it("should contain a prompt function", function() {
+
+ it("should contain a prompt function", function () {
expect(typeof navigator.notification.prompt).toBeDefined();
expect(typeof navigator.notification.prompt).toBe("function");
});
});
};
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+exports.defineManualTests = function (contentEl, createActionButton) {
+ var logMessage = function (message) {
+ var log = document.getElementById('info');
+ var logLine = document.createElement('div');
+ logLine.innerHTML = message;
+ log.appendChild(logLine);
+ }
+
+ var clearLog = function () {
+ var log = document.getElementById('info');
+ log.innerHTML = '';
+ }
+
+ var beep = function () {
+ console.log("beep()");
+ navigator.notification.beep(3);
+ };
+
+ var alertDialog = function (message, title, button) {
+ console.log("alertDialog()");
+ navigator.notification.alert(message,
+ function () {
+ console.log("Alert dismissed.");
+ },
+ title, button);
+ console.log("After alert");
+ };
+
+ var confirmDialogA = function (message, title, buttons) {
+ clearLog();
+ navigator.notification.confirm(message,
+ function (r) {
+ if (r === 0) {
+ logMessage("Dismissed dialog without making a selection.");
+ console.log("Dismissed dialog without making a selection.");
+ } else {
+ console.log("You selected " + r);
+ logMessage("You selected " + (buttons.split(","))[r - 1]);
+ }
+ },
+ title,
+ buttons);
+ };
+
+ var confirmDialogB = function (message, title, buttons) {
+ clearLog();
+ navigator.notification.confirm(message,
+ function (r) {
+ if (r === 0) {
+ logMessage("Dismissed dialog without making a selection.");
+ console.log("Dismissed dialog without making a selection.");
+ } else {
+ console.log("You selected " + r);
+ logMessage("You selected " + buttons[r - 1]);
+ }
+ },
+ title,
+ buttons);
+ };
+
+ var promptDialog = function (message, title, buttons) {
+ clearLog();
+ navigator.notification.prompt(message,
+ function (r) {
+ if (r && r.buttonIndex === 0) {
+ var msg = "Dismissed dialog";
+ if (r.input1) {
+ msg += " with input: " + r.input1
+ }
+ logMessage(msg);
+ console.log(msg);
+ } else {
+ console.log("You selected " + r.buttonIndex + " and entered: " + r.input1);
+ logMessage("You selected " + buttons[r.buttonIndex - 1] + " and entered: " + r.input1);
+ }
+ },
+ title,
+ buttons);
+ };
+
+ /******************************************************************************/
+
+ contentEl.innerHTML = '<div id="info"></div>' +
+ '<div id="actions"></div>';
+
+ createActionButton('Beep', function () {
+ beep();
+ }, 'actions');
+
+ createActionButton('Alert Dialog', function () {
+ alertDialog('You pressed alert.', 'Alert Dialog', 'Continue');
+ }, 'actions');
+
+ createActionButton('Confirm Dialog - Deprecated', function () {
+ confirmDialogA('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');
+ }, 'actions');
+
+ createActionButton('Confirm Dialog', function () {
+ confirmDialogB('You pressed confirm.', 'Confirm Dialog', ['Yes', 'No', 'Maybe, Not Sure']);
+ }, 'actions');
+
+ createActionButton('Prompt Dialog', function () {
+ promptDialog('You pressed prompt.', 'Prompt Dialog', ['Yes', 'No', 'Maybe, Not Sure']);
+ }, 'actions');
+
+ createActionButton('Built-in Alert Dialog', function () {
+ alert('You pressed alert');
+ }, 'actions');
+
+ createActionButton('Built-in Confirm Dialog', function () {
+ confirm('You selected confirm');
+ }, 'actions');
+
+ createActionButton('Built-in Prompt Dialog', function () {
+ prompt('This is a prompt', 'Default value');
+ }, 'actions');
+};