aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2013-01-30 18:10:39 +0100
committerFelix Nagel <info@felixnagel.com>2013-01-30 18:10:39 +0100
commit91dde04dadcd9b314e099ced040a763aa35b7b5c (patch)
tree3572e1b71f5c8998c46e411b9d992795a1105530 /tests
parentde149c47d79bf5822baad786591eb837fe2af769 (diff)
parentceebe07e2c99190030c16b031813ae660d9283d1 (diff)
downloadjquery-ui-91dde04dadcd9b314e099ced040a763aa35b7b5c.tar.gz
jquery-ui-91dde04dadcd9b314e099ced040a763aa35b7b5c.zip
Merge branch 'master' into selectmenu
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/accordion/accordion_events.js7
-rw-r--r--tests/unit/datepicker/datepicker_options.js18
-rw-r--r--tests/unit/dialog/dialog_methods.js33
-rw-r--r--tests/unit/dialog/dialog_options.js36
-rw-r--r--tests/unit/effects/effects_core.js11
5 files changed, 94 insertions, 11 deletions
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index b67f2b26d..79283d11c 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -6,7 +6,7 @@ var setupTeardown = TestHelpers.accordion.setupTeardown,
module( "accordion: events", setupTeardown() );
test( "create", function() {
- expect( 10 );
+ expect( 15 );
var element = $( "#list1" ),
headers = element.children( "h3" ),
@@ -16,6 +16,8 @@ test( "create", function() {
create: function( event, ui ) {
equal( ui.header.length, 1, "header length" );
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
+ equal( ui.panel.length, 1, "panel length" );
+ strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
equal( ui.content.length, 1, "content length" );
strictEqual( ui.content[ 0 ], contents[ 0 ], "content" );
}
@@ -27,6 +29,8 @@ test( "create", function() {
create: function( event, ui ) {
equal( ui.header.length, 1, "header length" );
strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
+ equal( ui.panel.length, 1, "panel length" );
+ strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
equal( ui.content.length, 1, "content length" );
strictEqual( ui.content[ 0 ], contents[ 2 ], "content" );
}
@@ -38,6 +42,7 @@ test( "create", function() {
collapsible: true,
create: function( event, ui ) {
equal( ui.header.length, 0, "header length" );
+ equal( ui.panel.length, 0, "panel length" );
equal( ui.content.length, 0, "content length" );
}
});
diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js
index e47235786..dac2262dc 100644
--- a/tests/unit/datepicker/datepicker_options.js
+++ b/tests/unit/datepicker/datepicker_options.js
@@ -384,7 +384,7 @@ test("miscellaneous", function() {
});
test("minMax", function() {
- expect( 19 );
+ expect( 23 );
var date,
inp = TestHelpers.datepicker.init("#inp"),
dp = $("#ui-datepicker-div"),
@@ -472,6 +472,22 @@ test("minMax", function() {
ok(dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - previous button disabled at 1/1/minYear");
inp.datepicker("setDate", "12/30/" + new Date().getFullYear());
ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled at 12/30/maxYear");
+
+ inp.datepicker("option", {
+ minDate: new Date(1900, 0, 1),
+ maxDate: "-6Y",
+ yearRange: "1900:-6"
+ }).val( "" );
+ ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled");
+ ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - prev button enabled");
+
+ inp.datepicker("option", {
+ minDate: new Date(1900, 0, 1),
+ maxDate: "1/25/2007",
+ yearRange: "1900:2007"
+ }).val( "" );
+ ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled");
+ ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - prev button enabled");
});
test("setDate", function() {
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js
index b4c58c31e..efca71fd8 100644
--- a/tests/unit/dialog/dialog_methods.js
+++ b/tests/unit/dialog/dialog_methods.js
@@ -34,7 +34,9 @@ test("init", function() {
});
test("destroy", function() {
- expect( 7 );
+ expect( 17 );
+
+ var el, el2;
$( "#dialog1, #form-dialog" ).hide();
domEqual( "#dialog1", function() {
@@ -57,6 +59,35 @@ test("destroy", function() {
domEqual( "#dialog1", function() {
$( "#dialog1" ).dialog().dialog( "destroy" );
});
+
+ // Don't throw errors when destroying a never opened modal dialog (#9004)
+ $( "#dialog1" ).dialog({ autoOpen: false, modal: true }).dialog( "destroy" );
+ equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" );
+ equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays");
+
+ el = $( "#dialog1" ).dialog({ modal: true }),
+ el2 = $( "#dialog2" ).dialog({ modal: true });
+ equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" );
+ equal( $.ui.dialog.overlayInstances, 2, "overlayInstances equals the number of open overlays" );
+ el.dialog( "close" );
+ equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after closing one dialog" );
+ equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" );
+ el.dialog( "destroy" );
+ equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after destroying one dialog" );
+ equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" );
+ el2.dialog( "destroy" );
+ equal( $( ".ui-widget-overlay" ).length, 0, "overlays removed when all dialogs are destoryed" );
+ equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays" );
+});
+
+asyncTest("#9000: Dialog leaves broken event handler after close/destroy in certain cases", function() {
+ expect( 1 );
+ $( "#dialog1" ).dialog({ modal:true }).dialog( "close" ).dialog( "destroy" );
+ setTimeout(function() {
+ $( "#favorite-animal" ).focus();
+ ok( true, "close and destroy modal dialog before its really opened" );
+ start();
+ }, 2 );
});
test("#4980: Destroy should place element back in original DOM position", function(){
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js
index a20480de6..5f0434308 100644
--- a/tests/unit/dialog/dialog_options.js
+++ b/tests/unit/dialog/dialog_options.js
@@ -6,43 +6,63 @@
module("dialog: options");
test( "appendTo", function() {
- expect( 8 );
+ expect( 16 );
var detached = $( "<div>" ),
- element = $( "#dialog1" ).dialog();
+ element = $( "#dialog1" ).dialog({
+ modal: true
+ });
equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" );
+ equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay defaults to body" );
element.dialog( "destroy" );
element.dialog({
- appendTo: ".wrap"
+ appendTo: ".wrap",
+ modal: true
});
equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" );
+ equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay first found element" );
equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" );
+ equal( $( "#wrap2 .ui-widget-overlay" ).length, 0, "overlay only appends to one element" );
element.dialog( "destroy" );
element.dialog({
- appendTo: null
+ appendTo: null,
+ modal: true
});
equal( element.dialog( "widget" ).parent()[0], document.body, "null" );
+ equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay null" );
element.dialog( "destroy" );
- element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
+ element.dialog({
+ autoOpen: false,
+ modal: true
+ }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" );
+ equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay modified after init" );
element.dialog( "destroy" );
element.dialog({
- appendTo: detached
+ appendTo: detached,
+ modal: true
});
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" );
+ equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached jQuery object" );
element.dialog( "destroy" );
element.dialog({
- appendTo: detached[0]
+ appendTo: detached[0],
+ modal: true
});
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" );
+ equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached DOM element" );
element.dialog( "destroy" );
- element.dialog({ autoOpen: false }).dialog( "option", "appendTo", detached );
+ element.dialog({
+ autoOpen: false,
+ modal: true
+ }).dialog( "option", "appendTo", detached );
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
+ equal( detached.find( ".ui-widget-overlay" ).length, 0, "overlay detached DOM element via option()" );
element.dialog( "destroy" );
});
diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js
index 26390b7d3..c9b1e1b4a 100644
--- a/tests/unit/effects/effects_core.js
+++ b/tests/unit/effects/effects_core.js
@@ -38,6 +38,17 @@ asyncTest( "Parse of null for options", function() {
});
});
+test( "removeClass", function() {
+ expect( 3 );
+
+ var element = $( "<div>" );
+ equal( "", element[ 0 ].className );
+ element.addClass( "destroyed" );
+ equal( "destroyed", element[ 0 ].className );
+ element.removeClass();
+ equal( "", element[ 0 ].className );
+});
+
/* TODO: Disabled - Can't figure out why this is failing in IE 6/7
test( "createWrapper and removeWrapper retain focused elements (#7595)", function() {