Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / tests / unit / navigation / navigation_paths.js
1 /*
2  * mobile navigation path unit tests
3  */
4 (function($){
5         var url = $.mobile.path.parseUrl( location.href ),
6                 home = location.href.replace( url.domain, "" );
7
8         var testPageLoad = function(testPageAnchorSelector, expectedTextValue){
9                 expect( 2 );
10
11                 $.testHelper.pageSequence([
12                         function(){
13                                 // reset before each test, all tests expect original page
14                                 // for relative urls
15                                 $.testHelper.openPage( "#" + home);
16                         },
17
18                         // open our test page
19                         function(){
20                                 $.testHelper.openPage("#pathing-tests");
21                         },
22
23                         // navigate to the linked page
24                         function(){
25                                 var page = $.mobile.activePage;
26
27                                 // check that the reset page isn't still open
28                                 equal("", page.find(".reset-value").text());
29
30                                 //click he test page link to execute the path
31                                 page.find("a" + testPageAnchorSelector).click();
32                         },
33
34                         // verify that the page has changed and the expected text value is present
35                         function(){
36                                 same($.mobile.activePage.find(".test-value").text(), expectedTextValue);
37                                 start();
38                         }
39                 ]);
40         };
41
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
46         $(function(){
47                 $("a.site-rel").each(function(i, elem){
48                         var $elem = $(elem);
49                         $elem.attr("href", location.pathname + $(elem).attr("href"));
50                 });
51
52                 $('a.protocol-rel').each(function(i, elem){
53                         var $elem = $(elem);
54                         $elem.attr("href", "//" + location.host + location.pathname + $(elem).attr("href"));
55                 });
56
57                 $('a.absolute').each(function(i, elem){
58                         var $elem = $(elem);
59                         $elem.attr("href",
60                                                                         location.protocol + "//" + location.host +
61                                                                         location.pathname + $(elem).attr("href"));
62                 });
63         });
64
65
66         //Doc relative tests
67         module("document relative paths");
68
69         asyncTest( "file reference no nesting", function(){
70                 testPageLoad("#doc-rel-test-one", "doc rel test one");
71         });
72
73         asyncTest( "file reference with nesting", function(){
74                 testPageLoad("#doc-rel-test-two", "doc rel test two");
75         });
76
77         asyncTest( "file reference with double nesting", function(){
78                 testPageLoad("#doc-rel-test-three", "doc rel test three");
79         });
80
81         asyncTest( "dir refrence with nesting", function(){
82                 testPageLoad("#doc-rel-test-four", "doc rel test four");
83         });
84
85         asyncTest( "file refrence with parent dir", function(){
86                 testPageLoad("#doc-rel-test-five", "doc rel test five");
87         });
88
89         asyncTest( "dir refrence with parent dir", function(){
90                 testPageLoad("#doc-rel-test-six", "doc rel test six");
91         });
92
93
94         // Site relative tests
95         // NOTE does not test root path or non nested references
96         module("site relative paths");
97
98         asyncTest( "file reference no nesting", function(){
99                 testPageLoad("#site-rel-test-one", "doc rel test one");
100         });
101
102         asyncTest( "file reference with nesting", function(){
103                 testPageLoad("#site-rel-test-two", "doc rel test two");
104         });
105
106         asyncTest( "file reference with double nesting", function(){
107                 testPageLoad("#site-rel-test-three", "doc rel test three");
108         });
109
110         asyncTest( "dir refrence with nesting", function(){
111                 testPageLoad("#site-rel-test-four", "doc rel test four");
112         });
113
114         asyncTest( "file refrence with parent dir", function(){
115                 testPageLoad("#site-rel-test-five", "doc rel test five");
116         });
117
118         asyncTest( "dir refrence with parent dir", function(){
119                 testPageLoad("#site-rel-test-six", "doc rel test six");
120         });
121
122
123         // Protocol relative tests
124         // NOTE does not test root path or non nested references
125         module("protocol relative paths");
126
127         asyncTest( "file reference no nesting", function(){
128                 testPageLoad("#protocol-rel-test-one", "doc rel test one");
129         });
130
131         asyncTest( "file reference with nesting", function(){
132                 testPageLoad("#protocol-rel-test-two", "doc rel test two");
133         });
134
135         asyncTest( "file reference with double nesting", function(){
136                 testPageLoad("#protocol-rel-test-three", "doc rel test three");
137         });
138
139         asyncTest( "dir refrence with nesting", function(){
140                 testPageLoad("#protocol-rel-test-four", "doc rel test four");
141         });
142
143         asyncTest( "file refrence with parent dir", function(){
144                 testPageLoad("#protocol-rel-test-five", "doc rel test five");
145         });
146
147         asyncTest( "dir refrence with parent dir", function(){
148                 testPageLoad("#protocol-rel-test-six", "doc rel test six");
149         });
150
151         // absolute tests
152         // NOTE does not test root path or non nested references
153         module("abolute paths");
154
155         asyncTest( "file reference no nesting", function(){
156                 testPageLoad("#absolute-test-one", "doc rel test one");
157         });
158
159         asyncTest( "file reference with nesting", function(){
160                 testPageLoad("#absolute-test-two", "doc rel test two");
161         });
162
163         asyncTest( "file reference with double nesting", function(){
164                 testPageLoad("#absolute-test-three", "doc rel test three");
165         });
166
167         asyncTest( "dir refrence with nesting", function(){
168                 testPageLoad("#absolute-test-four", "doc rel test four");
169         });
170
171         asyncTest( "file refrence with parent dir", function(){
172                 testPageLoad("#absolute-test-five", "doc rel test five");
173         });
174
175         asyncTest( "dir refrence with parent dir", function(){
176                 testPageLoad("#absolute-test-six", "doc rel test six");
177         });
178 })(jQuery);