Skip to content

Commit

Permalink
add very basic selectable tests for table row
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen committed Nov 27, 2024
1 parent 44b4049 commit 6b986df
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/uui-table/lib/uui-table-row.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {

import '.';
import { UUITableRowElement } from './uui-table-row.element';
import { UUITestMouse } from '../../../test/index';

describe('UuiTableRow', () => {
let element: UUITableRowElement;
Expand Down Expand Up @@ -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;
});
});
});

0 comments on commit 6b986df

Please sign in to comment.