summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-09-29 09:40:21 +0100
committerPhil Hughes <me@iamphill.com>2017-09-29 09:40:21 +0100
commitd729aa73836c4b74b09a8b84ad97694ee858f34c (patch)
tree5e0c841f5902728323eef24230af605090751643
parent2c9ca4f1e021c15224eeeb21f1e8594924773572 (diff)
downloadgitlab-ce-hash-mr-scroll-load.tar.gz
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js10
1 files changed, 3 insertions, 7 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js
index 03c02ea06a8..f86f2f260c3 100644
--- a/spec/javascripts/lib/utils/common_utils_spec.js
+++ b/spec/javascripts/lib/utils/common_utils_spec.js
@@ -92,13 +92,12 @@ describe('common_utils', () => {
<div id="test" style="height: 2000px;"></div>
</div>
`;
- const elTop = document.getElementById('test').getBoundingClientRect().top;
window.history.pushState({}, null, '#test');
commonUtils.handleLocationHash();
expectGetElementIdToHaveBeenCalledWith('test');
- expect(window.scrollY).toBe(elTop);
+ expect(window.scrollY).toBe(document.getElementById('test').offsetTop);
document.getElementById('parent').remove();
});
@@ -110,14 +109,13 @@ describe('common_utils', () => {
<div id="user-content-test" style="height: 2000px;"></div>
</div>
`;
- const elTop = document.getElementById('user-content-test').getBoundingClientRect().top;
window.history.pushState({}, null, '#test');
commonUtils.handleLocationHash();
expectGetElementIdToHaveBeenCalledWith('test');
expectGetElementIdToHaveBeenCalledWith('user-content-test');
- expect(window.scrollY).toBe(elTop);
+ expect(window.scrollY).toBe(document.getElementById('user-content-test').offsetTop);
document.getElementById('parent').remove();
});
@@ -132,14 +130,12 @@ describe('common_utils', () => {
</div>
`;
- const elTop = document.getElementById('user-content-test').getBoundingClientRect().top;
-
window.history.pushState({}, null, '#test');
commonUtils.handleLocationHash();
expectGetElementIdToHaveBeenCalledWith('test');
expectGetElementIdToHaveBeenCalledWith('user-content-test');
- expect(window.scrollY).toBe(elTop - 50);
+ expect(window.scrollY).toBe(document.getElementById('user-content-test').offsetTop - 50);
expect(window.scrollBy).toHaveBeenCalledWith(0, -50);
document.getElementById('parent').remove();