-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbutton.test.basics.ts
63 lines (51 loc) · 1.42 KB
/
button.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
import sinon from 'sinon';
import { expect, fixture, html } from '@open-wc/testing';
import { customElement } from 'lit/decorators.js';
import GlideCoreButton from './button.js';
@customElement('glide-core-subclassed')
class GlideCoreSubclassed extends GlideCoreButton {}
it('registers itself', async () => {
expect(window.customElements.get('glide-core-button')).to.equal(
GlideCoreButton,
);
});
it('is accessible', async () => {
const host = await fixture(
html`<glide-core-button label="Label"></glide-core-button>`,
);
await expect(host).to.be.accessible();
});
it('has `#onPrefixIconSlotChange` coverage', async () => {
await fixture<GlideCoreButton>(html`
<glide-core-button label="Label">
<span slot="prefix-icon">Prefix</span>
</glide-core-button>
`);
});
it('has `#onSuffixIconSlotChange` coverage', async () => {
await fixture<GlideCoreButton>(html`
<glide-core-button label="Label">
<span slot="suffix-icon">Suffix</span>
</glide-core-button>
`);
});
it('throws when `label` is empty', async () => {
const spy = sinon.spy();
try {
await fixture<GlideCoreButton>(
html`<glide-core-button></glide-core-button>`,
);
} 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);
});