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",
|
2015-01-08 02:51:38 +00:00
|
|
|
"ui/safe-active-element",
|
2015-07-15 01:57:20 +00:00
|
|
|
"ui/widgets/button"
|
2016-04-03 14:43:27 +00:00
|
|
|
], function( QUnit, $ ) {
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2016-04-03 14:43:27 +00:00
|
|
|
QUnit.module( "Button: core" );
|
2010-01-20 14:00:14 +00:00
|
|
|
|
2016-04-03 14:43:27 +00:00
|
|
|
QUnit.test( "Disabled button loses focus", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 2 );
|
2014-01-22 17:02:32 +00:00
|
|
|
var element = $( "#button" ).button();
|
2013-04-07 16:57:15 +00:00
|
|
|
|
2014-01-22 17:02:32 +00:00
|
|
|
element.focus();
|
2015-08-21 04:12:35 +00:00
|
|
|
setTimeout( function() {
|
2013-04-07 16:57:15 +00:00
|
|
|
|
2016-04-03 14:43:27 +00:00
|
|
|
assert.equal( element[ 0 ], $.ui.safeActiveElement( document ), "Button is focused" );
|
2012-12-08 01:06:29 +00:00
|
|
|
|
2013-04-11 18:03:51 +00:00
|
|
|
element.button( "disable" );
|
2016-04-03 14:43:27 +00:00
|
|
|
assert.notEqual( element[ 0 ], $.ui.safeActiveElement( document ), "Button has had focus removed" );
|
|
|
|
ready();
|
2015-08-21 04:12:35 +00:00
|
|
|
} );
|
|
|
|
} );
|
2013-04-11 18:03:51 +00:00
|
|
|
|
2015-04-06 14:13:15 +00:00
|
|
|
} );
|