aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-05-22 10:09:08 -0400
committerScott González <scott.gonzalez@gmail.com>2012-05-22 10:09:20 -0400
commitd7359beee6f8103e997959efd4f070245e9d3225 (patch)
treeb8a525aec75a1a68898821b3d367ebace1cac35f /tests
parent9dcd0e0eb824a4000692b6ce6d864056339ac498 (diff)
downloadjquery-ui-d7359beee6f8103e997959efd4f070245e9d3225.tar.gz
jquery-ui-d7359beee6f8103e997959efd4f070245e9d3225.zip
Autocomplete: Added tests for live region.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/autocomplete/autocomplete_core.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js
index daeea0972..f0ad36a57 100644
--- a/tests/unit/autocomplete/autocomplete_core.js
+++ b/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 ) );