Skip to content

Commit

Permalink
fix hash state for dialog tests, remove console log from popup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Jul 26, 2012
1 parent b1946a6 commit 3b56b55
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 25 deletions.
24 changes: 24 additions & 0 deletions tests/jquery.testHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,30 @@
} else {
same( parts.hash, "#" + (args.hashOrPush || args.hash), args.report );
}
},

navReset: function( url ) {
var pageReset = function( hash ) {
hash = hash || "";

stop();

$(document).one( "pagechange", function() {
start();
});

location.hash = "#" + hash;
};

// force the page reset for hash based tests
if ( location.hash && !$.support.pushState ) {
pageReset();
}

// force the page reset for all pushstate tests
if ( $.support.pushState ) {
pageReset( url );
}
}
};
})(jQuery);
56 changes: 33 additions & 23 deletions tests/unit/dialog/dialog_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
* mobile dialog unit tests
*/
(function($) {
var home = $.mobile.path.parseUrl(location.pathname).directory,
homeWithSearch = home + location.search;

module( "jquery.mobile.dialog.js", {
setup: function() {
$.mobile.page.prototype.options.contentTheme = "d";
$.testHelper.navReset( homeWithSearch );
}
});

asyncTest( "dialog hash is added when the dialog is opened and removed when closed", function() {
expect( 2 );

$.testHelper.pageSequence([
function() {
$.mobile.changePage( $( "#mypage" ) );
},

function() {
//bring up the dialog
$( "#foo-dialog-link" ).click();
Expand All @@ -32,7 +32,7 @@
},

function() {
ok( !/&ui-state=dialog/.test(location.hash), "ui-state=dialog !~ location.hash" );
ok( !(/&ui-state=dialog/.test(location.hash)), "ui-state=dialog !~ location.hash" );
start();
}
]);
Expand Down Expand Up @@ -76,7 +76,7 @@

asyncTest( "dialog element with no theming", function() {
expect(4);

$.testHelper.pageSequence([
function() {
$.mobile.changePage( $( "#mypage" ) );
Expand Down Expand Up @@ -159,24 +159,34 @@
}
]);
});


asyncTest( "page container is updated to dialog overlayTheme at pagebeforeshow", function(){

var pageTheme;

expect( 1 );

var pageTheme = "ui-overlay-" + $.mobile.activePage.dialog( "option", "overlayTheme" );

$.mobile.pageContainer.removeClass( pageTheme );

$.mobile.activePage
.bind( "pagebeforeshow", function(){
ok( $.mobile.pageContainer.hasClass( pageTheme ), "Page container has the same theme as the dialog overlayTheme on pagebeforeshow" );
start();
})
.trigger( "pagebeforeshow" );

} );


$.testHelper.pageSequence([
function() {
$.mobile.changePage( "#mypage" );
},

function() {
//bring up the dialog
$( "#foo-dialog-link" ).click();
},

function() {
pageTheme = "ui-overlay-" + $.mobile.activePage.dialog( "option", "overlayTheme" );

$.mobile.pageContainer.removeClass( pageTheme );

$.mobile.activePage
.bind( "pagebeforeshow", function(){
ok( $.mobile.pageContainer.hasClass( pageTheme ), "Page container has the same theme as the dialog overlayTheme on pagebeforeshow" );
start();
}).trigger( "pagebeforeshow" );
}
]);
});
})( jQuery );
3 changes: 1 addition & 2 deletions tests/unit/popup/popup_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// seq : [
// fn(result),
// { key: {
// src: event source (is jQuery object),
// src: event source (is jQuery object),
// event: event name (is string),
// NB: It's a good idea to namespace your events, because the handler will be removed
// based on the name you give here if a timeout occurs before the event fires.
Expand Down Expand Up @@ -167,7 +167,6 @@
popupEnhancementTests( $payload, "When created on-the-fly" );
ok( $container.children().first().html() === "<!-- placeholder for otf-popup -->", "When created on-the-fly, there is a placeholder in the popup div's original location" );
$payload.popup( "destroy" );
console.log( "class: " + $payload.attr( "class" ) );
ok( !$payload.attr( "class" ), "After destroying on-the-fly popup, the payload has no 'class' attribute" );
ok( $container.children().is( $payload ), "After destroying on-the-fly popup, its payload is returned to its original location" );
});
Expand Down

0 comments on commit 3b56b55

Please sign in to comment.