Skip to content

Commit 209fbaf

Browse files
committed
Merge branch 'v1/chore/test-runner-commands' into v1/bugfix/selectableMixin-only-be-selective-when-selectabletarget-is-this
2 parents 2adab35 + 9f525e1 commit 209fbaf

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"@types/mocha": "^10.0.7",
8383
"@web/dev-server-esbuild": "0.4.3",
8484
"@web/test-runner": "0.18.2",
85+
"@web/test-runner-commands": "^0.9.0",
8586
"@web/test-runner-playwright": "0.11.0",
8687
"autoprefixer": "10.4.17",
8788
"babel-loader": "9.1.3",

packages/uui-color-swatch/lib/uui-color-swatch.test.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { html, fixture, expect } from '@open-wc/testing';
1+
import { html, fixture, expect, elementUpdated } from '@open-wc/testing';
22
import { UUIColorSwatchElement } from './uui-color-swatch.element';
3+
import { sendMouse } from '@web/test-runner-commands';
34

45
describe('UUIColorSwatchElement', () => {
56
let element: UUIColorSwatchElement;
@@ -17,4 +18,42 @@ describe('UUIColorSwatchElement', () => {
1718
it('passes the a11y audit', async () => {
1819
await expect(element).shadowDom.to.be.accessible();
1920
});
21+
22+
describe('selectable', () => {
23+
beforeEach(async () => {
24+
element.selectable = true;
25+
});
26+
27+
it('can be selected when selectable', async () => {
28+
await elementUpdated(element);
29+
await sendMouse({
30+
type: 'click',
31+
position: [15, 15],
32+
button: 'left',
33+
});
34+
expect(element.selected).to.be.true;
35+
});
36+
37+
it('can not be selected when not selectable', async () => {
38+
element.selectable = false;
39+
await elementUpdated(element);
40+
await sendMouse({
41+
type: 'click',
42+
position: [15, 15],
43+
button: 'left',
44+
});
45+
expect(element.selected).to.be.false;
46+
});
47+
48+
it('cant be selected when disabled', async () => {
49+
element.disabled = true;
50+
await elementUpdated(element);
51+
await sendMouse({
52+
type: 'click',
53+
position: [15, 15],
54+
button: 'left',
55+
});
56+
expect(element.selected).to.be.false;
57+
});
58+
});
2059
});

0 commit comments

Comments
 (0)