diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index d7db98c8..54a55c27 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -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); diff --git a/tests/unit/dialog/index.html b/tests/unit/dialog/index.html index 0214dcda..79b62ebe 100644 --- a/tests/unit/dialog/index.html +++ b/tests/unit/dialog/index.html @@ -50,12 +50,11 @@ -
- foo - foo - foo - foo - foo +
+
+

Dialog

+
+ foo