|
3 | 3 | */
|
4 | 4 | (function($){
|
5 | 5 | var changePageFn = $.mobile.changePage,
|
6 |
| - originalTitle = document.title; |
| 6 | + originalTitle = document.title, |
| 7 | + siteDirectory = location.pathname.replace(/[^/]+$/, ""); |
7 | 8 | module('jquery.mobile.navigation.js', {
|
8 | 9 | setup: function(){
|
9 | 10 | $.mobile.urlHistory.stack = [];
|
|
14 | 15 | }
|
15 | 16 | });
|
16 | 17 |
|
17 |
| - asyncTest( "changepage will only run once when a new page is visited", function(){ |
| 18 | + asyncTest( "changepage runs once when called with an element", function(){ |
18 | 19 | var called = 0,
|
19 | 20 | newChangePage = function(a,b,c,d,e){
|
20 | 21 | changePageFn( a,b,c,d,e );
|
|
25 | 26 | // avoid initial page load triggering changePage early
|
26 | 27 | function(){
|
27 | 28 | $.mobile.changePage = newChangePage;
|
28 |
| - $('#foo a').click(); |
| 29 | + newChangePage($("#bar")); |
29 | 30 | },
|
30 | 31 |
|
31 | 32 | function(){
|
32 | 33 | ok(called == 1, "change page should be called once");
|
| 34 | + $.mobile.changePage = changePageFn; |
| 35 | + start(); |
| 36 | + }], 500); |
| 37 | + }); |
| 38 | + |
| 39 | + asyncTest( "changepage runs twice when triggered by a link", function(){ |
| 40 | + var called = 0, |
| 41 | + newChangePage = function(a,b,c,d,e){ |
| 42 | + changePageFn( a,b,c,d,e ); |
| 43 | + called ++; |
| 44 | + }; |
| 45 | + |
| 46 | + $.testHelper.sequence([ |
| 47 | + // avoid initial page load triggering changePage early |
| 48 | + function(){ |
| 49 | + $.mobile.changePage = newChangePage; |
| 50 | + $('#foo a').click(); |
| 51 | + }, |
| 52 | + |
| 53 | + function(){ |
| 54 | + ok(called == 2, "change page should be called twice"); |
| 55 | + $.mobile.changePage = changePageFn; |
33 | 56 | start();
|
34 | 57 | }], 500);
|
35 | 58 | });
|
|
166 | 189 | };
|
167 | 190 |
|
168 | 191 | test( "when loading a page where data-url is not defined on a sub element hash defaults to the url", function(){
|
169 |
| - testDataUrlHash("#non-data-url a", new RegExp("^#/tests/unit/navigation/data-url-tests/non-data-url.html$")); |
| 192 | + testDataUrlHash("#non-data-url a", new RegExp("^#" + siteDirectory + "data-url-tests/non-data-url.html$")); |
170 | 193 | });
|
171 | 194 |
|
172 | 195 | test( "data url works for nested paths", function(){
|
|
0 commit comments