Permalink
Browse files

[unit tests] Add unit test for dialog double hash fix -- Re: #2656

  • Loading branch information...
1 parent 49c87f9 commit b3011fd954c58c2f32deb9dd5c8ae70339058c3c @gabrielschulhof gabrielschulhof committed Apr 19, 2012
Showing with 42 additions and 0 deletions.
  1. +11 −0 tests/unit/navigation/index.html
  2. +31 −0 tests/unit/navigation/navigation_core.js
View
11 tests/unit/navigation/index.html
@@ -146,6 +146,17 @@ <h2 id="qunit-userAgent"></h2>
<a href="#" data-nstest-rel="back">Go Back</a>
</div>
+<div id="dialog-double-hash-test-dialog" data-nstest-role="dialog">
+ <div data-nstest-role="header">
+ <h1>Dialog</h1>
+ </div>
+</div>
+
+<div id="dialog-double-hash-test" data-nstest-role="page">
+ <div data-nstest-role="content">
+ <a href="#dialog-double-hash-test-dialog">Dialog</a>
+ </div>
+</div>
<div id="nested-dialog-page" data-nstest-role="page">
<div data-nstest-role="content">
View
31 tests/unit/navigation/navigation_core.js
@@ -465,6 +465,37 @@
}]);
});
+ asyncTest( "opening a dialog, closing it, moving forward, and opening it again, does not result in a dialog that needs to be closed twice ", function() {
+ $.testHelper.pageSequence([
+ // setup
+ function(){ $.testHelper.openPage("#dialog-double-hash-test"); },
+
+ // transition to the dialog
+ function(){ $("#dialog-double-hash-test a").click(); },
+
+ // close the dialog
+ function(){ $("#dialog-double-hash-test-dialog a").click(); },
+
+ // Go forward
+ function(){ window.history.forward(); },
+
+ // transition to the dialog
+ function(){ $("#dialog-double-hash-test a").click(); },
+
+ // close the dialog
+ function(){
+ $("#dialog-double-hash-test-dialog a").click();
+ },
+
+ // make sure the dialog is closed
+ function() {
+ setTimeout( function() {
+ same($("#dialog-double-hash-test")[0], $.mobile.activePage[0], "should be back to the test page");
+ }, 300);
@johnbender
johnbender Apr 20, 2012

I fixed the build by moving the start into the timeout - the same call was running after the next test had started. Timing is a bitch :(

Either way I'm curious why the timeout is necessary at all, the pagechange event should be firing after the dialog has gone away. Any chance you'll look into that?

@scottjehl
scottjehl Apr 20, 2012
+ start();
+ }]);
+ });
+
asyncTest( "going back from a dialog triggered from a dialog should result in the first dialog ", function(){
$.testHelper.pageSequence([
// setup

0 comments on commit b3011fd

Please sign in to comment.