mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-16 22:10:25 +00:00
removed useless test in for dialogs added simple replacement
This commit is contained in:
parent
099dfbd610
commit
487e04af02
2 changed files with 26 additions and 27 deletions
|
|
@ -2,38 +2,38 @@
|
|||
* mobile dialog unit tests
|
||||
*/
|
||||
(function($){
|
||||
var testValue = "a value we can test!";
|
||||
var wait = function(length){
|
||||
setTimeout(start, length);
|
||||
stop();
|
||||
};
|
||||
|
||||
module('jquery.mobile.dialog.js', {
|
||||
setup: function(){
|
||||
//bring up the dialog
|
||||
$("a[href='#foo-dialog']").click();
|
||||
|
||||
// We prefer the external links don't send the browser elsewhere
|
||||
$("#foo-dialog").delegate("a", "click", function(e){
|
||||
return false;
|
||||
});
|
||||
//wait for the dialog to appear
|
||||
wait(500);
|
||||
},
|
||||
teardown: function(){
|
||||
// close the dialog
|
||||
$(".ui-dialog .ui-icon-delete").parents("a").click();
|
||||
|
||||
// set a test value to verify against change
|
||||
$.mobile.activePage = testValue;
|
||||
// wait for the dialog to disappear
|
||||
wait(500);
|
||||
}
|
||||
});
|
||||
|
||||
test( "external and targeted links do not set the active page", function(){
|
||||
var verifyActivePage = function(selector){
|
||||
$(selector).click();
|
||||
same( $.mobile.activePage, testValue, "mobile active page remains untouched");
|
||||
};
|
||||
|
||||
verifyActivePage("a#http-link");
|
||||
verifyActivePage("a#mailto-link");
|
||||
verifyActivePage("a#rel-link");
|
||||
verifyActivePage("a#target-link");
|
||||
test( "dialog hash is added when the dialog is opened", function(){
|
||||
ok(/&ui-state=dialog/.test(location.hash), "ui-state=dialog =~ location.hash");
|
||||
});
|
||||
|
||||
test( "non external links set the active page", function(){
|
||||
$.mobile.activePage = testValue;
|
||||
$("a#internal-link").click();
|
||||
ok( $.mobile.activePage !== testValue, "mobile is altered");
|
||||
asyncTest( "dialog hash param is removed on close", function(){
|
||||
$(".ui-dialog .ui-icon-delete").parents("a").click();
|
||||
|
||||
setTimeout(function(){
|
||||
ok(!/&ui-state=dialog/.test(location.hash), "ui-state=dialog !~ location.hash");
|
||||
start();
|
||||
}, 600);
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
|||
|
|
@ -50,12 +50,11 @@
|
|||
<a href="#foo-dialog" data-role="button" data-inline="true" data-rel="dialog"></a>
|
||||
</div>
|
||||
|
||||
<div id="foo-dialog">
|
||||
<a href="http://google.com" id="http-link">foo</a>
|
||||
<a href="mailto:foo@bar.com" id="mailto-link">foo</a>
|
||||
<a href="#bar" rel="external" id="rel-link">foo</a>
|
||||
<a href="#bar" target="foo" id="target-link">foo</a>
|
||||
<a href="#bar" id="internal-link">foo</a>
|
||||
<div id="foo-dialog" data-role="dialog">
|
||||
<div data-role="header" data-theme="d" data-position="inline">
|
||||
<h1>Dialog</h1>
|
||||
</div>
|
||||
<a href="#" id="internal-link">foo</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue