-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaccordion.test.basics.ts
72 lines (59 loc) · 1.78 KB
/
accordion.test.basics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { expect, fixture, html } from '@open-wc/testing';
import sinon from 'sinon';
import { customElement } from 'lit/decorators.js';
import GlideCoreAccordion from './accordion.js';
import expectUnhandledRejection from './library/expect-unhandled-rejection.js';
@customElement('glide-core-subclassed')
class GlideCoreSubclassed extends GlideCoreAccordion {}
it('registers itself', async () => {
expect(window.customElements.get('glide-core-accordion')).to.equal(
GlideCoreAccordion,
);
});
it('is accessible', async () => {
const host = await fixture<GlideCoreAccordion>(
html`<glide-core-accordion label="Label">Content</glide-core-accordion>`,
);
await expect(host).to.be.accessible();
});
it('throws when `label` is empty', async () => {
const spy = sinon.spy();
try {
await fixture(html`<glide-core-accordion>Content</glide-core-accordion>`);
} catch {
spy();
}
expect(spy.callCount).to.equal(1);
});
it('throws when subclassed', async () => {
const spy = sinon.spy();
try {
new GlideCoreSubclassed();
} catch {
spy();
}
expect(spy.callCount).to.equal(1);
});
it('throws if its default slot is empty', async () => {
await expectUnhandledRejection(() => {
return fixture<GlideCoreAccordion>(
html`<glide-core-accordion label="Label"></glide-core-accordion>`,
);
});
});
it('`#onPrefixIconSlotChange` coverage', async () => {
await fixture<GlideCoreAccordion>(
html`<glide-core-accordion label="Label">
Content
<div slot="prefix-icon"></div>
</glide-core-accordion>`,
);
});
it('`#onSuffixIconsSlotChange` coverage', async () => {
await fixture<GlideCoreAccordion>(
html`<glide-core-accordion label="Label">
Content
<div slot="suffix-icons"></div>
</glide-core-accordion>`,
);
});