Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
[popup unit tests] Test for non-dismissable behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Schulhof committed Oct 7, 2012
1 parent 352fb0b commit 22b486b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/unit/popup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<div data-nstest-role="popup" id="test-destroy-popup" data-nstest-history="false">
<p>This is the test popup</p>
</div>

<div data-nstest-role="popup" id="test-popup-dismissable" data-nstest-dismissable="false">
<p>This is the test popup</p>
</div>
</div>
</div>

Expand Down
38 changes: 38 additions & 0 deletions tests/unit/popup/popup_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,42 @@
})
.popup( "open" );
});

asyncTest( "Cannot close a non-dismissable popup by clicking on the screen", function() {
var $popup = $( "#test-popup-dismissable" ), eventNs = ".cannotCloseNonDismissablePopup";

$.testHelper.detailedEventCascade([
function() {
$popup.popup( "open" );
},
{
navigate: { src: $( window ), event: "navigate" + eventNs + "0" },
popupafteropen: { src: $popup, event: "popupafteropen" + eventNs + "0" }
},
function( results ) {
ok( !results.navigate.timedOut, "A 'navigate' event has occurred" );
ok( !results.popupafteropen.timedOut, "The popup has emitted a 'popupafteropen' event" );
// Click on popup screen
$popup.parent().prev().click();
},
{
navigate: { src: $( window ), event: "navigate" + eventNs + "1" },
popupafterclose: { src: $popup, event: "popupafterclose" + eventNs + "1" }
},
function( results ) {
ok( results.navigate.timedOut, "A 'navigate' event has not occurred" );
ok( results.popupafterclose.timedOut, "The popup has not emitted a 'popupafterclose' event" );
$.mobile.back();
},
{
navigate: { src: $( window ), event: "navigate" + eventNs + "2" },
popupafterclose: { src: $popup, event: "popupafterclose" + eventNs + "2" }
},
function( results ) {
ok( !results.navigate.timedOut, "A 'navigate' event has occurred" );
ok( !results.popupafterclose.timedOut, "The popup has emitted a 'popupafterclose' event" );
start();
}
]);
});
})( jQuery );

0 comments on commit 22b486b

Please sign in to comment.