From bb230f4731b4bc62b52c5e19f082d74eadabc5f4 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Tue, 18 Oct 2011 14:48:27 +0100 Subject: [PATCH] Simplify getErrorDialog, add a test for getErrorDialog. --- .../dialog/controllers/page_controller.js | 12 +------- .../static/dialog/resources/error-messages.js | 28 +++++++++---------- .../controllers/page_controller_unit_test.js | 28 +++++++++++++++++-- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/browserid/static/dialog/controllers/page_controller.js b/browserid/static/dialog/controllers/page_controller.js index 0a9361bf7..6904b0fb8 100644 --- a/browserid/static/dialog/controllers/page_controller.js +++ b/browserid/static/dialog/controllers/page_controller.js @@ -133,16 +133,6 @@ } }, - /** - * Immediately show the error dialog - * @method errorDialog - * @param {object} info - info to use for the error dialog. Should have - * two fields, message, description. - */ - errorDialog: function(info) { - this.renderError({title: info.message, message: info.description}); - }, - /** * Get a curried function to an error dialog. * @method getErrorDialog @@ -151,7 +141,7 @@ */ getErrorDialog: function(info) { var self=this; - return self.errorDialog.bind(self, info); + return self.renderError.bind(self, info); }, onCancel: function(event) { diff --git a/browserid/static/dialog/resources/error-messages.js b/browserid/static/dialog/resources/error-messages.js index dd7ee7313..860760fb8 100644 --- a/browserid/static/dialog/resources/error-messages.js +++ b/browserid/static/dialog/resources/error-messages.js @@ -38,44 +38,44 @@ BrowserID.Errors = (function(){ var Errors = { authentication: { type: "serverError", - message: "Error Authenticating", - description: "There was a technical problem while trying to log you in. Yucky!" + title: "Error Authenticating", + message: "There was a technical problem while trying to log you in. Yucky!" }, addEmail: { type: "serverError", - message: "Error Adding Address", - description: "There was a technical problem while trying to add this email to your account. Yucky!" + title: "Error Adding Address", + message: "There was a technical problem while trying to add this email to your account. Yucky!" }, checkAuthentication: { type: "serverError", - message: "Error Checking Authentication", - description: "There was a technical problem while trying to log you in. Yucky!" + title: "Error Checking Authentication", + message: "There was a technical problem while trying to log you in. Yucky!" }, createAccount: { type: "serverError", - message: "Error Creating Account", - description: "There was a technical problem while trying to create your account. Yucky!" + title: "Error Creating Account", + message: "There was a technical problem while trying to create your account. Yucky!" }, registration: { type: "serverError", - message: "Registration Failed", - description: "An error was encountered and the signup cannot be completed. Yucky!" + title: "Registration Failed", + message: "An error was encountered and the signup cannot be completed. Yucky!" }, signIn: { type: "serverError", - message: "Signin Failed", - description: "There was an error signing in. Yucky!" + title: "Signin Failed", + message: "There was an error signing in. Yucky!" }, syncAddress: { type: "serverError", - message: "Error Syncing Address", - description: "There was a technical problem while trying to synchronize your account. Yucky!" + title: "Error Syncing Address", + message: "There was a technical problem while trying to synchronize your account. Yucky!" } }; diff --git a/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js b/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js index 92ed30efc..fca829d5c 100644 --- a/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js +++ b/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js @@ -100,7 +100,7 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() { ok(html.length, "with wait template specified, wait text is loaded"); }); - test("renderError does what it is meant to", function() { + test("renderError renders an error message", function() { controller = el.page({ waitTemplate: waitTemplate, waitVars: { @@ -109,14 +109,38 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() { } }).controller(); - el.page("renderError", { + controller.renderError({ title: "error title", message: "error message" }); var html = el.find("#error .contents").html(); + // XXX underpowered test, we don't actually check the contents. ok(html.length, "with error template specified, error text is loaded"); }); + test("getErrorDialog gets a function that can be used to render an error message", function() { + controller = el.page({ + waitTemplate: waitTemplate, + waitVars: { + title: "Test title", + message: "Test message" + } + }).controller(); + + var func = controller.getErrorDialog({ + title: "error title", + message: "error message" + }); + + equal(typeof func, "function", "a function was returned from getErrorDialog"); + func(); + + var html = el.find("#error .contents").html(); + // XXX underpowered test, we don't actually check the contents. + ok(html.length, "when function is run, error text is loaded"); + + }); + }); -- GitLab