2022-01-16 05:47:14 +00:00
|
|
|
import { expect, fixture, html } from '@open-wc/testing';
|
2021-06-25 23:02:34 +00:00
|
|
|
import type SlTextarea from './textarea';
|
|
|
|
|
|
|
|
describe('<sl-textarea>', () => {
|
|
|
|
it('should be disabled with the disabled attribute', async () => {
|
2021-08-10 21:11:07 +00:00
|
|
|
const el = await fixture<SlTextarea>(html` <sl-textarea disabled></sl-textarea> `);
|
2022-01-16 05:47:14 +00:00
|
|
|
const textarea = el.shadowRoot!.querySelector<HTMLTextAreaElement>('[part="textarea"]')!;
|
2021-06-25 23:02:34 +00:00
|
|
|
|
|
|
|
expect(textarea.disabled).to.be.true;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be valid by default', async () => {
|
2021-08-10 21:11:07 +00:00
|
|
|
const el = await fixture<SlTextarea>(html` <sl-textarea></sl-textarea> `);
|
2021-06-25 23:02:34 +00:00
|
|
|
|
|
|
|
expect(el.invalid).to.be.false;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be invalid when required and empty', async () => {
|
2021-08-10 21:11:07 +00:00
|
|
|
const el = await fixture<SlTextarea>(html` <sl-textarea required></sl-textarea> `);
|
2021-06-25 23:02:34 +00:00
|
|
|
|
|
|
|
expect(el.invalid).to.be.true;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be invalid when required and after removing disabled ', async () => {
|
2021-08-10 21:11:07 +00:00
|
|
|
const el = await fixture<SlTextarea>(html` <sl-textarea disabled required></sl-textarea> `);
|
2021-06-25 23:02:34 +00:00
|
|
|
|
|
|
|
el.disabled = false;
|
|
|
|
await el.updateComplete;
|
|
|
|
|
|
|
|
expect(el.invalid).to.be.true;
|
|
|
|
});
|
|
|
|
});
|