Permalink
Browse files

Pagecontainer: Add unit test for load method when no options are passed

  • Loading branch information...
1 parent 3d9863d commit de70416b1b3a663f0586ddc3ea54d4b61db5250d @arschmitz arschmitz committed Jun 19, 2014
@@ -662,7 +662,7 @@ define( [
url: url,
absUrl: absUrl,
toPage: url,
- prevPage: options.fromPage,
+ prevPage: options ? options.fromPage : undefined,
dataUrl: dataUrl,
deferred: deferred,
options: settings
@@ -0,0 +1,40 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>jQuery Mobile Pagecontainer Unit Test Suite</title>
+
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../js/requirejs.config.js"></script>
+ <script src="../../../js/jquery.tag.inserter.js"></script>
+ <script src="../../jquery.setNameSpace.js"></script>
+ <script src="../../../tests/jquery.testHelper.js"></script>
+
+ <link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
+ <link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
+ <link rel="stylesheet" href="../../jqm-tests.css"/>
+ <script src="../../../external/qunit/qunit.js"></script>
+ <script>
+ $.testHelper.asyncLoad([
+ [ "init" ],
+ [
+ "pagecontainer_core.js"
+ ]
+ ]);
+ </script>
+
+ <script src="../../swarminject.js"></script>
+</head>
+<body id="the-body">
+ <div id="qunit"></div>
+
+ <div data-nstest-role="page" id="start-page">
+ <div data-role="header"><h1>Start page</h1></div>
+ <div class="ui-content">
+ <a href="other-page.html" id="go-to-other-page">Go to other page</a>
+ <a href="page-does-not-exist.html" id="go-to-nonexistent-page">Go to non-existent page</a>
+ </div>
+ </div>
+</body>
+</html>
@@ -0,0 +1,29 @@
+( function() {
+var originalLoad = $.mobile.pagecontainer.prototype._triggerWithDeprecated
+module( "load method", {
+ setup: function(){
+ $.mobile.pagecontainer.prototype._triggerWithDeprecated = function(){
+ return {
+ deprecatedEvent: {
+ isDefaultPrevented: function() {
+ return true;
+ }
+ },
+ event: {
+ isDefaultPrevented: true
+ }
+ }
+ }
+ },
+ teardown: function(){
+ $.mobile.pagecontainer.prototype._triggerWithDeprecated = originalLoad;
+ }
+});
+test( "load does not trigger an error when called withput a second param", function(){
+ var pagecontainer = $( ":mobile-pagecontainer" );
+
+ pagecontainer.pagecontainer( "load", "stuff.html" );
+ ok( "no error triggered when load method called without options" );
+});
+
+})();

0 comments on commit de70416

Please sign in to comment.