-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/dom-offset-parent.test.js b/test/dom-offset-parent.test.js
new file mode 100644
index 0000000..7111555
--- /dev/null
+++ b/test/dom-offset-parent.test.js
@@ -0,0 +1,160 @@
+import '../d2l-dom.js';
+import { expect, fixture, html } from '@open-wc/testing';
+import { PolymerElement, html as polymerHtml } from '@polymer/polymer/polymer-element.js';
+
+class TestWrapper extends PolymerElement {
+ static get properties() {
+ return {
+ wrapperId: {
+ type: String,
+ value: 'notExpected'
+ }
+ };
+ }
+ static get template() {
+ return polymerHtml`
+
+
+
+
+ `;
+ }
+}
+
+window.customElements.define('test-wrapper', TestWrapper);
+
+describe('d2l-dom', () => {
+ describe('getOffsetParent', () => {
+ [
+ { name: 'direct-parent', fixture: html`
+
`
+ },
+ { name: 'indirect-parent', fixture: html`
+
`
+ },
+ { name: 'td', fixture: html`
+
`
+ },
+ { name: 'th', fixture: html`
+
`
+ },
+ { name: 'table', fixture: html`
+
`
+ },
+ { name: 'wrapper-inside', fixture: html`
+
`
+ },
+ { name: 'wrapper-passthrough', fixture: html`
+
`
+ },
+ { name: 'wrapper-is-parent', fixture: html`
+
`
+ },
+ { name: 'nested-wrapper-is-parent', fixture: html`
+
`
+ }
+ ].forEach(test => {
+ it(test.name, async() => {
+ const fixt = await fixture(test.fixture);
+ const child = fixt.querySelector('.child');
+ const expected = fixt.querySelector('.expected');
+ expect(D2L.Dom.getOffsetParent(child)).to.equal(expected);
+ });
+ });
+
+ it('wrapper-simple', async() => {
+ const fixt = await fixture(html`
+
+ `);
+ const child = fixt.querySelector('.child');
+ expect(D2L.Dom.getOffsetParent(child).id).to.equal('expected');
+ });
+
+ it('wrapper-nested', async() => {
+ const fixt = await fixture(html`
+
+ `);
+ const child = fixt.querySelector('.child');
+ expect(D2L.Dom.getOffsetParent(child).id).to.equal('expected');
+ });
+
+ it('fallback-when-shadowroot-undefined', () => {
+ const tempShadowRoot = window.ShadowRoot;
+ window.ShadowRoot = false;
+ const child = {
+ offsetParent: 'this is the offsetParent'
+ };
+ expect(D2L.Dom.getOffsetParent(child)).to.equal(child.offsetParent);
+ window.ShadowRoot = tempShadowRoot;
+ });
+
+ it('body', () => {
+ const body = document.querySelector('body');
+ expect(D2L.Dom.getOffsetParent(body)).to.equal(null);
+ });
+
+ it('orphan', () => {
+ const child = document.createElement('div');
+ expect(D2L.Dom.getOffsetParent(child)).to.equal(null);
+ });
+
+ it('orphan-with-extra-steps', () => {
+ const grandparent = document.createElement('div');
+ const parent = document.createElement('div');
+ const child = document.createElement('div');
+ grandparent.appendChild(parent);
+ parent.appendChild(child);
+ expect(D2L.Dom.getOffsetParent(child)).to.equal(null);
+ });
+
+ it('fixed', async() => {
+ const fixed = await fixture(html`
`);
+ const el = fixed.querySelector('#fixed');
+ expect(D2L.Dom.getOffsetParent(el)).to.equal(null);
+ });
+
+ it('body-is-parent', () => {
+ const child = document.createElement('div');
+ document.body.appendChild(child);
+ expect(D2L.Dom.getOffsetParent(child)).to.equal(document.body);
+ });
+ });
+});
diff --git a/test/dom-visibility.html b/test/dom-visibility.test.js
similarity index 61%
rename from test/dom-visibility.html
rename to test/dom-visibility.test.js
index 8da1aaa..21b8a41 100644
--- a/test/dom-visibility.html
+++ b/test/dom-visibility.test.js
@@ -1,17 +1,16 @@
-
-
-
-
-
d2l-dom-visibility tests
-
-
-
-
-
-
+import '../d2l-dom-visibility.js';
+import './dom-visibility-components.js';
+import { expect, fixture, html } from '@open-wc/testing';
+import { dom } from '@polymer/polymer/lib/legacy/polymer.dom.js';
+
+describe('d2l-dom-visibility', () => {
+ let Visibility;
-
-
+ describe('isVisible', () => {
+ let visibilityFixture;
+
+ beforeEach(async() => {
+ const fullFixture = await fixture(html`