shoelace/src/components/textarea/textarea.test.ts

36 wiersze
1.1 KiB
TypeScript
Czysty Zwykły widok Historia

2021-06-25 23:02:34 +00:00
import { expect, fixture, html, waitUntil } from '@open-wc/testing';
import sinon from 'sinon';
import '../../../dist/shoelace.js';
import type SlTextarea from './textarea';
describe('<sl-textarea>', () => {
it('should be disabled with the disabled attribute', async () => {
const el = await fixture(html` <sl-textarea disabled></sl-textarea> `);
const textarea = el.shadowRoot?.querySelector('[part="textarea"]') as HTMLInputElement;
expect(textarea.disabled).to.be.true;
});
it('should be valid by default', async () => {
const el = (await fixture(html` <sl-textarea></sl-textarea> `)) as SlTextarea;
expect(el.invalid).to.be.false;
});
it('should be invalid when required and empty', async () => {
const el = (await fixture(html` <sl-textarea required></sl-textarea> `)) as SlTextarea;
expect(el.invalid).to.be.true;
});
it('should be invalid when required and after removing disabled ', async () => {
const el = (await fixture(html` <sl-textarea disabled required></sl-textarea> `)) as SlTextarea;
el.disabled = false;
await el.updateComplete;
expect(el.invalid).to.be.true;
});
});