import popper.js

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2019-12-31 01:21:21 +01:00
commit 16fb2bb919
241 changed files with 34099 additions and 0 deletions

View file

@ -0,0 +1,46 @@
import chai from 'chai';
const { expect } = chai;
import getOffsetParent from '../../src/utils/getOffsetParent';
describe('utils/getOffsetParent', () => {
let node;
beforeEach(() => {
node = document.createElement('div');
document.body.appendChild(node);
});
afterEach(() => {
document.body.removeChild(node);
});
it('element is just appended to the body', () => {
expect(getOffsetParent(node)).to.equal(document.querySelector('html'));
});
it('element is inside positioned element', () => {
const innerNode = document.createElement('div');
node.style.position = 'absolute';
node.appendChild(innerNode);
expect(getOffsetParent(innerNode)).to.equal(node);
});
it('first child element is hidden', () => {
const innerNode = document.createElement('div');
innerNode.style.display = 'none';
const nextSibling = document.createElement('div');
node.style.position = 'absolute';
node.appendChild(innerNode);
node.appendChild(nextSibling);
expect(getOffsetParent(innerNode)).to.equal(node);
});
it('all child elements are hidden', () => {
const innerNode = document.createElement('div');
innerNode.style.display = 'none';
node.style.position = 'absolute';
expect(getOffsetParent(innerNode)).to.equal(document.querySelector('html'));
});
});