2015-04-06 14:13:15 +00:00
|
|
|
define( [
|
2016-04-03 14:43:27 +00:00
|
|
|
"qunit",
|
2015-04-06 14:13:15 +00:00
|
|
|
"jquery",
|
2020-05-16 07:16:24 +00:00
|
|
|
"lib/helper",
|
2015-07-15 01:57:20 +00:00
|
|
|
"ui/widgets/button"
|
2020-05-16 07:16:24 +00:00
|
|
|
], function( QUnit, $, helper ) {
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2020-05-16 07:16:24 +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 );
|
2015-04-06 14:13:15 +00:00
|
|
|
assert.domEqual( "#button", function() {
|
2012-06-16 12:24:29 +00:00
|
|
|
$( "#button" ).button().button( "destroy" );
|
2015-08-21 04:12:35 +00:00
|
|
|
} );
|
|
|
|
} );
|
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
|
|
|
|
2012-11-19 20:42:28 +00:00
|
|
|
var element = $( "<a href='#'></a>" );
|
2015-08-21 04:12:35 +00:00
|
|
|
element.button( { disabled: true } ).button( "refresh" );
|
2016-04-03 14:43:27 +00:00
|
|
|
assert.ok( element.button( "option", "disabled" ),
|
2014-01-22 17:02:32 +00:00
|
|
|
"Anchor button should remain disabled after refresh" );
|
2012-11-19 20:42:28 +00:00
|
|
|
|
|
|
|
element = $( "<button></button>" );
|
2015-08-21 04:12:35 +00:00
|
|
|
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" );
|
2012-11-19 20:42:28 +00:00
|
|
|
|
|
|
|
element = $( "<button></button>" );
|
2015-08-21 04:12:35 +00:00
|
|
|
element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
|
2016-04-03 14:43:27 +00:00
|
|
|
assert.ok( !element.button( "option", "disabled" ),
|
2014-01-22 17:02:32 +00:00
|
|
|
"Changing a <button>'s disabled property should update the state after refresh." );
|
2014-04-01 18:42:38 +00:00
|
|
|
|
2015-08-21 04:12:35 +00:00
|
|
|
} );
|
2014-04-01 18:42:38 +00:00
|
|
|
|
2015-04-06 14:13:15 +00:00
|
|
|
} );
|