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); + }); });