diff --git a/packages/uui-color-swatch/lib/uui-color-swatch.test.ts b/packages/uui-color-swatch/lib/uui-color-swatch.test.ts index fbb512d48..7b1b2e8a8 100644 --- a/packages/uui-color-swatch/lib/uui-color-swatch.test.ts +++ b/packages/uui-color-swatch/lib/uui-color-swatch.test.ts @@ -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; @@ -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; + }); }); });