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

Commit

Permalink
Unit tests: Make sure panel doesn't close upon a default-prevented click
Browse files Browse the repository at this point in the history
Re: #6693
  • Loading branch information
Gabriel Schulhof committed Dec 20, 2013
1 parent d64e81d commit 2fea2fd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/unit/panel/index.html
Expand Up @@ -71,6 +71,10 @@ <h2 id="qunit-userAgent"></h2>
<a href="#demo-links" data-nstest-rel="close" data-nstest-role="button">Close panel</a>
</div>

<div data-nstest-role="panel" id="panel-test-ignore-unrelated-link">
<a href="#" id="unrelated-link" data-nstest-ajax="false">Unrelated link</a>
</div>

<div data-nstest-role="header">
<h1>Panel Test</h1>
</div>
Expand All @@ -86,6 +90,7 @@ <h1 id="demo-links">Panels</h1>
<a href="#panel-test-destroy">Open Panel</a>
<a href="#panel-test-non-default-theme">Open Panel</a>
<a href="#panel-test-with-close">Open Panel</a>
<a href="#panel-test-ignore-unrelated-link">Open Panel</a>
</div>
</div>

Expand Down
40 changes: 40 additions & 0 deletions tests/unit/panel/panel_core.js
Expand Up @@ -284,4 +284,44 @@
$panel.panel( "open" );
});

// Test for https://github.com/jquery/jquery-mobile/issues/6693
asyncTest( "link unrelated to closing the panel does not close the panel", function() {
var panel = $( "#panel-test-ignore-unrelated-link" ),
eventNs = ".ignoreUnrelatedLinkClick";

$( "#unrelated-link" ).one( "click", function( event ) {
event.preventDefault();
});

$.testHelper.detailedEventCascade([
function() {
panel.panel( "open" );
},

{
panelopen: { src: panel, event: "panelopen" + eventNs + "1" }
},

function( result ) {
deepEqual( result.panelopen.timedOut, false, "Panel opened successfully" );
$( "#unrelated-link" ).click();
},

{
panelclose: { src: panel, event: "panelclose" + eventNs + "2" }
},

function( result ) {
deepEqual( result.panelclose.timedOut, true, "Panel did not close in response to unrelated link click" );
panel.panel( "close" );
},

{
panelclose: { src: panel, event: "panelclose" + eventNs + "3" }
},

start
]);
});

}( jQuery ));

0 comments on commit 2fea2fd

Please sign in to comment.