Unit tests for dialog theme inheritance

This commit is contained in:
BradBroulik 2011-07-28 16:45:39 -05:00
parent f78970618c
commit d5cf4fc29a
2 changed files with 17 additions and 5 deletions

View file

@ -5,13 +5,20 @@
module('jquery.mobile.dialog.js');
asyncTest( "dialog hash is added when the dialog is opened and removed when closed", function(){
expect( 2 );
expect( 6 );
//bring up the dialog
$("a[href='#foo-dialog']").click();
setTimeout(function(){
ok(/&ui-state=dialog/.test(location.hash), "ui-state=dialog =~ location.hash");
// Assert dialog theme inheritance (issue 1375):
ok($('#foo-dialog').hasClass('ui-body-b'), 'Expected theme ui-body-b');
ok($('#foo-dialog').find( ":jqmData(role=header)" ).hasClass('ui-bar-b'), 'Expected header theme inherited from parent ui-bar-b');
ok($('#foo-dialog').find( ":jqmData(role=content)" ).hasClass('ui-body-b'), 'Expect content inheritance from dialog theme ui-body-b');
ok($('#foo-dialog').find( ":jqmData(role=footer)" ).hasClass('ui-bar-c'), 'Expected footer theme ui-bar-c');
// close the dialog
$(".ui-dialog").dialog("close");
}, 500);

View file

@ -25,15 +25,20 @@
<ol id="qunit-tests">
</ol>
<div id="bar" data-nstest-role="page">
<div id="bar" data-nstest-role="page" data-nstest-theme="a">
<a href="#foo-dialog" data-nstest-role="button" data-nstest-inline="true" data-nstest-rel="dialog"></a>
</div>
<div id="foo-dialog" data-nstest-role="dialog">
<div data-nstest-role="header" data-nstest-theme="d" data-nstest-position="inline">
<div id="foo-dialog" data-nstest-role="dialog" data-nstest-theme="b">
<div data-nstest-role="header" data-nstest-position="inline">
<h1>Dialog</h1>
</div>
<a href="#" id="internal-link">foo</a>
<div data-nstest-role="content">
<a href="#" id="internal-link">foo</a>
</div>
<div data-nstest-role="footer" data-nstest-theme="c">
footer
</div>
</div>
</body>