diff --git a/package.json b/package.json index 688507d..0eb3855 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@web/dev-server-esbuild": "^0.2.2", "@web/test-runner": "^0.7.12", "@web/test-runner-playwright": "^0.5.4", + "@web/test-runner-puppeteer": "^0.10.5", "eslint": "^7.7.0", "eslint-config-developit": "^1.2.0", "get-stream": "^6.0.0", diff --git a/src/index.test.jsx b/src/index.test.jsx index 00da646..f293941 100644 --- a/src/index.test.jsx +++ b/src/index.test.jsx @@ -245,4 +245,38 @@ describe('web components', () => { }); assert.equal(getShadowHTML(), '

Active theme: sunny

'); }); + + it('renders element in shadow dom open mode', async () => { + function ShadowDomOpen() { + return
Shadow DOM Open
; + } + + registerElement(ShadowDomOpen, 'x-shadowdom-open', [], { + shadow: true, + mode: 'open', + }); + + const el = document.createElement('x-shadowdom-open'); + root.appendChild(el); + const shadowRoot = el.shadowRoot; + assert.isTrue(!!shadowRoot); + const child = shadowRoot.querySelector('.shadow-child'); + assert.isTrue(!!child); + assert.equal(child.textContent, 'Shadow DOM Open'); + }); + + it('renders element in shadow dom closed mode', async () => { + function ShadowDomClosed() { + return
Shadow DOM Closed
; + } + + registerElement(ShadowDomClosed, 'x-shadowdom-closed', [], { + shadow: true, + mode: 'closed', + }); + + const el = document.createElement('x-shadowdom-closed'); + root.appendChild(el); + assert.isTrue(el.shadowRoot === null); + }); });