Skip to content

Commit

Permalink
[tests] Added test for floating-ui#211 (floating-ui#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
FezVrasta authored Apr 19, 2017
1 parent 68cfdf2 commit 19bcc85
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/popper/utils/getBoundingClientRect.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ export default function getBoundingClientRect(element) {
if (isIE10) {
try {
rect = element.getBoundingClientRect();
const scrollTop = getScroll(element, 'top');
const scrollLeft = getScroll(element, 'left');
rect.top += scrollTop;
rect.left += scrollLeft;
rect.bottom += scrollTop;
rect.right += scrollLeft;
} catch (err) {}
const scrollTop = getScroll(element, 'top');
const scrollLeft = getScroll(element, 'left');
rect.top += scrollTop;
rect.left += scrollLeft;
} else {
rect = element.getBoundingClientRect();
}
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/flips.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,28 @@ describe('[flipping]', () => {
},
});
});

// This one will fail on IE10 - See #211
xit('properly positions a bottom popper inside very high body', done => {
jasmineWrapper.innerHTML = `
<div id="reference" style="background: pink; margin-top: 100vh; width: 100px; height: 100px;">reference</div>
<div id="popper" style="background: purple; width: 100px; height: 100px;">popper</div>
`;
document.body.style.height = '200vh';

const reference = document.getElementById('reference');
const popper = document.getElementById('popper');

new Popper(reference, popper, {
onCreate() {
simulateScroll(document.body, { scrollTop: getRect(document.body).height, delay: 50 });
},
onUpdate(data) {
expect(getRect(popper).top).toBeApprox(getRect(reference).bottom);
data.instance.destroy();
document.body.style.cssText = null;
done();
},
});
});
});
3 changes: 3 additions & 0 deletions tests/setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import simulateScroll from './utils/simulateScroll';

const wrapper = document.createElement('div');
wrapper.id = 'jasmineWrapper';
document.body.appendChild(wrapper);
Expand Down Expand Up @@ -25,4 +27,5 @@ beforeEach(function() {

const jasmineWrapper = document.getElementById('jasmineWrapper');
jasmineWrapper.innerHTML = '';
simulateScroll(document.body, 0);
});

0 comments on commit 19bcc85

Please sign in to comment.