Commit d729aa73 authored by Phil Hughes's avatar Phil Hughes

spec fix

parent 2c9ca4f1
...@@ -92,13 +92,12 @@ describe('common_utils', () => { ...@@ -92,13 +92,12 @@ describe('common_utils', () => {
<div id="test" style="height: 2000px;"></div> <div id="test" style="height: 2000px;"></div>
</div> </div>
`; `;
const elTop = document.getElementById('test').getBoundingClientRect().top;
window.history.pushState({}, null, '#test'); window.history.pushState({}, null, '#test');
commonUtils.handleLocationHash(); commonUtils.handleLocationHash();
expectGetElementIdToHaveBeenCalledWith('test'); expectGetElementIdToHaveBeenCalledWith('test');
expect(window.scrollY).toBe(elTop); expect(window.scrollY).toBe(document.getElementById('test').offsetTop);
document.getElementById('parent').remove(); document.getElementById('parent').remove();
}); });
...@@ -110,14 +109,13 @@ describe('common_utils', () => { ...@@ -110,14 +109,13 @@ describe('common_utils', () => {
<div id="user-content-test" style="height: 2000px;"></div> <div id="user-content-test" style="height: 2000px;"></div>
</div> </div>
`; `;
const elTop = document.getElementById('user-content-test').getBoundingClientRect().top;
window.history.pushState({}, null, '#test'); window.history.pushState({}, null, '#test');
commonUtils.handleLocationHash(); commonUtils.handleLocationHash();
expectGetElementIdToHaveBeenCalledWith('test'); expectGetElementIdToHaveBeenCalledWith('test');
expectGetElementIdToHaveBeenCalledWith('user-content-test'); expectGetElementIdToHaveBeenCalledWith('user-content-test');
expect(window.scrollY).toBe(elTop); expect(window.scrollY).toBe(document.getElementById('user-content-test').offsetTop);
document.getElementById('parent').remove(); document.getElementById('parent').remove();
}); });
...@@ -132,14 +130,12 @@ describe('common_utils', () => { ...@@ -132,14 +130,12 @@ describe('common_utils', () => {
</div> </div>
`; `;
const elTop = document.getElementById('user-content-test').getBoundingClientRect().top;
window.history.pushState({}, null, '#test'); window.history.pushState({}, null, '#test');
commonUtils.handleLocationHash(); commonUtils.handleLocationHash();
expectGetElementIdToHaveBeenCalledWith('test'); expectGetElementIdToHaveBeenCalledWith('test');
expectGetElementIdToHaveBeenCalledWith('user-content-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); expect(window.scrollBy).toHaveBeenCalledWith(0, -50);
document.getElementById('parent').remove(); document.getElementById('parent').remove();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment