Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[dialog unit tests] Add basic open-the-dialog-close-the-dialog test, …

…and a redirect that runs the test with an initial URL that has #&ui-state=dialog
  • Loading branch information...
commit 2748236799ebd202697e8b060578a161187268a9 1 parent 690fd93
Gabriel "_|Nix|_" Schulhof gabrielschulhof authored
15 tests/unit/dialog/basic-dialog-hash-key-tests.html
View
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../../js/jquery.js"></script>
+ <script src="../../../js/"></script>
+ <script>
+(function($) {
+ var l = $.mobile.path.parseLocation();
+
+ // Redirect to basic-test.html in the same directory as this file
+ location.href = l.protocol + "//" + l.host + l.directory + "basic-tests.html" + l.search + "#&ui-state=dialog";
+})( jQuery );
+ </script>
+</head>
+</html>
57 tests/unit/dialog/basic-tests.html
View
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>jQuery Mobile Dialog Test Suite</title>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../js/jquery.tag.inserter.js"></script>
+ <script>
+ $(document).bind('mobileinit',function(){
+ // Expect content to inherit this theme when not explicitly set
+ $.mobile.page.prototype.options.contentTheme = "d";
+ });
+ </script>
+ <script src="../jquery.setNameSpace.js"></script>
+ <script src="../../jquery.testHelper.js"></script>
+ <script src="../../../external/qunit.js"></script>
+ <script>
+ $.testHelper.asyncLoad([
+ [
+ "widgets/dialog",
+ "widgets/page",
+ "widgets/page.sections"
+ ],
+ [ "jquery.mobile.init" ],
+ [
+ "dialog_basic.js"
+ ]
+ ]);
+ </script>
+
+
+ <link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
+ <link rel="stylesheet" href="../../../external/qunit.css"/>
+
+ <script src="../swarminject.js"></script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery Mobile Dialog Test Suite</h1>
+<h2 id="qunit-banner"></h2>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests">
+</ol>
+
+<div id="basicTestPage" data-nstest-role="page" data-nstest-theme="a">
+ <a id="openBasicDialog" href="#basicDialog" data-nstest-rel="dialog">Dialog</a>
+</div>
+
+<div id="basicDialog" data-nstest-role="dialog">
+ <div data-nstest-role="header">
+ <h1>Dialog</h1>
+ </div>
+</div>
+
+</body>
+</html>
21 tests/unit/dialog/dialog_basic.js
View
@@ -0,0 +1,21 @@
+(function($) {
+
+ asyncTest( "Returning from a dialog results in the page from which it opened", function() {
+ expect( 2 );
+
+ $.testHelper.pageSequence([
+ function() {
+ $( "#openBasicDialog" ).click();
+ },
+ function() {
+ ok( $.mobile.activePage.attr( "id" ) === "basicDialog", "Basic dialog has opened" );
+ $( "a", $.mobile.activePage[ 0 ] ).click();
+ },
+ function() {
+ ok( $.mobile.activePage.attr( "id" ) === "basicTestPage", "Active page is original page" );
+ start();
+ }
+ ]);
+ });
+
+})( jQuery );
Please sign in to comment.
Something went wrong with that request. Please try again.