Skip to content

Commit

Permalink
add tests for uui-color-swatch selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen committed Nov 27, 2024
1 parent 0420638 commit 9f525e1
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion packages/uui-color-swatch/lib/uui-color-swatch.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { html, fixture, expect } from '@open-wc/testing';
import { html, fixture, expect, elementUpdated } from '@open-wc/testing';
import { UUIColorSwatchElement } from './uui-color-swatch.element';
import { sendMouse } from '@web/test-runner-commands';

describe('UUIColorSwatchElement', () => {
let element: UUIColorSwatchElement;
Expand All @@ -17,4 +18,42 @@ describe('UUIColorSwatchElement', () => {
it('passes the a11y audit', async () => {
await expect(element).shadowDom.to.be.accessible();
});

describe('selectable', () => {
beforeEach(async () => {
element.selectable = true;
});

it('can be selected when selectable', async () => {
await elementUpdated(element);
await sendMouse({
type: 'click',
position: [15, 15],
button: 'left',
});
expect(element.selected).to.be.true;
});

it('can not be selected when not selectable', async () => {
element.selectable = false;
await elementUpdated(element);
await sendMouse({
type: 'click',
position: [15, 15],
button: 'left',
});
expect(element.selected).to.be.false;
});

it('cant be selected when disabled', async () => {
element.disabled = true;
await elementUpdated(element);
await sendMouse({
type: 'click',
position: [15, 15],
button: 'left',
});
expect(element.selected).to.be.false;
});
});
});

0 comments on commit 9f525e1

Please sign in to comment.