import Popper from '../../src/index.js'; import '@popperjs/test-utils'; const jasmineWrapper = document.getElementById('jasmineWrapper'); // Utils import getRect from '../utils/getRect'; [true, false].forEach((positionFixed) => { describe('[arrow core]' + (positionFixed ? ' Fixed' : ''), () => { beforeEach(function(){ Popper.Defaults.positionFixed = positionFixed; }); afterEach(function() { jasmineWrapper.scrollTop = 0; jasmineWrapper.scrollLeft = 0; }); it('arrowStyles gets defined', done => { jasmineWrapper.innerHTML = `
ref
pop
`; const reference = document.getElementById('reference'); const popper = document.getElementById('popper'); new Popper(reference, popper, { placement: 'bottom', onCreate(data) { expect(data.arrowStyles.left).toBeApprox(getRect(popper).width / 2 - 8); expect(data.arrowStyles.top).toBe(''); data.instance.destroy(); done(); }, }); }); it('arrow addresses popper margin', done => { jasmineWrapper.innerHTML = `
ref
pop
`; const reference = document.getElementById('reference'); const popper = document.getElementById('popper'); const arrow = document.getElementById('arrow'); new Popper(reference, popper, { placement: 'bottom', onCreate(data) { expect(getRect(arrow).left + getRect(arrow).width / 2).toBeApprox( getRect(popper).left + getRect(popper).width / 2 ); data.instance.destroy(); done(); }, }); }); it('arrow addresses popper border width', done => { jasmineWrapper.innerHTML = `
ref
`; const reference = document.getElementById('reference'); const popper = document.getElementById('popper'); const arrow = document.getElementById('arrow'); new Popper(reference, popper, { placement: 'right', onCreate(data) { expect(getRect(arrow).top + getRect(arrow).height / 2).toBeApprox( getRect(popper).top + getRect(popper).height / 2 ); data.instance.destroy(); done(); }, }); }); }); });