import './checkbox.element.js'; import { assert, fixture, html } from '@open-wc/testing'; describe('usa-checkbox', () => { it('should be accessible', async () => { const form = await fixture(html` Hello World `); return assert.isAccessible(form); }); it('should submit form with default values', async () => { const form = await fixture(html`
Hello World
`); const value = new FormData(form); assert.equal(value.get('enabled'), 'test'); }); it('should update form value as input value changed', async () => { const form = await fixture(html`
Hello World
`); const checkbox = form.querySelector('usa-checkbox'); const nativeInput = checkbox?.shadowRoot?.querySelector('input'); if (nativeInput) { nativeInput.click(); } await Promise.resolve(); const value = new FormData(form); assert.equal(value.get('enabled'), 'test'); }); it('should not submit when not valid', async () => { const form = await fixture(html`
Hello World
`); assert.equal(form.checkValidity(), false); }); });