import './textarea.element.js'; import { assert, fixture, html } from '@open-wc/testing'; import { userEvent } from '@testing-library/user-event'; describe('usa-textarea', () => { 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('fname'), 'Foo'); }); it('should update form value as input value changed', async () => { const form = await fixture(html`
Hello World
`); const input = form.querySelector('usa-textarea'); const nativeInput = input?.shadowRoot?.querySelector('textarea'); if (nativeInput) { await userEvent.type(nativeInput, 'Bar'); } const value = new FormData(form); assert.equal(value.get('fname'), 'Bar'); }); it('should not submit when not valid', async () => { const form = await fixture(html`
Hello World
`); assert.equal(form.checkValidity(), false); }); });