/// import { render } from '@wdio/browser-runner/stencil'; import { $, expect } from '@wdio/globals'; import { renderToString, serializeProperty } from '../hydrate/index.mjs'; const template = ``; describe('complex-properties', () => { it('should render complex properties', async () => { const { html } = await renderToString(template, { prettyHtml: true, fullDocument: false, }); expect(html).toMatchSnapshot(); }); it('can render component and update properties', async () => { const { html } = await renderToString(template, { fullDocument: false, }); render({ html, components: [] }); await expect($('complex-properties')).toHaveText( [ `this.foo.bar: 123`, `this.foo.loo: 1, 2, 3`, `this.foo.qux: symbol`, `this.baz.get('foo'): symbol`, `this.quux.has('foo'): true`, `this.grault: true`, `this.waldo: true`, `this.kidsNames: John, Jane, Jim`, ].join('\n'), ); }); it('can change a complex property and see it updated correctly', async () => { const elm = document.querySelector('complex-properties') as HTMLComplexPropertiesElement; elm.foo = { bar: '456', loo: [4, 5, 6], qux: { quux: Symbol('new quux') } }; elm.kidsNames.push('Jill'); await expect(elm).toHaveText( [ `this.foo.bar: 456`, `this.foo.loo: 4, 5, 6`, `this.foo.qux: symbol`, `this.baz.get('foo'): symbol`, `this.quux.has('foo'): true`, `this.grault: true`, `this.waldo: true`, `this.kidsNames: John, Jane, Jim, Jill`, ].join('\n'), ); }); });