module( "Checkboxradio: core" );
test( "Checkbox - Initial class structure", function( assert ) {
expect( 2 );
- var input = $("#check"),
- label = $("label[for=check]");
+ var input = $( "#check" ),
+ label = $( "label[for=check]" );
input.checkboxradio();
assert.hasClasses( input, "ui-helper-hidden-accessible ui-checkboxradio" );
assert.hasClasses( label, "ui-button ui-widget ui-checkboxradio-label ui-corner-all" );
-});
+} );
test( "Radios - Initial class structure", function( assert ) {
expect( 6 );
inputs.checkboxradio();
inputs.each( function() {
assert.hasClasses( this, "ui-helper-hidden-accessible" );
- });
+ } );
labels.each( function() {
assert.hasClasses( this, "ui-button" );
- });
-});
+ } );
+} );
asyncTest( "Ensure checked after single click on checkbox label button", function( assert ) {
expect( 2 );
ok( this.checked, "checked ok" );
assert.hasClasses( label, "ui-state-active" );
- });
+ } );
// Support: Opera
// Opera doesn't trigger a change event when this is done synchronously.
// This seems to be a side effect of another test, but until that can be
// tracked down, this delay will have to do.
- setTimeout(function() {
+ setTimeout( function() {
$( "#check2" ).checkboxradio( "widget" ).simulate( "click" );
start();
- });
-});
+ } );
+} );
test( "Checkbox creation requires a label, and finds it in all cases", function( assert ) {
expect( 7 );
group.find( "input[type=checkbox]" ).checkboxradio();
assert.hasClasses( group.find( "label" ), "ui-button" );
} );
-});
+} );
test( "Calling checkboxradio on an unsupported element throws an error", function( assert ) {
expect( 2 );
error,
"Proper error thrown"
);
-});
+} );
test( "Calling checkboxradio on an input with no label throws an error", function( assert ) {
expect( 1 );
var error = new Error( "No label found for checkboxradio widget" );
error,
"Proper error thrown"
);
-});
+} );
} );
assert.lacksClasses( icon, "ui-icon-check" );
}
assert.lacksClasses( widget, "ui-checkboxradio-checked" );
- });
+ } );
- test( value + ": destroy", function( assert ){
+ test( value + ": destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#" + value + "-method-destroy", function() {
$( "#" + value + "-method-destroy" ).checkboxradio().checkboxradio( "destroy" );
- });
- });
+ } );
+ } );
test( value + ": disable / enable", function( assert ) {
expect( 4 );
assert.lacksClasses( widget, "ui-state-disabled" );
strictEqual( input.is( ":disabled" ), false,
value + " has disabled prop removed when enable is called" );
- });
+ } );
- test( value + ": widget returns the label", function(){
+ test( value + ": widget returns the label", function() {
var input = $( "#" + value + "-method-refresh" ),
label = $( "#" + value + "-method-refresh-label" );
input.checkboxradio();
strictEqual( input.checkboxradio( "widget" )[ 0 ], label[ 0 ],
"widget method returns label" );
- });
+ } );
} );
input.checkboxradio( "refresh" );
strictEqual( input.parent()[ 0 ], element[ 0 ], "Input preserved" );
-});
+} );
} );
test( "disabled", function( assert ) {
var checkbox = $( "#checkbox-option-disabled" );
expect( 6 );
- checkbox.checkboxradio({
+ checkbox.checkboxradio( {
disabled: true
- });
+ } );
assertDisabled( checkbox, assert );
checkbox.checkboxradio( "option", "disabled", true );
assertDisabled( checkbox, assert );
-});
+} );
test( "disabled - prop true on init", function( assert ) {
expect( 2 );
var checkbox = $( "#checkbox-option-disabled" );
checkbox.checkboxradio();
assertDisabled( checkbox, assert );
-});
+} );
test( "disabled - explicit null value, checks the DOM", function( assert ) {
expect( 2 );
var checkbox = $( "#checkbox-option-disabled" );
checkbox.prop( "disabled", true );
- checkbox.checkboxradio({
+ checkbox.checkboxradio( {
disabled: null
- });
+ } );
assertDisabled( checkbox, assert );
-});
+} );
function assertNoIcon( checkbox ) {
strictEqual( checkbox.checkboxradio( "widget" ).find( "span.ui-icon" ).length, 0,
expect( 1 );
- checkbox.checkboxradio({ icon: false });
+ checkbox.checkboxradio( { icon: false } );
assertNoIcon( checkbox );
-});
+} );
test( "icon - default unchecked", function( assert ) {
var checkbox = $( "#checkbox-option-icon" );
checkbox.checkboxradio();
assertIcon( checkbox, false, assert );
-});
-test( "icon", function( assert ){
+} );
+test( "icon", function( assert ) {
var checkbox = $( "#checkbox-option-icon" );
expect( 8 );
checkbox.checkboxradio( "option", "icon", true );
assertIcon( checkbox, false, assert );
-});
+} );
test( "label - default", function() {
var checkbox = $( "#checkbox-option-label" ),
"checkbox label", "When no value passed on create text from dom is used for option" );
strictEqual( widget.text(),
" checkbox label", "When no value passed on create text from dom is used in dom" );
-});
+} );
test( "label - explicit value", function() {
expect( 5 );
- var checkbox = $( "#checkbox-option-label" ).checkboxradio({
+ var checkbox = $( "#checkbox-option-label" ).checkboxradio( {
label: "foo"
- }),
+ } ),
widget = checkbox.checkboxradio( "widget" ),
icon = widget.find( ".ui-icon" ),
iconSpace = widget.find( ".ui-checkboxradio-icon-space" );
"Icon space is preserved when label is set on init when wrapped in label" );
strictEqual( $( "#checkbox-option-label" ).length, 1,
"Element is preserved when label is set on init when wrapped in label" );
-});
+} );
test( "label - explicit null value", function() {
var checkbox = $( "#checkbox-option-label" ),
// We are testing the default here because the default null is a special value which means to check
// the DOM, so we need to make sure this happens correctly checking the options should never return
// null. It should always be true or false
- checkbox.checkboxradio({
+ checkbox.checkboxradio( {
label: null
- });
+ } );
widget = checkbox.checkboxradio( "widget" );
strictEqual( checkbox.checkboxradio( "option", "label" ),
"checkbox label", "When null is passed on create text from dom is used for option" );
strictEqual( widget.text(),
" checkbox label", "When null is passed on create text from dom is used in dom" );
-});
+} );
test( "label", function() {
var checkbox = $( "#checkbox-option-label" ),
strictEqual( widget.text(),
" bar", "When null is passed text from dom is used in dom" );
-});
+} );
} );