From 6b986df94c2a931edb4dcb3f1923d7a4194c2f1c Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 27 Nov 2024 22:07:03 +0100 Subject: [PATCH] add very basic selectable tests for table row --- packages/uui-table/lib/uui-table-row.test.ts | 46 ++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/uui-table/lib/uui-table-row.test.ts b/packages/uui-table/lib/uui-table-row.test.ts index 55382f915..a160e0417 100644 --- a/packages/uui-table/lib/uui-table-row.test.ts +++ b/packages/uui-table/lib/uui-table-row.test.ts @@ -8,6 +8,7 @@ import { import '.'; import { UUITableRowElement } from './uui-table-row.element'; +import { UUITestMouse } from '../../../test/index'; describe('UuiTableRow', () => { let element: UUITableRowElement; @@ -60,4 +61,49 @@ describe('UuiTableRow', () => { }); }); }); + + // TODO: add tests with different kinds of elements in the cells + 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; + }); + }); + + // TODO: add tests with different kinds of elements in the cells + describe('selectable & selectOnly', () => { + const mouse = new UUITestMouse(); + + beforeEach(async () => { + element.selectable = true; + element.selectOnly = 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; + }); + }); });