2 * mobile dialog unit tests
5 module( "jquery.mobile.dialog.js", {
7 $.mobile.page.prototype.options.contentTheme = "d";
11 asyncTest( "dialog hash is added when the dialog is opened and removed when closed", function() {
14 $.testHelper.pageSequence([
16 $.mobile.changePage( $( "#mypage" ) );
21 $( "#foo-dialog-link" ).click();
25 var fooDialog = $( "#foo-dialog" );
27 // make sure the dialog came up
28 ok( /&ui-state=dialog/.test(location.hash), "ui-state=dialog =~ location.hash", "dialog open" );
31 $( ".ui-dialog" ).dialog( "close" );
35 ok( !/&ui-state=dialog/.test(location.hash), "ui-state=dialog !~ location.hash" );
41 asyncTest( "dialog element with no theming", function() {
44 $.testHelper.pageSequence([
46 $.mobile.changePage( $( "#mypage" ) );
51 $( "#link-a" ).click();
55 var dialog = $( "#dialog-a" );
57 // Assert dialog theme inheritance (issue 1375):
58 ok( dialog.hasClass( "ui-body-c" ), "Expected explicit theme ui-body-c" );
59 ok( dialog.find( ":jqmData(role=header)" ).hasClass( "ui-bar-" + $.mobile.page.prototype.options.footerTheme ), "Expected header to inherit from $.mobile.page.prototype.options.headerTheme" );
60 ok( dialog.find( ":jqmData(role=content)" ).hasClass( "ui-body-" + $.mobile.page.prototype.options.contentTheme ), "Expect content to inherit from $.mobile.page.prototype.options.contentTheme" );
61 ok( dialog.find( ":jqmData(role=footer)" ).hasClass( "ui-bar-" + $.mobile.page.prototype.options.footerTheme ), "Expected footer to inherit from $.mobile.page.prototype.options.footerTheme" );
68 asyncTest( "dialog element with data-theme", function() {
69 // Reset fallback theme for content
70 $.mobile.page.prototype.options.contentTheme = null;
74 $.testHelper.pageSequence([
76 $.mobile.changePage( $( "#mypage" ) );
81 $( "#link-b" ).click();
85 var dialog = $( "#dialog-b" );
87 // Assert dialog theme inheritance (issue 1375):
88 ok( dialog.hasClass( "ui-body-e" ), "Expected explicit theme ui-body-e" );
89 ok( !dialog.hasClass( "ui-overlay-b" ), "Expected no theme ui-overlay-b" );
90 ok( dialog.find( ":jqmData(role=header)" ).hasClass( "ui-bar-" + $.mobile.page.prototype.options.footerTheme ), "Expected header to inherit from $.mobile.page.prototype.options.headerTheme" );
91 ok( dialog.find( ":jqmData(role=content)" ).hasClass( "ui-body-e" ), "Expect content to inherit from data-theme" );
92 ok( dialog.find( ":jqmData(role=footer)" ).hasClass( "ui-bar-" + $.mobile.page.prototype.options.footerTheme ), "Expected footer to inherit from $.mobile.page.prototype.options.footerTheme" );
99 asyncTest( "dialog element with data-theme & data-overlay-theme", function() {
102 $.testHelper.pageSequence([
104 $.mobile.changePage( $( "#mypage" ) );
108 //bring up the dialog
109 $( "#link-c" ).click();
113 var dialog = $( "#dialog-c" );
115 // Assert dialog theme inheritance (issue 1375):
116 ok( dialog.hasClass( "ui-body-e" ), "Expected explicit theme ui-body-e" );
117 ok( dialog.hasClass( "ui-overlay-b" ), "Expected explicit theme ui-overlay-b" );
118 ok( dialog.find( ":jqmData(role=header)" ).hasClass( "ui-bar-" + $.mobile.page.prototype.options.footerTheme ), "Expected header to inherit from $.mobile.page.prototype.options.headerTheme" );
119 ok( dialog.find( ":jqmData(role=content)" ).hasClass( "ui-body-" + $.mobile.page.prototype.options.contentTheme ), "Expect content to inherit from $.mobile.page.prototype.options.contentTheme" );
120 ok( dialog.find( ":jqmData(role=footer)" ).hasClass( "ui-bar-" + $.mobile.page.prototype.options.footerTheme ), "Expected footer to inherit from $.mobile.page.prototype.options.footerTheme" );