import '../../../dist/zn.min.js'; import { expect, fixture, html } from '@open-wc/testing'; describe('', () => { it('should render a component', async () => { const el = await fixture(html` `); expect(el).to.exist; }); it('should render the description under the label', async () => { const el = await fixture(html` `); const label = el.shadowRoot!.querySelector('.switch-label')!; const description = el.shadowRoot!.querySelector('[part="description"]')!; expect(description.textContent).to.include('Receive an email when mentioned.'); expect(label.nextElementSibling).to.equal(description); }); describe('form submission', () => { it('should submit the value when checked', async () => { const form = await fixture(html`
`); expect(new FormData(form).get('feature')).to.equal('enabled'); }); it('should submit "off" when unchecked', async () => { const form = await fixture(html`
`); expect(new FormData(form).get('feature')).to.equal('off'); }); it('should submit the fallback value when unchecked', async () => { const form = await fixture(html`
`); expect(new FormData(form).get('feature')).to.equal('disabled'); }); }); });