testing: components/skeleton (#951)

* add tests for SlSkeleton

* check base aria-properties too
pull/979/head
Felix Becker 2022-10-24 16:04:30 +02:00 zatwierdzone przez GitHub
rodzic 1301934796
commit 3b4d0652c4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 34 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,34 @@
import { expect, fixture, html } from '@open-wc/testing';
import type SlSkeleton from './skeleton';
describe('<sl-skeleton>', () => {
it('should render default skeleton', async () => {
const el = await fixture<SlSkeleton>(html` <sl-skeleton></sl-skeleton> `);
await expect(el).to.be.accessible();
const base = el.shadowRoot!.querySelector<HTMLElement>('[part="base"]')!;
const indicator = el.shadowRoot!.querySelector<HTMLElement>('[part="indicator"]')!;
expect(base.getAttribute('class')).to.equal(' skeleton ');
expect(base.getAttribute('aria-busy')).to.equal('true');
expect(base.getAttribute('aria-live')).to.equal('polite');
expect(indicator.getAttribute('class')).to.equal('skeleton__indicator');
});
it('should set pulse effect by attribute', async () => {
const el = await fixture<SlSkeleton>(html` <sl-skeleton effect="pulse"></sl-skeleton> `);
const base = el.shadowRoot!.querySelector<HTMLElement>('[part="base"]')!;
expect(base.getAttribute('class')).to.equal(' skeleton skeleton--pulse ');
});
it('should set sheen effect by attribute', async () => {
const el = await fixture<SlSkeleton>(html` <sl-skeleton effect="sheen"></sl-skeleton> `);
const base = el.shadowRoot!.querySelector<HTMLElement>('[part="base"]')!;
expect(base.getAttribute('class')).to.equal(' skeleton skeleton--sheen ');
});
});