| 1 | define( [ |
| 2 | "qunit", |
| 3 | "jquery", |
| 4 | "lib/helper", |
| 5 | "ui/widgets/button" |
| 6 | ], function( QUnit, $, helper ) { |
| 7 | "use strict"; |
| 8 | |
| 9 | QUnit.module( "Button: core", { afterEach: helper.moduleAfterEach } ); |
| 10 | |
| 11 | QUnit.test( "Disabled button loses focus", function( assert ) { |
| 12 | var ready = assert.async(); |
| 13 | assert.expect( 2 ); |
| 14 | var element = $( "#button" ).button(); |
| 15 | |
| 16 | element.trigger( "focus" ); |
| 17 | setTimeout( function() { |
| 18 | |
| 19 | assert.equal( element[ 0 ], document.activeElement, "Button is focused" ); |
| 20 | |
| 21 | element.button( "disable" ); |
| 22 | assert.notEqual( element[ 0 ], document.activeElement, "Button has had focus removed" ); |
| 23 | ready(); |
| 24 | } ); |
| 25 | } ); |
| 26 | |
| 27 | } ); |