Skip to content

Commit

Permalink
Add new tests for dialog title heading levels
Browse files Browse the repository at this point in the history
  • Loading branch information
rpkoller committed Aug 5, 2024
1 parent 140fa73 commit f46ff12
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions tests/unit/dialog/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,38 @@ QUnit.test( "aria-modal", function( assert ) {
element.remove();
} );

QUnit.test( "ui dialog title tagname", function( assert ) {
assert.expect( 1 );
QUnit.test( "ui dialog title heading level", function( assert ) {
assert.expect( 7 );

var element, nodeName;

element = $( "<div>" ).dialog( { modal: true, uiDialogTitleTagName: "<h2>" } );
element = $( "<div>" ).dialog( { modal: true } );
nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
assert.equal( nodeName, "span", "The dialog title element is span" );

element = $( "<div>" ).dialog( { modal: true, uiDialogTitleTagName: 0 } );
nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
assert.equal( nodeName, "span", "The dialog title element is span" );

element = $( "<div>" ).dialog( { modal: true, uiDialogTitleTagName: 1 } );
nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
assert.equal( nodeName, "h1", "The dialog title element is h1" );

element = $( "<div>" ).dialog( { modal: true, uiDialogTitleTagName: 6 } );
nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
assert.equal( nodeName, "h6", "The dialog title element is h6" );

element = $( "<div>" ).dialog( { modal: true, uiDialogTitleTagName: 9 } );
nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
assert.equal( nodeName, "span", "The dialog title element is span" );

element = $( "<div>" ).dialog( { modal: true, uiDialogTitleTagName: -9 } );
nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
assert.equal( nodeName, "span", "The dialog title element is span" );

element = $( "<div>" ).dialog( { modal: true, uiDialogTitleTagName: 2.3 } );
nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
assert.equal( nodeName, "h2", "The dialog title element is h2" );
assert.equal( nodeName, "span", "The dialog title element is span" );
} );

QUnit.test( "widget method", function( assert ) {
Expand Down

0 comments on commit f46ff12

Please sign in to comment.