Skip to content
Permalink
Browse files

Dialog: Add missing unit test for aria-describedby attribute

  • Loading branch information...
jzaefferer committed Nov 17, 2012
1 parent 32a8931 commit 5aac8f563f3ff7227fe9790c2ac8620223e3bd45
Showing with 11 additions and 17 deletions.
  1. +11 −17 tests/unit/dialog/dialog_core.js
@@ -17,24 +17,18 @@ test("title id", function() {
el.remove();
});

// TODO test for aria-describedby
// add only when the attribute isn't anywhere yet
test("ARIA", function() {
expect(4);

var labelledBy,
el = $('<div></div>').dialog();

equal(el.dialog('widget').attr('role'), 'dialog', 'dialog role');

labelledBy = el.dialog('widget').attr('aria-labelledby');
ok(labelledBy.length > 0, 'has aria-labelledby attribute');
equal(el.dialog('widget').find('.ui-dialog-title').attr('id'), labelledBy,
'proper aria-labelledby attribute');

equal(el.dialog('widget').find('.ui-dialog-titlebar-close').attr('role'), 'button',
'close link role');
test( "ARIA", function() {
expect( 4 );

var el = $( "<div></div>" ).dialog(),
wrapper = el.dialog( "widget" );
equal( wrapper.attr( "role" ), "dialog", "dialog role" );
equal( wrapper.attr( "aria-labelledby" ), wrapper.find( ".ui-dialog-title" ).attr( "id" ) );
equal( wrapper.attr( "aria-describedby" ), el.attr( "id" ), "aria-describedby added" );
el.remove();

el = $( '<div><div aria-describedby="section2"><p id="section2">descriotion</p></div></div>' ).dialog();
strictEqual( el.dialog( "widget" ).attr( "aria-describedby" ), undefined, "no aria-describedby added, as already present in markup" );
el.remove();
});

0 comments on commit 5aac8f5

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