Skip to content

Commit 3b21481

Browse files
committed
small simplification of core scrolling tests
1 parent ea85b5a commit 3b21481

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

tests/unit/core/core_scroll.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,58 +14,50 @@
1414

1515
teardown: function(){
1616
$("#scroll-testing").remove();
17+
window.fizz = '';
1718
}
1819
});
1920

2021
var scrollUp = function( pos ){
2122
$(window).scrollTop(1000);
22-
ok($(window).scrollTop() > 0);
23-
24-
if(pos) {
25-
$.mobile.silentScroll(pos);
26-
} else {
27-
$.mobile.silentScroll();
28-
}
23+
ok($(window).scrollTop() > 0, $(window).scrollTop());
24+
$.mobile.silentScroll(pos);
2925
};
3026

31-
test( "silent scroll scrolls the page to the top by default", function(){
27+
asyncTest( "silent scroll scrolls the page to the top by default", function(){
3228
scrollUp();
3329

34-
stop();
3530
setTimeout(function(){
3631
same($(window).scrollTop(), 0);
3732
start();
3833
}, scrollTimeout);
3934
});
4035

41-
test( "silent scroll scrolls the page to the passed y position", function(){
36+
asyncTest( "silent scroll scrolls the page to the passed y position", function(){
4237
var pos = 10;
4338
scrollUp(pos);
4439

45-
stop();
4640
setTimeout(function(){
4741
same($(window).scrollTop(), pos);
4842
start();
4943
}, scrollTimeout);
5044
});
5145

5246
// NOTE may be brittle depending on timing
53-
test( "silent scroll takes at least 20 ms to scroll to the top", function(){
47+
asyncTest( "silent scroll takes at least 20 ms to scroll to the top", function(){
5448
scrollUp();
5549

56-
stop();
5750
setTimeout(function(){
58-
ok($(window).scrollTop() != 0);
51+
ok($(window).scrollTop() != 0, "scrolltop position should not be zero");
5952
start();
60-
}, scrollTimeout - 1);
53+
}, scrollTimeout - 2);
6154
});
6255

63-
test( "scrolling marks scrollstart as disabled for 150 ms", function(){
56+
asyncTest( "scrolling marks scrollstart as disabled for 150 ms", function(){
6457
$.event.special.scrollstart.enabled = true;
6558
scrollUp();
6659
ok(!$.event.special.scrollstart.enabled);
6760

68-
stop();
6961
setTimeout(function(){
7062
ok($.event.special.scrollstart.enabled);
7163
start();

0 commit comments

Comments
 (0)