jquery-ui/tests/unit/button/methods.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

define( [
2016-04-03 14:43:27 +00:00
"qunit",
"jquery",
"lib/helper",
"ui/widgets/button"
], function( QUnit, $, helper ) {
2010-01-20 14:00:14 +00:00
QUnit.module( "Button: methods", { afterEach: helper.moduleAfterEach } );
2010-01-20 14:00:14 +00:00
2016-04-03 14:43:27 +00:00
QUnit.test( "destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( "#button", function() {
$( "#button" ).button().button( "destroy" );
} );
} );
2010-01-20 14:00:14 +00:00
2016-04-03 14:43:27 +00:00
QUnit.test( "refresh: Ensure disabled state is preserved correctly.", function( assert ) {
assert.expect( 3 );
2013-03-26 18:43:35 +00:00
var element = $( "<a href='#'></a>" );
element.button( { disabled: true } ).button( "refresh" );
2016-04-03 14:43:27 +00:00
assert.ok( element.button( "option", "disabled" ),
"Anchor button should remain disabled after refresh" );
element = $( "<button></button>" );
element.button( { disabled: true } ).button( "refresh" );
2016-04-03 14:43:27 +00:00
assert.ok( element.button( "option", "disabled" ), "<button> should remain disabled after refresh" );
element = $( "<button></button>" );
element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
2016-04-03 14:43:27 +00:00
assert.ok( !element.button( "option", "disabled" ),
"Changing a <button>'s disabled property should update the state after refresh." );
} );
} );