summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();