aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/button/deprecated.html8
-rw-r--r--tests/unit/button/deprecated.js18
-rw-r--r--tests/unit/core/core.js4
-rw-r--r--tests/unit/menu/events.js26
-rw-r--r--tests/unit/menu/menu.html10
-rw-r--r--tests/unit/resizable/options.js10
-rw-r--r--tests/unit/selectmenu/core.js4
-rw-r--r--tests/unit/selectmenu/events.js4
-rw-r--r--tests/unit/widget/extend.js7
9 files changed, 83 insertions, 8 deletions
diff --git a/tests/unit/button/deprecated.html b/tests/unit/button/deprecated.html
index 73f62921c..8b5270baa 100644
--- a/tests/unit/button/deprecated.html
+++ b/tests/unit/button/deprecated.html
@@ -56,6 +56,14 @@
<button id="button1">Button</button>
<a href="#" id="anchor-button">Anchor Button</a>
+<div class="mixed">
+ <a href="#" id="mixed-anchor">Anchor</a>
+ <button id="mixed-button" disabled>Button</button>
+ <input type="button" value="Button" id="mixed-input">
+ <input type="checkbox" id="mixed-check" name="check"><label for="mixed-check">Check</label>
+ <input type="radio" id="mixed-radio" name="radio"><label for="mixed-radio">Radio</label>
+</div>
+
</div>
</body>
</html>
diff --git a/tests/unit/button/deprecated.js b/tests/unit/button/deprecated.js
index 81a0281b7..86fca797e 100644
--- a/tests/unit/button/deprecated.js
+++ b/tests/unit/button/deprecated.js
@@ -194,4 +194,22 @@ QUnit.test( "icon / icons options properly proxied", function( assert ) {
"Icons secondary option sets iconPosition option to end on init" );
} );
+QUnit.test( "Calling button on a collection of mixed types works correctly", function( assert ) {
+ assert.expect( 5 );
+
+ var group = $( ".mixed" ).children();
+
+ group.button();
+
+ $.each( {
+ anchor: "button",
+ button: "button",
+ check: "checkboxradio",
+ input: "button",
+ radio: "checkboxradio"
+ }, function( type, widget ) {
+ assert.ok( $( "#mixed-" + type )[ widget ]( "instance" ), type + " is a " + widget );
+ } );
+} );
+
} );
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js
index 770ea4138..b5b6b3b81 100644
--- a/tests/unit/core/core.js
+++ b/tests/unit/core/core.js
@@ -142,7 +142,7 @@ QUnit.test( "uniqueId / removeUniqueId", function( assert ) {
} );
QUnit.test( "Labels", function( assert ) {
- assert.expect( 2 );
+ assert.expect( 3 );
var expected = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ];
var dom = $( "#labels-fragment" );
@@ -165,6 +165,8 @@ QUnit.test( "Labels", function( assert ) {
// Detach the dom to test on a fragment
dom.detach();
testLabels( "document fragments" );
+
+ assert.equal( $().labels().length, 0, "No element" );
} );
( function() {
diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js
index a8ccb0282..fd57373c1 100644
--- a/tests/unit/menu/events.js
+++ b/tests/unit/menu/events.js
@@ -670,7 +670,9 @@ QUnit.test( "handle keyboard navigation and mouse click on menu with dividers an
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- assert.equal( logOutput(), "keydown,3,4,7", "Keydown focus skips divider and group label" );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ assert.equal( logOutput(), "keydown,1,2,3,4,7", "Keydown focus skips divider and group label" );
ready();
}
} );
@@ -755,4 +757,26 @@ QUnit.test( "#10571: When typing in a menu, only menu-items should be focused",
} );
} );
+QUnit.test( "#15157: Must not focus menu dividers with the keyboard", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 6 );
+
+ var element = $( "#menu-with-dividers" ).menu( {
+ focus: function( event, ui ) {
+ assert.hasClasses( ui.item, "ui-menu-item", "Should have menu item class" );
+ log( ui.item.text() );
+ }
+ } );
+
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
+ setTimeout( function() {
+ assert.equal( logOutput(), "beginning,middle,end,beginning,end", "Should wrap around items" );
+ ready();
+ } );
+} );
+
} );
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index 2d871a4b3..8d70b19df 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -323,6 +323,16 @@
<li class="foo"><div>Addyston</div></li>
<li class="foo"><div>Adelphi</div></li>
</ul>
+
+<ul id="menu-with-dividers">
+ <li>-</li>
+ <li>beginning</li>
+ <li>-</li>
+ <li>middle</li>
+ <li>-</li>
+ <li>end</li>
+ <li>-</li>
+</ul>
</div>
</body>
</html>
diff --git a/tests/unit/resizable/options.js b/tests/unit/resizable/options.js
index 4080bac0e..81206abf8 100644
--- a/tests/unit/resizable/options.js
+++ b/tests/unit/resizable/options.js
@@ -434,8 +434,10 @@ QUnit.test( "zIndex, applied to all handles", function( assert ) {
} );
QUnit.test( "setOption handles", function( assert ) {
- assert.expect( 15 );
+ assert.expect( 19 );
+ // https://bugs.jqueryui.com/ticket/3423
+ // https://bugs.jqueryui.com/ticket/15084
var target = $( "<div></div>" ).resizable(),
target2 = $( "<div>" +
"<div class='ui-resizable-handle ui-resizable-e'></div>" +
@@ -470,6 +472,12 @@ QUnit.test( "setOption handles", function( assert ) {
target2.resizable( "option", "handles", "e, s, w" );
checkHandles( target2, [ "e", "s", "w" ] );
+
+ target.resizable( "destroy" );
+ checkHandles( target, [ ] );
+
+ target2.resizable( "destroy" );
+ checkHandles( target2, [ "e", "w" ] );
} );
QUnit.test( "alsoResize + containment", function( assert ) {
diff --git a/tests/unit/selectmenu/core.js b/tests/unit/selectmenu/core.js
index cef6dc5bf..708452312 100644
--- a/tests/unit/selectmenu/core.js
+++ b/tests/unit/selectmenu/core.js
@@ -251,13 +251,13 @@ $.each( [
wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.trigger( "click" );
- wrappers.first().simulate( "mouseover" ).trigger( "click" );
+ wrappers.first().simulate( "mouseover", { clientX: 2, clientY: 2 } ).trigger( "click" );
assert.equal( element[ 0 ].selectedIndex, 0, "First item is selected" );
button.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
assert.equal( element[ 0 ].selectedIndex, 0, "No looping beyond first item" );
button.trigger( "click" );
- wrappers.last().simulate( "mouseover" ).trigger( "click" );
+ wrappers.last().simulate( "mouseover", { clientX: 3, clientY: 3 } ).trigger( "click" );
assert.equal( element[ 0 ].selectedIndex, wrappers.length - 1, "Last item is selected" );
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
assert.equal( element[ 0 ].selectedIndex, wrappers.length - 1, "No looping behind last item" );
diff --git a/tests/unit/selectmenu/events.js b/tests/unit/selectmenu/events.js
index 4aed70ac8..ffc0429ee 100644
--- a/tests/unit/selectmenu/events.js
+++ b/tests/unit/selectmenu/events.js
@@ -89,9 +89,9 @@ QUnit.test( "focus", function( assert ) {
button.trigger( "click" );
links = menu.find( "li.ui-menu-item" );
optionIndex = 0;
- links.eq( optionIndex ).simulate( "mouseover" );
+ links.eq( optionIndex ).simulate( "mouseover", { clientX: 2, clientY: 2 } );
optionIndex += 1;
- links.eq( optionIndex ).simulate( "mouseover" );
+ links.eq( optionIndex ).simulate( "mouseover", { clientX: 3, clientY: 3 } );
// This tests for unwanted, additional focus event on close
that.element.selectmenu( "close" );
diff --git a/tests/unit/widget/extend.js b/tests/unit/widget/extend.js
index 36575200b..b27d925f0 100644
--- a/tests/unit/widget/extend.js
+++ b/tests/unit/widget/extend.js
@@ -5,7 +5,7 @@ define( [
], function( QUnit, $ ) {
QUnit.test( "$.widget.extend()", function( assert ) {
- assert.expect( 27 );
+ assert.expect( 28 );
var ret, empty, optionsWithLength, optionsWithDate, myKlass, customObject, optionsWithCustomObject, nullUndef,
target, recursive, obj, input, output,
@@ -108,6 +108,11 @@ QUnit.test( "$.widget.extend()", function( assert ) {
assert.deepEqual( input, output, "don't clone arrays" );
input.key[ 0 ] = 10;
assert.deepEqual( input, output, "don't clone arrays" );
+
+ input = Object.create( null );
+ input.foo = "f";
+ output = $.widget.extend( {}, input );
+ assert.deepEqual( input, output, "Object with no prototype" );
} );
} );