Permalink
Browse files

[popup unit tests] Test for non-dismissable behaviour

  • Loading branch information...
gabrielschulhof committed Oct 7, 2012
1 parent 352fb0b commit 22b486b6eae5b1a760a8deebc3a5d8b8bdd28c80
Showing with 42 additions and 0 deletions.
  1. +4 −0 tests/unit/popup/index.html
  2. +38 −0 tests/unit/popup/popup_core.js
@@ -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>
@@ -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.