import { Component, h } from '@stencil/core'; import { newSpecPage } from '@stencil/core/testing'; describe('hydrate, shadow', () => { it('light dom parent, nested shadow slot', async () => { @Component({ tag: 'cmp-a', }) class CmpA { render() { return CmpALightDom; } } @Component({ tag: 'cmp-b', shadow: true, }) class CmpB { render() { return (
); } } const serverHydrated = await newSpecPage({ components: [CmpA, CmpB], html: ``, hydrateServerSide: true, }); expect(serverHydrated.root).toEqualHtml(`
CmpALightDom
`); const clientHydrated = await newSpecPage({ components: [CmpA, CmpB], html: serverHydrated.root.outerHTML, hydrateClientSide: true, }); expect(clientHydrated.root).toEqualHtml(`
CmpALightDom
`); }); it('light dom content, shadow slot', async () => { @Component({ tag: 'cmp-a', shadow: true, }) class CmpA { render() { return (
ShadowDom
); } } const serverHydrated = await newSpecPage({ components: [CmpA], html: `

LightDom1

LightDom2
`, hydrateServerSide: true, }); expect(serverHydrated.root).toEqualHtml(`
ShadowDom

LightDom1

LightDom2
`); const clientHydrated = await newSpecPage({ components: [CmpA], html: serverHydrated.root.outerHTML, hydrateClientSide: true, }); expect(clientHydrated.root).toEqualHtml(`
ShadowDom

LightDom1

LightDom2
`); }); });