Skip to content
Snippets Groups Projects
Commit 32346f0a authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

Make sure the first input element is focused. Adding a test for this.

parent aa26aaf2
No related branches found
No related tags found
No related merge requests found
......@@ -83,9 +83,7 @@
if (body) {
var bodyHtml = $.View("//dialog/views/" + body, body_vars);
target = $(target + " .contents");
target.html(bodyHtml);//.hide().fadeIn(ANIMATION_TIME, function() {
target.find("input").eq(0).focus();
//});
target.html(bodyHtml).find("input").eq(0).focus();
}
},
......
......@@ -37,7 +37,9 @@
steal.plugins("jquery").then("/dialog/controllers/page_controller", function() {
"use strict";
var controller, el;
var controller, el,
bodyTemplate = "testBodyTemplate.ejs",
waitTemplate = "wait.ejs";
module("PageController", {
setup: function() {
......@@ -61,9 +63,9 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() {
equal(html, "", "with no template specified, no text is loaded");
});
test("page controller with body template renders in #formWrap > form", function() {
test("page controller with body template renders in #formWrap .contents", function() {
controller = el.page({
bodyTemplate: "wait.ejs",
bodyTemplate: bodyTemplate,
bodyVars: {
title: "Test title",
message: "Test message"
......@@ -73,13 +75,17 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() {
var html = el.find("#formWrap .contents").html();
ok(html.length, "with template specified, form text is loaded");
var input = el.find("input").eq(0);
ok(input.is(":focus"), "make sure the first input is focused");
html = el.find("#wait .contents").html();
equal(html, "", "with body template specified, wait text is not loaded");
});
test("page controller with wait template renders in #wait .contents", function() {
controller = el.page({
waitTemplate: "wait.ejs",
waitTemplate: waitTemplate,
waitVars: {
title: "Test title",
message: "Test message"
......
......@@ -10,6 +10,7 @@ steal("/dialog/resources/browserid.js",
"jquery/controller/view",
"jquery/view/ejs",
"funcunit/qunit")
.views('testBodyTemplate.ejs')
.views('wait.ejs')
.then("browserid_unit_test")
.then("controllers/page_controller_unit_test")
......
<input type="text" value="" />
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment