Skip to content
Permalink
Browse files

Autocomplete: Added tests for live region.

  • Loading branch information
scottgonzalez committed May 22, 2012
1 parent 9dcd0e0 commit d7359beee6f8103e997959efd4f070245e9d3225
Showing with 37 additions and 0 deletions.
  1. +37 −0 tests/unit/autocomplete/autocomplete_core.js
@@ -152,4 +152,41 @@ asyncTest( "handle race condition", function() {
}
});

test( "ARIA", function() {
expect( 7 );
var element = $( "#autocomplete" ).autocomplete({
source: [ "java", "javascript" ]
}),
liveRegion = element.data( "ui-autocomplete" ).liveRegion;

equal( liveRegion.text(), "", "Empty live region on create" );

element.autocomplete( "search", "j" );
equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.",
"Live region for multiple values" );

element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.",
"Live region not changed on focus" );

element.one( "autocompletefocus", function( event ) {
event.preventDefault();
});
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( liveRegion.text(), "javascript",
"Live region updated when default focus is prevented" );

element.autocomplete( "search", "javas" );
equal( liveRegion.text(), "1 result is available, use up and down arrow keys to navigate.",
"Live region for one value" );

element.autocomplete( "search", "z" );
equal( liveRegion.text(), "No search results.",
"Live region for no values" );

element.autocomplete( "search", "j" );
equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.",
"Live region for multiple values" );
});

}( jQuery ) );

0 comments on commit d7359be

Please sign in to comment.
You can’t perform that action at this time.