jquery-ui/tests/unit/controlgroup/core.js
2015-10-08 14:02:57 -04:00

70 lines
2.3 KiB
JavaScript

define( [
"jquery",
"ui/widgets/controlgroup",
"ui/widgets/checkboxradio",
"ui/widgets/selectmenu",
"ui/widgets/button"
], function( $ ) {
module( "Controlgroup: Core" );
test( "selectmenu: open/close corners", function( assert ) {
expect( 1 );
var element = $( ".controlgroup" ).controlgroup(),
selects = element.find( "select" ),
selectButton = selects.eq( 0 ).selectmenu( "widget" );
expect( 12 );
selects.eq( 0 ).selectmenu( "open" );
assert.hasClasses( selectButton, "ui-corner-tl",
"Horizontal: First selectmenu gets ui-corner-tl when opened" );
selects.eq( 0 ).selectmenu( "close" );
assert.hasClasses( selectButton, "ui-corner-left",
"Horizontal: First selectmenu gets ui-corner-left when closed" );
selectButton = selects.eq( 1 ).selectmenu( "widget" );
selects.eq( 1 ).selectmenu( "open" );
assert.lacksClassStart( selectButton, "ui-corner" );
selects.eq( 1 ).selectmenu( "close" );
assert.lacksClassStart( selectButton, "ui-corner" );
selectButton = selects.eq( 2 ).selectmenu( "widget" );
selects.eq( 2 ).selectmenu( "open" );
assert.hasClasses( selectButton, "ui-corner-tr",
"Horizontal: Last selectmenu gets ui-corner-tr when opened" );
selects.eq( 2 ).selectmenu( "close" );
assert.hasClasses( selectButton, "ui-corner-right",
"Horizontal: Last selectmenu gets ui-corner-right when closed" );
element.controlgroup( "option", "direction", "vertical" );
selectButton = selects.eq( 0 ).selectmenu( "widget" );
selects.eq( 0 ).selectmenu( "open" );
assert.hasClasses( selectButton, "ui-corner-top",
"vertical: First selectmenu gets ui-corner-top when opened" );
selects.eq( 0 ).selectmenu( "close" );
assert.hasClasses( selectButton, "ui-corner-top",
"vertical: First selectmenu gets ui-corner-top when closed" );
selectButton = selects.eq( 1 ).selectmenu( "widget" );
selects.eq( 1 ).selectmenu( "open" );
assert.lacksClassStart( selectButton, "ui-corner" );
selects.eq( 1 ).selectmenu( "close" );
assert.lacksClassStart( selectButton, "ui-corner" );
selectButton = selects.eq( 2 ).selectmenu( "widget" );
selects.eq( 2 ).selectmenu( "open" );
assert.lacksClassStart( selectButton, "ui-corner" );
selects.eq( 2 ).selectmenu( "close" );
assert.hasClasses( selectButton, "ui-corner-bottom",
"vertical: Last selectmenu gets ui-corner-bottom when closed" );
} );
} );