Skip to content

Commit

Permalink
test(component-library): do nothing when clicking on a disabled conte…
Browse files Browse the repository at this point in the history
…xt menu item
  • Loading branch information
Haberkamp committed Jan 23, 2025
1 parent e407e06 commit f52e3de
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,29 @@ describe("mt-context-menu", async () => {
// ASSERT
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});

it("does not emit a click event when clicking on a disabled context menu item", async () => {
// ARRANGE
const handler = vi.fn();

render(
defineComponent({
components: { MtContextButton, MtContextMenuItem },
setup: () => ({ handler }),
template: `
<mt-context-button>
<mt-context-menu-item disabled @click="handler">Item 1</mt-context-menu-item>
</mt-context-button>
`,
}),
);

await userEvent.click(screen.getByRole("button"));

// ACT
await userEvent.click(screen.getByRole("menuitem"));

// ASSERT
expect(handler).not.toHaveBeenCalled();
});
});

0 comments on commit f52e3de

Please sign in to comment.