Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 1eb1a98

Browse files
Gabriel Schulhofjaspermdegroot
Gabriel Schulhof
authored andcommitted
Core: Test silentScroll() more robustly
Closes gh-7931
1 parent e0c8376 commit 1eb1a98

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/integration/core/core_scroll.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
(function($){
66
var libName = "core",
7-
scrollTimeout = 20, // TODO expose timing as an attribute
7+
scrollTimeout = 70, // TODO expose timing as an attribute
88
scrollStartEnabledTimeout = 150;
99

1010
module(libName, {
11-
setup: function(){
12-
$("<div id='scroll-testing' style='height: 1000px'></div>").appendTo("body");
11+
setup: function() {
12+
$( "<div id='scroll-testing' " +
13+
"style='height: " + ( screen.height * 3 ) + "px'></div>").appendTo( "body" );
1314
},
1415

1516
teardown: function(){
@@ -18,16 +19,19 @@
1819
});
1920

2021
var scrollUp = function( pos ){
21-
$(window).scrollTop(1000);
22-
ok($(window).scrollTop() > 0, $(window).scrollTop());
22+
$( window ).scrollTop( screen.height );
23+
deepEqual( $( window ).scrollTop() > 0, true,
24+
"After setting scrollTop, it is " + $( window ).scrollTop() );
2325
$.mobile.silentScroll(pos);
2426
};
2527

2628
asyncTest( "silent scroll scrolls the page to the top by default", function(){
2729
scrollUp();
2830

2931
setTimeout(function(){
30-
deepEqual($(window).scrollTop(), 0);
32+
deepEqual( $(window).scrollTop(), $.mobile.defaultHomeScroll,
33+
"After parameterless silentScroll(), scrollTop is $.mobile.defaultHomescroll: " +
34+
$.mobile.defaultHomeScroll );
3135
start();
3236
}, scrollTimeout);
3337
});

0 commit comments

Comments
 (0)