2 * mobile navigation path unit tests
5 var url = $.mobile.path.parseUrl( location.href ),
6 home = location.href.replace( url.domain, "" );
8 var testPageLoad = function(testPageAnchorSelector, expectedTextValue){
11 $.testHelper.pageSequence([
13 // reset before each test, all tests expect original page
15 $.testHelper.openPage( "#" + home);
20 $.testHelper.openPage("#pathing-tests");
23 // navigate to the linked page
25 var page = $.mobile.activePage;
27 // check that the reset page isn't still open
28 equal("", page.find(".reset-value").text());
30 //click he test page link to execute the path
31 page.find("a" + testPageAnchorSelector).click();
34 // verify that the page has changed and the expected text value is present
36 same($.mobile.activePage.find(".test-value").text(), expectedTextValue);
42 // all of these alterations assume location.pathname will be a directory
43 // this is required to prevent the tests breaking in a subdirectory
44 // TODO could potentially be fragile since the tests could be running while
45 // the urls are being updated
47 $("a.site-rel").each(function(i, elem){
49 $elem.attr("href", location.pathname + $(elem).attr("href"));
52 $('a.protocol-rel').each(function(i, elem){
54 $elem.attr("href", "//" + location.host + location.pathname + $(elem).attr("href"));
57 $('a.absolute').each(function(i, elem){
60 location.protocol + "//" + location.host +
61 location.pathname + $(elem).attr("href"));
67 module("document relative paths");
69 asyncTest( "file reference no nesting", function(){
70 testPageLoad("#doc-rel-test-one", "doc rel test one");
73 asyncTest( "file reference with nesting", function(){
74 testPageLoad("#doc-rel-test-two", "doc rel test two");
77 asyncTest( "file reference with double nesting", function(){
78 testPageLoad("#doc-rel-test-three", "doc rel test three");
81 asyncTest( "dir refrence with nesting", function(){
82 testPageLoad("#doc-rel-test-four", "doc rel test four");
85 asyncTest( "file refrence with parent dir", function(){
86 testPageLoad("#doc-rel-test-five", "doc rel test five");
89 asyncTest( "dir refrence with parent dir", function(){
90 testPageLoad("#doc-rel-test-six", "doc rel test six");
94 // Site relative tests
95 // NOTE does not test root path or non nested references
96 module("site relative paths");
98 asyncTest( "file reference no nesting", function(){
99 testPageLoad("#site-rel-test-one", "doc rel test one");
102 asyncTest( "file reference with nesting", function(){
103 testPageLoad("#site-rel-test-two", "doc rel test two");
106 asyncTest( "file reference with double nesting", function(){
107 testPageLoad("#site-rel-test-three", "doc rel test three");
110 asyncTest( "dir refrence with nesting", function(){
111 testPageLoad("#site-rel-test-four", "doc rel test four");
114 asyncTest( "file refrence with parent dir", function(){
115 testPageLoad("#site-rel-test-five", "doc rel test five");
118 asyncTest( "dir refrence with parent dir", function(){
119 testPageLoad("#site-rel-test-six", "doc rel test six");
123 // Protocol relative tests
124 // NOTE does not test root path or non nested references
125 module("protocol relative paths");
127 asyncTest( "file reference no nesting", function(){
128 testPageLoad("#protocol-rel-test-one", "doc rel test one");
131 asyncTest( "file reference with nesting", function(){
132 testPageLoad("#protocol-rel-test-two", "doc rel test two");
135 asyncTest( "file reference with double nesting", function(){
136 testPageLoad("#protocol-rel-test-three", "doc rel test three");
139 asyncTest( "dir refrence with nesting", function(){
140 testPageLoad("#protocol-rel-test-four", "doc rel test four");
143 asyncTest( "file refrence with parent dir", function(){
144 testPageLoad("#protocol-rel-test-five", "doc rel test five");
147 asyncTest( "dir refrence with parent dir", function(){
148 testPageLoad("#protocol-rel-test-six", "doc rel test six");
152 // NOTE does not test root path or non nested references
153 module("abolute paths");
155 asyncTest( "file reference no nesting", function(){
156 testPageLoad("#absolute-test-one", "doc rel test one");
159 asyncTest( "file reference with nesting", function(){
160 testPageLoad("#absolute-test-two", "doc rel test two");
163 asyncTest( "file reference with double nesting", function(){
164 testPageLoad("#absolute-test-three", "doc rel test three");
167 asyncTest( "dir refrence with nesting", function(){
168 testPageLoad("#absolute-test-four", "doc rel test four");
171 asyncTest( "file refrence with parent dir", function(){
172 testPageLoad("#absolute-test-five", "doc rel test five");
175 asyncTest( "dir refrence with parent dir", function(){
176 testPageLoad("#absolute-test-six", "doc rel test six");