mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Selectmenu Tests: use asyncTest when working with focus events
This commit is contained in:
parent
5e06985fb4
commit
adcfa63ac4
@ -2,7 +2,7 @@
|
||||
|
||||
module( "selectmenu: core" );
|
||||
|
||||
test("accessibility", function () {
|
||||
asyncTest("accessibility", function () {
|
||||
var links,
|
||||
element = $( "#speed" ).selectmenu(),
|
||||
button = element.selectmenu( "widget" ),
|
||||
@ -13,6 +13,7 @@ test("accessibility", function () {
|
||||
|
||||
expect(12 + links.length * 2);
|
||||
|
||||
setTimeout(function() {
|
||||
equal( button.attr( "role" ), "combobox", "button link role" );
|
||||
equal( button.attr( "aria-haspopup" ), "true", "button link aria-haspopup" );
|
||||
equal( button.attr( "aria-expanded" ), "false", "button link aria-expanded" );
|
||||
@ -38,6 +39,8 @@ test("accessibility", function () {
|
||||
equal( $( this ).attr( "role" ), "option", "menu link #" + index +" role" );
|
||||
equal( $( this ).attr( "tabindex" ), -1, "menu link #" + index +" tabindex" );
|
||||
});
|
||||
start();
|
||||
}, 1 );
|
||||
});
|
||||
|
||||
|
||||
@ -51,7 +54,7 @@ $.each([
|
||||
selector: "#files"
|
||||
}
|
||||
], function( i, settings ) {
|
||||
test( "state synchronization - after keydown on button - " + settings.type, function () {
|
||||
asyncTest( "state synchronization - after keydown on button - " + settings.type, function () {
|
||||
expect( 4 );
|
||||
|
||||
var links,
|
||||
@ -61,6 +64,7 @@ $.each([
|
||||
selected = element.find( "option:selected" );
|
||||
|
||||
button.simulate( "focus" );
|
||||
setTimeout(function() {
|
||||
links = menu.find("li.ui-menu-item a");
|
||||
|
||||
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
@ -80,9 +84,11 @@ $.each([
|
||||
"original select state"
|
||||
);
|
||||
equal( button.text(), selected.next( "option" ).text(), "button text" );
|
||||
start();
|
||||
}, 1 );
|
||||
});
|
||||
|
||||
test("state synchronization - after click on item - " + settings.type, function () {
|
||||
asyncTest("state synchronization - after click on item - " + settings.type, function () {
|
||||
expect(4);
|
||||
|
||||
var links,
|
||||
@ -91,6 +97,7 @@ $.each([
|
||||
menu = element.selectmenu( "menuWidget" );
|
||||
|
||||
button.simulate( "focus" );
|
||||
setTimeout(function() {
|
||||
links = menu.find("li.ui-menu-item a");
|
||||
|
||||
button.simulate( "click" );
|
||||
@ -111,9 +118,11 @@ $.each([
|
||||
"original select state"
|
||||
);
|
||||
equal( button.text(), element.find( "option" ).last().text(), "button text" );
|
||||
start();
|
||||
}, 1 );
|
||||
});
|
||||
|
||||
test( "state synchronization - after focus item and keydown on button - " + settings.type, function () {
|
||||
asyncTest( "state synchronization - after focus item and keydown on button - " + settings.type, function () {
|
||||
expect(4);
|
||||
|
||||
var links,
|
||||
@ -124,6 +133,8 @@ $.each([
|
||||
|
||||
// init menu
|
||||
button.simulate( "focus" );
|
||||
|
||||
setTimeout(function() {
|
||||
links = menu.find( "li.ui-menu-item a" );
|
||||
// open menu and click first item
|
||||
button.simulate( "click" );
|
||||
@ -134,12 +145,16 @@ $.each([
|
||||
// close and use keyboard control on button
|
||||
button.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
||||
button.simulate( "focus" );
|
||||
setTimeout(function() {
|
||||
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
|
||||
equal( menu.attr( "aria-activedescendant" ), links.eq( 1 ).attr( "id" ), "menu aria-activedescendant" );
|
||||
equal( button.attr( "aria-activedescendant" ), links.eq( 1 ).attr( "id" ), "button aria-activedescendant" );
|
||||
equal( element.find( "option:selected" ).val(), options.eq( 1 ).val() , "original select state" );
|
||||
equal( button.text(), options.eq( 1 ).text(), "button text" );
|
||||
start();
|
||||
}, 1 );
|
||||
}, 1 );
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user