forked from nyaruka/temba-components
-
Notifications
You must be signed in to change notification settings - Fork 1
/
temba-checkbox.test.ts
50 lines (42 loc) · 1.5 KB
/
temba-checkbox.test.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
import { html, fixture, expect } from '@open-wc/testing';
import { Checkbox } from '../src/checkbox/Checkbox';
import { assertScreenshot, getClip } from './utils.test';
describe('temba-checkbox', () => {
it('renders default checkbox', async () => {
const el: Checkbox = await fixture(html`
<temba-checkbox label="My Checkbox"></temba-checkbox>
`);
expect(el.label).to.equal('My Checkbox');
await assertScreenshot('checkbox/default', getClip(el));
});
it('can select by clicking on the label', async () => {
const el: Checkbox = await fixture(html`
<temba-checkbox
label="My Checkbox"
animatechange="false"
></temba-checkbox>
`);
(el.shadowRoot.querySelector('.checkbox-label') as HTMLDivElement).click();
expect(el.checked).to.equal(true);
await assertScreenshot('checkbox/checked', getClip(el));
});
it('fires change event on click', async () => {
// eslint-disable-next-line no-async-promise-executor
return new Promise<void>(async resolve => {
const checkbox: Checkbox = await fixture(html`
<temba-checkbox label="My Checkbox"></temba-checkbox>
`);
checkbox.addEventListener('change', () => {
resolve();
});
click('temba-checkbox');
});
});
it('checks via click method', async () => {
const checkbox: Checkbox = await fixture(html`
<temba-checkbox label="My Checkbox"></temba-checkbox>
`);
checkbox.click();
expect(checkbox.checked).to.equal(true);
});
});