Skip to content

Commit 020f4b7

Browse files
committed
seperate transition tests, whitespace
1 parent 57338ef commit 020f4b7

File tree

3 files changed

+334
-42
lines changed

3 files changed

+334
-42
lines changed

tests/unit/navigation/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<link rel="stylesheet" href="../../../external/qunit.css"/>
1818
<script src="../../../external/qunit.js"></script>
1919

20-
<script type="text/javascript" src="navigation_transitions.js"></script>
2120
<script type="text/javascript" src="navigation_helpers.js"></script>
2221
<script type="text/javascript" src="navigation_core.js"></script>
2322
<script type="text/javascript" src="navigation_paths.js"></script>

tests/unit/navigation/navigation_transitions.js

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
isTransitioningIn = function(page){
2020
return page.hasClass("in") && isTransitioning(page);
2121
},
22-
22+
2323
disableMaxTransWidth = function(){
2424
$.mobile.maxTransitionWidth = false;
2525
},
26-
26+
2727
enableMaxTransWidth = function(){
2828
$.mobile.maxTransitionWidth = defaultMaxTrans;
2929
},
@@ -36,15 +36,15 @@
3636
fromQueue = [];
3737
toQueue = [];
3838
},
39-
39+
4040
onFromComplete = function( f ){
4141
fromQueue.push( f );
4242
},
43-
43+
4444
onToComplete = function( f ){
4545
toQueue.push( f );
4646
},
47-
47+
4848

4949
//wipe all urls
5050
clearUrlHistory = function(){
@@ -55,9 +55,11 @@
5555

5656
module('jquery.mobile.navigation.js', {
5757
setup: function(){
58+
59+
5860
// disable this option so we can test transitions regardless of window width
5961
disableMaxTransWidth();
60-
62+
6163
//stub to allow callback before function is returned to transition handler
6264
$.fn.animationComplete = function( callback ){
6365
animationCompleteFn.call( this, function(){
@@ -72,6 +74,17 @@
7274

7375
resetQueues();
7476
clearUrlHistory();
77+
78+
if ( location.hash !== "#harmless-default-page" ) {
79+
stop();
80+
81+
$(document).one("pagechange", function() {
82+
start();
83+
} );
84+
85+
location.hash = "#harmless-default-page";
86+
}
87+
7588
},
7689

7790
teardown: function(){
@@ -80,52 +93,51 @@
8093
enableMaxTransWidth();
8194
}
8295
});
83-
84-
/*
85-
NOTES:
86-
Our default transition handler now has either one or two animationComplete calls - two if there are two pages in play (from and to)
96+
97+
/*
98+
NOTES:
99+
Our default transition handler now has either one or two animationComplete calls - two if there are two pages in play (from and to)
87100
To is required, so each async function must call start() onToComplete, not onFromComplete.
88101
*/
89-
102+
90103

91104
asyncTest( "changePage applies perspective class to mobile viewport for flip", function(){
92105
expect(1);
93-
106+
94107
onToComplete( function( el ){
95108
ok($("body").hasClass(perspective), "has perspective class");
96109
start();
97110
} );
98-
99-
$("#foo > a").click();
100111

112+
$("#foo > a").click();
101113
});
102-
114+
103115
asyncTest( "changePage does not apply perspective class to mobile viewport for transitions other than flip", function(){
104116
expect(1);
105-
117+
106118
onToComplete( function( el ){
107119
ok(!$("body").hasClass(perspective), "doesn't have perspective class");
108120
start();
109121
} );
110-
122+
111123
$("#bar > a").click();
112124
});
113-
125+
114126
asyncTest( "changePage applies transition class to mobile viewport for default transition", function(){
115127
expect(1);
116-
128+
117129
onToComplete( function( el ){
118130
ok($("body").hasClass(transitioning), "has transitioning class");
119131
start();
120132
} );
121-
133+
122134
$("#baz > a").click();
123135

124136
});
125-
137+
126138
asyncTest( "explicit transition preferred for page navigation reversal (ie back)", function(){
127139
expect( 1 );
128-
140+
129141
onToComplete(function(){
130142
$("#flip-trans > a").click();
131143
onToComplete(function(){
@@ -136,7 +148,7 @@
136148
});
137149
});
138150
});
139-
151+
140152
$("#fade-trans > a").click();
141153
});
142154

@@ -145,7 +157,7 @@
145157
ok($("#no-trans").hasClass("fade"), "has fade class");
146158
start();
147159
})
148-
160+
149161
$("#default-trans > a").click();
150162
});
151163

@@ -164,7 +176,7 @@
164176
ok(!isTransitioningIn(firstPage), "first page transition should be complete");
165177
ok(isTransitioningIn(secondPage), "second page should begin transitioning");
166178
start();
167-
179+
168180
});
169181
});
170182
});
@@ -175,47 +187,43 @@
175187
ok($("#no-trans-dialog").hasClass("pop"), "has pop class" );
176188
start();
177189
});
178-
190+
179191
$("#default-trans-dialog > a").click();
180192
});
181193

182194
test( "animationComplete return value", function(){
183195
$.fn.animationComplete = animationCompleteFn;
184196
equals($("#foo").animationComplete(function(){})[0], $("#foo")[0]);
185197
});
186-
187-
198+
199+
188200
// reusable function for a few tests below
189201
function testTransitionMaxWidth( val, expected ){
190202
expect( 1 );
191-
203+
192204
$.mobile.maxTransitionWidth = val;
193-
205+
194206
var transitionOccurred = false;
195-
207+
196208
onToComplete(function(){
197209
transitionOccurred = true;
198210
});
199-
200-
211+
212+
201213
return setTimeout(function(){
202214
ok( transitionOccurred === expected, (expected ? "" : "no ") + "transition occurred" );
203215
start();
204216
}, 5000);
205-
217+
206218
$.mobile.changePage( $(".ui-page:not(.ui-page-active)").first() );
207-
219+
208220
}
209-
221+
210222
asyncTest( "maxTransitionWidth property disables transitions when value is less than browser width", function(){
211223
testTransitionMaxWidth( $( window ).width() - 1, false );
212224
});
213-
225+
214226
asyncTest( "maxTransitionWidth property disables transitions when value is false", function(){
215227
testTransitionMaxWidth( false, false );
216228
});
217-
218-
219-
220-
221229
})(jQuery);

0 commit comments

Comments
 (0)