Skip to content

Commit

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

describe('UUIColorSwatchElement', () => {
let element: UUIColorSwatchElement;
Expand Down Expand Up @@ -55,5 +55,35 @@ describe('UUIColorSwatchElement', () => {
});
expect(element.selected).to.be.false;
});

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;
});
});
});

0 comments on commit 5ac142f

Please sign in to comment.