generated from openscd/oscd-component
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oscd-component.test.ts
40 lines (30 loc) · 1014 Bytes
/
oscd-component.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
import { fixture } from '@open-wc/testing';
import { html } from 'lit';
import { visualDiff } from '@web/test-runner-visual-regression';
import './oscd-component.js';
import type { OscdComponent } from './oscd-component.js';
const factor = process.env.CI ? 2 : 1;
function timeout(ms: number) {
return new Promise(res => {
setTimeout(res, ms * factor);
});
}
mocha.timeout(2000 * factor);
describe('oscd-component', () => {
let element: OscdComponent;
beforeEach(async () => {
element = await fixture(
html`<oscd-component title="Test Title" counter="41"></oscd-component>`
);
document.body.prepend(element);
});
afterEach(() => element.remove());
it('displays the title and counter', async () => {
await visualDiff(element, 'oscd-component');
});
it('increments the counter on button click', async () => {
element.shadowRoot?.querySelector('button')?.click();
await timeout(100);
await visualDiff(element, 'oscd-component-incremented');
});
});