Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(router): use pageYOffset in testing when scrollY is not available #35976

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions packages/router/test/BUILD.bazel
Expand Up @@ -44,21 +44,6 @@ jasmine_node_test(

karma_web_test_suite(
name = "test_web",
tags = [
# FIXME: fix on saucelabs
# IE 11.0.0 (Windows 8.1.0.0) bootstrap should restore the scrolling position FAILED
# IE 10.0.0 (Windows 8.0.0) bootstrap should restore the scrolling position FAILED
# Error: Expected undefined to equal 5000.
# at <Jasmine>
# Error: Expected undefined to equal 3000.
# at <Jasmine>
# Error: Expected undefined to equal 0.
# at <Jasmine>
# Error: Expected false to be true.
# at <Jasmine>
"fixme-saucelabs-ivy",
"fixme-saucelabs-ve",
],
deps = [
":test_lib",
],
Expand Down
15 changes: 9 additions & 6 deletions packages/router/test/bootstrap.spec.ts
Expand Up @@ -298,24 +298,27 @@ describe('bootstrap', () => {
await router.navigateByUrl('/aa');
window.scrollTo(0, 5000);

// IE 9/10/11 use non-standard pageYOffset instead of scrollY
const getScrollY = () => window.scrollY !== undefined ? window.scrollY : window.pageYOffset;

await router.navigateByUrl('/fail');
expect(window.scrollY).toEqual(5000);
expect(getScrollY()).toEqual(5000);

await router.navigateByUrl('/bb');
window.scrollTo(0, 3000);

expect(window.scrollY).toEqual(3000);
expect(getScrollY()).toEqual(3000);

await router.navigateByUrl('/cc');
expect(window.scrollY).toEqual(0);
expect(getScrollY()).toEqual(0);

await router.navigateByUrl('/aa#marker2');
expect(window.scrollY >= 5900).toBe(true);
expect(getScrollY() >= 5900).toBe(true);
expect(window.scrollY < 6000).toBe(true); // offset

await router.navigateByUrl('/aa#marker3');
expect(window.scrollY >= 8900).toBe(true);
expect(window.scrollY < 9000).toBe(true);
expect(getScrollY() >= 8900).toBe(true);
expect(getScrollY() < 9000).toBe(true);
done();
});

Expand Down