aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2012-12-07 20:06:29 -0500
committerMike Sherov <mike.sherov@gmail.com>2012-12-07 20:06:29 -0500
commite83a89dd7df3009d46ddd9e7e1cabf42e901e397 (patch)
tree8ada242bd81857ace993ce09625d06236530cc4a /tests
parentd4551bc3b8dfbfd925700dcb9f71e7729b125889 (diff)
downloadjquery-ui-e83a89dd7df3009d46ddd9e7e1cabf42e901e397.tar.gz
jquery-ui-e83a89dd7df3009d46ddd9e7e1cabf42e901e397.zip
Dev: Remove *_tickets.js test files and move the associated tests to the proper locations.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/button/button_core.js56
-rw-r--r--tests/unit/button/button_options.js11
-rw-r--r--tests/unit/button/button_tickets.js75
-rw-r--r--tests/unit/dialog/dialog_core.js32
-rw-r--r--tests/unit/dialog/dialog_events.js14
-rw-r--r--tests/unit/dialog/dialog_methods.js48
-rw-r--r--tests/unit/dialog/dialog_options.js22
-rw-r--r--tests/unit/dialog/dialog_tickets.js121
-rw-r--r--tests/unit/sortable/sortable_events.js61
-rw-r--r--tests/unit/sortable/sortable_tickets.js69
10 files changed, 242 insertions, 267 deletions
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js
index 991e4bceb..460201f15 100644
--- a/tests/unit/button/button_core.js
+++ b/tests/unit/button/button_core.js
@@ -113,4 +113,60 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
});
}
+test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
+ expect( 5 );
+ var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
+ group.find( "input[type=checkbox]" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ) );
+
+ group = $( "<input type='checkbox' id='t7092b'><label for='t7092b'></label>" );
+ group.filter( "input[type=checkbox]" ).button();
+ ok( group.filter( "label" ).is( ".ui-button" ) );
+
+ group = $( "<span><input type='checkbox' id='t7092c'></span><label for='t7092c'></label>" );
+ group.find( "input[type=checkbox]" ).button();
+ ok( group.filter( "label" ).is( ".ui-button" ) );
+
+ group = $( "<span><input type='checkbox' id='t7092d'></span><span><label for='t7092d'></label></span>" );
+ group.find( "input[type=checkbox]" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ) );
+
+ group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
+ group.filter( "input[type=checkbox]" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ) );
+});
+
+test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
+ expect( 2 );
+ $( "#radio01" ).next().andSelf().hide();
+ var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
+ ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
+ ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
+});
+
+test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
+ expect( 3 );
+ $( "#radio0" ).hide();
+ var set = $( "#radio0" ).buttonset();
+ ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
+ ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
+ ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
+});
+
+test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
+ expect( 2 );
+ var check = $( "#check" ).button(),
+ label = $( "label[for='check']" );
+ ok( !label.is( ".ui-state-focus" ) );
+ check.focus();
+ ok( label.is( ".ui-state-focus" ) );
+});
+
+test( "#7534 - Button label selector works for ids with \":\"", function() {
+ expect( 1 );
+ var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
+ group.find( "input" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
+});
+
})(jQuery);
diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js
index eeb6e5527..e1931a54e 100644
--- a/tests/unit/button/button_options.js
+++ b/tests/unit/button/button_options.js
@@ -103,4 +103,15 @@ test("icons", function() {
$("#button").button("destroy");
});
+test( "#5295 - button does not remove hoverstate if disabled" , function() {
+ expect( 1 );
+ var btn = $("#button").button();
+ btn.hover( function() {
+ btn.button( "disable" );
+ });
+ btn.trigger( "mouseenter" );
+ btn.trigger( "mouseleave" );
+ ok( !btn.is( ".ui-state-hover") );
+});
+
})(jQuery);
diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js
deleted file mode 100644
index 1272d368f..000000000
--- a/tests/unit/button/button_tickets.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * button_tickets.js
- */
-(function( $ ) {
-
-module( "button: tickets" );
-
-test( "#5295 - button does not remove hoverstate if disabled" , function() {
- expect( 1 );
- var btn = $("#button").button();
- btn.hover( function() {
- btn.button( "disable" );
- });
- btn.trigger( "mouseenter" );
- btn.trigger( "mouseleave" );
- ok( !btn.is( ".ui-state-hover") );
-});
-
-test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
- expect( 2 );
- $( "#radio01" ).next().andSelf().hide();
- var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
- ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
- ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
-});
-
-test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
- expect( 3 );
- $( "#radio0" ).hide();
- var set = $( "#radio0" ).buttonset();
- ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
- ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
- ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
-});
-
-test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
- expect( 2 );
- var check = $( "#check" ).button(),
- label = $( "label[for='check']" );
- ok( !label.is( ".ui-state-focus" ) );
- check.focus();
- ok( label.is( ".ui-state-focus" ) );
-});
-
-test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
- expect( 5 );
- var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
- group.find( "input[type=checkbox]" ).button();
- ok( group.find( "label" ).is( ".ui-button" ) );
-
- group = $( "<input type='checkbox' id='t7092b'><label for='t7092b'></label>" );
- group.filter( "input[type=checkbox]" ).button();
- ok( group.filter( "label" ).is( ".ui-button" ) );
-
- group = $( "<span><input type='checkbox' id='t7092c'></span><label for='t7092c'></label>" );
- group.find( "input[type=checkbox]" ).button();
- ok( group.filter( "label" ).is( ".ui-button" ) );
-
- group = $( "<span><input type='checkbox' id='t7092d'></span><span><label for='t7092d'></label></span>" );
- group.find( "input[type=checkbox]" ).button();
- ok( group.find( "label" ).is( ".ui-button" ) );
-
- group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
- group.filter( "input[type=checkbox]" ).button();
- ok( group.find( "label" ).is( ".ui-button" ) );
-});
-
-test( "#7534 - Button label selector works for ids with \":\"", function() {
- expect( 1 );
- var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
- group.find( "input" ).button();
- ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
-});
-
-})( jQuery );
diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js
index 9c0e80825..700208dfc 100644
--- a/tests/unit/dialog/dialog_core.js
+++ b/tests/unit/dialog/dialog_core.js
@@ -80,8 +80,7 @@ test( "focus tabbable", function() {
}, 13);
});
-// #7960
-test( "resizable handles below modal overlays", function() {
+test( "#7960: resizable handles below modal overlays", function() {
expect( 1 );
var resizable = $( "<div>" ).resizable(),
@@ -93,4 +92,33 @@ test( "resizable handles below modal overlays", function() {
dialog.dialog( "destroy" );
});
+asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
+ expect( 3 );
+
+ var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
+ inputs = el.find( "input" ),
+ widget = el.dialog( "widget" )[ 0 ];
+
+ function checkTab() {
+ ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
+
+ // check shift tab
+ $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
+ setTimeout( checkShiftTab, 2 );
+ }
+
+ function checkShiftTab() {
+ ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
+
+ el.remove();
+ start();
+ }
+
+ inputs.eq( 1 ).focus();
+ equal( document.activeElement, inputs[1], "Focus set on second input" );
+ inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
+
+ setTimeout( checkTab, 2 );
+});
+
})(jQuery);
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js
index cbeced0f8..19337ad5d 100644
--- a/tests/unit/dialog/dialog_events.js
+++ b/tests/unit/dialog/dialog_events.js
@@ -341,4 +341,18 @@ asyncTest("ensure dialog's container doesn't scroll on resize and focus", functi
}, 500);
});
+test("#5184: isOpen in dialogclose event is true", function() {
+ expect( 3 );
+
+ var el = $( "<div></div>" ).dialog({
+ close: function() {
+ ok( !el.dialog("isOpen"), "dialog is not open during close" );
+ }
+ });
+ ok( el.dialog("isOpen"), "dialog is open after init" );
+ el.dialog( "close" );
+ ok( !el.dialog("isOpen"), "dialog is not open after close" );
+ el.remove();
+});
+
})(jQuery);
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js
index 92fe3d60f..fbb649fbf 100644
--- a/tests/unit/dialog/dialog_methods.js
+++ b/tests/unit/dialog/dialog_methods.js
@@ -137,4 +137,52 @@ test("open", function() {
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called');
});
+// TODO merge this with the main destroy test
+test("#4980: Destroy should place element back in original DOM position", function(){
+ expect( 2 );
+ var container = $('<div id="container"><div id="modal">Content</div></div>'),
+ modal = container.find('#modal');
+ modal.dialog();
+ ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
+ modal.dialog('destroy');
+ ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position');
+});
+
+test("#6137: dialog('open') causes form elements to reset on IE7", function() {
+ expect(2);
+
+ var d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
+ '<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
+
+ d1.find('#b').prop( "checked", true );
+ equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
+
+ d1.dialog('open');
+ equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
+
+ d1.remove();
+});
+
+test("#5531: dialog width should be at least minWidth on creation", function () {
+ expect( 4 );
+ var el = $('<div></div>').dialog({
+ width: 200,
+ minWidth: 300
+ });
+
+ equal(el.dialog('option', 'width'), 300, "width is minWidth");
+ el.dialog('option', 'width', 200);
+ equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
+ el.dialog('option', 'width', 320);
+ equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
+ el.remove();
+
+ el = $('<div></div>').dialog({
+ minWidth: 300
+ });
+ ok(el.dialog('option', 'width') >= 300, "width is at least 300");
+ el.remove();
+
+});
+
})(jQuery);
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js
index 19e69b29a..2ccbed573 100644
--- a/tests/unit/dialog/dialog_options.js
+++ b/tests/unit/dialog/dialog_options.js
@@ -478,4 +478,26 @@ test("width", function() {
el.remove();
});
+test("#4826: setting resizable false toggles resizable on dialog", function() {
+ expect(6);
+ var i,
+ el = $('<div></div>').dialog({ resizable: false });
+
+ TestHelpers.dialog.shouldResize(el, 0, 0, "[default]");
+ for (i=0; i<2; i++) {
+ el.dialog('close').dialog('open');
+ TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')');
+ }
+ el.remove();
+
+ el = $('<div></div>').dialog({ resizable: true });
+ TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
+ for (i=0; i<2; i++) {
+ el.dialog('close').dialog('option', 'resizable', false).dialog('open');
+ TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')');
+ }
+ el.remove();
+
+});
+
})(jQuery);
diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js
deleted file mode 100644
index 389a243b3..000000000
--- a/tests/unit/dialog/dialog_tickets.js
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * dialog_tickets.js
- */
-(function($) {
-
-module( "dialog: tickets" );
-
-asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
- expect( 3 );
-
- var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
- inputs = el.find( "input" ),
- widget = el.dialog( "widget" )[ 0 ];
-
- function checkTab() {
- ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
-
- // check shift tab
- $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
- setTimeout( checkShiftTab, 2 );
- }
-
- function checkShiftTab() {
- ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
-
- el.remove();
- start();
- }
-
- inputs.eq( 1 ).focus();
- equal( document.activeElement, inputs[1], "Focus set on second input" );
- inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
-
- setTimeout( checkTab, 2 );
-});
-
-test("#4826: setting resizable false toggles resizable on dialog", function() {
- expect(6);
- var i,
- el = $('<div></div>').dialog({ resizable: false });
-
- TestHelpers.dialog.shouldResize(el, 0, 0, "[default]");
- for (i=0; i<2; i++) {
- el.dialog('close').dialog('open');
- TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')');
- }
- el.remove();
-
- el = $('<div></div>').dialog({ resizable: true });
- TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
- for (i=0; i<2; i++) {
- el.dialog('close').dialog('option', 'resizable', false).dialog('open');
- TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')');
- }
- el.remove();
-
-});
-
-test("#5184: isOpen in dialogclose event is true", function() {
- expect( 3 );
-
- var el = $( "<div></div>" ).dialog({
- close: function() {
- ok( !el.dialog("isOpen"), "dialog is not open during close" );
- }
- });
- ok( el.dialog("isOpen"), "dialog is open after init" );
- el.dialog( "close" );
- ok( !el.dialog("isOpen"), "dialog is not open after close" );
- el.remove();
-});
-
-test("#5531: dialog width should be at least minWidth on creation", function () {
- expect( 4 );
- var el = $('<div></div>').dialog({
- width: 200,
- minWidth: 300
- });
-
- equal(el.dialog('option', 'width'), 300, "width is minWidth");
- el.dialog('option', 'width', 200);
- equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
- el.dialog('option', 'width', 320);
- equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
- el.remove();
-
- el = $('<div></div>').dialog({
- minWidth: 300
- });
- ok(el.dialog('option', 'width') >= 300, "width is at least 300");
- el.remove();
-
-});
-
-test("#6137: dialog('open') causes form elements to reset on IE7", function() {
- expect(2);
-
- var d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
- '<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
-
- d1.find('#b').prop( "checked", true );
- equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
-
- d1.dialog('open');
- equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
-
- d1.remove();
-});
-
-// TODO merge this with the main destroy test
-test("#4980: Destroy should place element back in original DOM position", function(){
- expect( 2 );
- var container = $('<div id="container"><div id="modal">Content</div></div>'),
- modal = container.find('#modal');
- modal.dialog();
- ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
- modal.dialog('destroy');
- ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position');
-});
-
-})(jQuery);
diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js
index 556f539e1..4245d64fa 100644
--- a/tests/unit/sortable/sortable_events.js
+++ b/tests/unit/sortable/sortable_events.js
@@ -128,6 +128,67 @@ test("update", function() {
});
+test("#3019: Stop fires too early", function() {
+ expect(2);
+
+ var helper = null,
+ el = $("#sortable").sortable({
+ stop: function(event, ui) {
+ helper = ui.helper;
+ }
+ });
+
+ TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable');
+ equal(helper, null, "helper should be false");
+
+});
+
+test('#4752: link event firing on sortable with connect list', function () {
+ expect( 10 );
+
+ var fired = {},
+ hasFired = function (type) { return (type in fired) && (true === fired[type]); };
+
+ $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable');
+
+ $('#qunit-fixture ul').sortable({
+ connectWith: '#qunit-fixture ul',
+ change: function () {
+ fired.change = true;
+ },
+ receive: function () {
+ fired.receive = true;
+ },
+ remove: function () {
+ fired.remove = true;
+ }
+ });
+
+ $('#qunit-fixture ul').bind('click.ui-sortable-test', function () {
+ fired.click = true;
+ });
+
+ $('#sortable li:eq(0)').simulate('click');
+ ok(!hasFired('change'), 'Click only, change event should not have fired');
+ ok(hasFired('click'), 'Click event should have fired');
+
+ // Drag an item within the first list
+ fired = {};
+ $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 });
+ ok(hasFired('change'), '40px drag, change event should have fired');
+ ok(!hasFired('receive'), 'Receive event should not have fired');
+ ok(!hasFired('remove'), 'Remove event should not have fired');
+ ok(!hasFired('click'), 'Click event should not have fired');
+
+ // Drag an item from the first list to the second, connected list
+ fired = {};
+ $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 });
+ ok(hasFired('change'), '150px drag, change event should have fired');
+ ok(hasFired('receive'), 'Receive event should have fired');
+ ok(hasFired('remove'), 'Remove event should have fired');
+ ok(!hasFired('click'), 'Click event should not have fired');
+});
+
/*
test("receive", function() {
ok(false, "missing test - untested code is broken code.");
diff --git a/tests/unit/sortable/sortable_tickets.js b/tests/unit/sortable/sortable_tickets.js
deleted file mode 100644
index eebd8dc21..000000000
--- a/tests/unit/sortable/sortable_tickets.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * sortable_tickets.js
- */
-(function($) {
-
-module("sortable: tickets");
-
-test("#3019: Stop fires too early", function() {
- expect(2);
-
- var helper = null,
- el = $("#sortable").sortable({
- stop: function(event, ui) {
- helper = ui.helper;
- }
- });
-
- TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable');
- equal(helper, null, "helper should be false");
-
-});
-
-test('#4752: link event firing on sortable with connect list', function () {
- expect( 10 );
-
- var fired = {},
- hasFired = function (type) { return (type in fired) && (true === fired[type]); };
-
- $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable');
-
- $('#qunit-fixture ul').sortable({
- connectWith: '#qunit-fixture ul',
- change: function () {
- fired.change = true;
- },
- receive: function () {
- fired.receive = true;
- },
- remove: function () {
- fired.remove = true;
- }
- });
-
- $('#qunit-fixture ul').bind('click.ui-sortable-test', function () {
- fired.click = true;
- });
-
- $('#sortable li:eq(0)').simulate('click');
- ok(!hasFired('change'), 'Click only, change event should not have fired');
- ok(hasFired('click'), 'Click event should have fired');
-
- // Drag an item within the first list
- fired = {};
- $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 });
- ok(hasFired('change'), '40px drag, change event should have fired');
- ok(!hasFired('receive'), 'Receive event should not have fired');
- ok(!hasFired('remove'), 'Remove event should not have fired');
- ok(!hasFired('click'), 'Click event should not have fired');
-
- // Drag an item from the first list to the second, connected list
- fired = {};
- $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 });
- ok(hasFired('change'), '150px drag, change event should have fired');
- ok(hasFired('receive'), 'Receive event should have fired');
- ok(hasFired('remove'), 'Remove event should have fired');
- ok(!hasFired('click'), 'Click event should not have fired');
-});
-
-})(jQuery);