Skip to content

Commit

Permalink
use send mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen committed Nov 27, 2024
1 parent 6255856 commit 41014f8
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions packages/uui-menu-item/lib/uui-menu-item.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '@umbraco-ui/uui-loader-bar/lib';
import { UUIMenuItemElement } from './uui-menu-item.element';
import { UUIMenuItemEvent } from './UUIMenuItemEvent';
import { UUISelectableEvent } from '@umbraco-ui/uui-base/lib/events';
import { sendMouse } from '@web/test-runner-commands';

describe('UUIMenuItemElement', () => {
let element: UUIMenuItemElement;
Expand Down Expand Up @@ -287,21 +288,33 @@ describe('UUIMenuItemElement', () => {

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

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

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

Expand Down Expand Up @@ -339,21 +352,33 @@ describe('UUIMenuItemElement', () => {

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

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

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

Expand Down

0 comments on commit 41014f8

Please sign in to comment.