-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathuui-color-swatch.test.ts
81 lines (68 loc) · 2.08 KB
/
uui-color-swatch.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { html, fixture, expect, elementUpdated } from '@open-wc/testing';
import { UUIColorSwatchElement } from './uui-color-swatch.element';
import { UUITestMouse } from '../../../test/index';
describe('UUIColorSwatchElement', () => {
let element: UUIColorSwatchElement;
beforeEach(async () => {
element = await fixture(html`
<uui-color-swatch label="Color swatch"></uui-color-swatch>
`);
});
it('is defined with its own instance', () => {
expect(element).to.be.instanceOf(UUIColorSwatchElement);
});
it('passes the a11y audit', async () => {
await expect(element).shadowDom.to.be.accessible();
});
describe('selectable', () => {
const mouse = new UUITestMouse();
beforeEach(async () => {
element.selectable = true;
});
it('can be selected when selectable', async () => {
await elementUpdated(element);
await mouse.leftClick(element);
expect(element.selected).to.be.true;
});
it('can not be selected when not selectable', async () => {
element.selectable = false;
await elementUpdated(element);
await mouse.leftClick(element);
expect(element.selected).to.be.false;
});
it('cant be selected when disabled', async () => {
element.disabled = true;
await elementUpdated(element);
await mouse.leftClick(element);
expect(element.selected).to.be.false;
});
/* TODO: temp commented out as they are flaky in webkit
it('can be selected with Space key', async () => {
await sendKeys({
press: 'Tab',
});
await sendKeys({
press: 'Space',
});
expect(element.selected).to.be.true;
await sendKeys({
press: 'Space',
});
expect(element.selected).to.be.false;
});
it('can be selected with Enter key', async () => {
await sendKeys({
press: 'Tab',
});
await sendKeys({
press: 'Enter',
});
expect(element.selected).to.be.true;
await sendKeys({
press: 'Enter',
});
expect(element.selected).to.be.false;
});
*/
});
});