Skip to content
Snippets Groups Projects
Unverified Commit bcc4bee1 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Expand `EntityMenuItem` component test coverage (#30615)

* Do not render menu item that has both `action` and `link` props

* Add unit tests

* Address PR comment and refactor tests
parent c70fba89
Branches
Tags
No related merge requests found
......@@ -32,7 +32,8 @@ const EntityMenuItem = ({
onClose,
}: EntityMenuItemProps): JSX.Element | null => {
if (link && action) {
return <div />;
// You cannot specify both action and link props!
return null;
}
const content = (
......
......@@ -41,5 +41,30 @@ describe("EntityMenuItem", () => {
expect(screen.getByTestId("entity-menu-link")).toBeInTheDocument();
});
});
it("should not render if both action and link props are present", () => {
render(
<div data-testid="container">
<EntityMenuItem
title="A pencil icon"
icon="pencil"
link="/derp"
action={() => ({})}
/>
</div>,
);
expect(screen.getByTestId("container")).toBeEmptyDOMElement();
});
it("should not render if neither action nor link props are present", () => {
render(
<div data-testid="container">
<EntityMenuItem title="A pencil icon" icon="pencil" />
</div>,
);
expect(screen.getByTestId("container")).toBeEmptyDOMElement();
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment