2014-08-23 03:39:35 +00:00
|
|
|
define( [
|
2016-04-03 14:56:10 +00:00
|
|
|
"qunit",
|
2014-08-23 03:39:35 +00:00
|
|
|
"jquery",
|
2015-08-09 04:30:34 +00:00
|
|
|
"ui/widgets/controlgroup",
|
|
|
|
"ui/widgets/checkboxradio",
|
|
|
|
"ui/widgets/selectmenu",
|
|
|
|
"ui/widgets/button"
|
2016-04-03 14:56:10 +00:00
|
|
|
], function( QUnit, $ ) {
|
2014-08-23 03:39:35 +00:00
|
|
|
|
2016-04-03 14:56:10 +00:00
|
|
|
QUnit.module( "Controlgroup: Core" );
|
2014-08-23 03:39:35 +00:00
|
|
|
|
2016-04-03 14:56:10 +00:00
|
|
|
QUnit.test( "selectmenu: open/close corners", function( assert ) {
|
|
|
|
assert.expect( 12 );
|
2014-08-23 03:39:35 +00:00
|
|
|
var element = $( ".controlgroup" ).controlgroup(),
|
|
|
|
selects = element.find( "select" ),
|
|
|
|
selectButton = selects.eq( 0 ).selectmenu( "widget" );
|
|
|
|
|
|
|
|
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" );
|
2015-09-11 14:48:51 +00:00
|
|
|
} );
|
2014-08-23 03:39:35 +00:00
|
|
|
|
2016-04-03 14:56:10 +00:00
|
|
|
QUnit.test( "selectmenu: controlgroupLabel", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2015-10-25 22:07:34 +00:00
|
|
|
var element = $( ".controlgroup" ).controlgroup();
|
|
|
|
var label = element.find( ".ui-controlgroup-label" );
|
|
|
|
|
|
|
|
assert.hasClasses( label, "ui-widget ui-widget-content ui-state-default ui-controlgroup-item" );
|
|
|
|
assert.hasClasses( label.find( "span" ), "ui-controlgroup-label-contents" );
|
|
|
|
} );
|
|
|
|
|
2014-08-23 03:39:35 +00:00
|
|
|
} );
|