Skip to content

Commit

Permalink
refactor(DownloadMenuItems): change to a simpler version
Browse files Browse the repository at this point in the history
  • Loading branch information
msyavuz committed Jan 24, 2025
1 parent 6892c6a commit 37a4ead
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ export default function DownloadAsImage({
};

return (
<Menu.Item key="download-image">
<div onClick={onDownloadImage} role="button" tabIndex={0}>
{text}
</div>
<Menu.Item
key="download-image"
onClick={e => {
onDownloadImage(e.domEvent);
}}
>
{text}
</Menu.Item>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ export default function DownloadAsPdf({
};

return (
<Menu.Item key="download-pdf">
<div onClick={onDownloadPdf} role="button" tabIndex={0}>
{text}
</div>
<Menu.Item
key="download-pdf"
onClick={e => {
onDownloadPdf(e.domEvent);
}}
>
{text}
</Menu.Item>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const createProps = () => ({

const renderComponent = () => {
render(
<Menu>
<Menu forceSubMenuRender>
<DownloadMenuItems {...createProps()} />
</Menu>,
{
Expand All @@ -43,10 +43,6 @@ const renderComponent = () => {

test('Should render menu items', () => {
renderComponent();
expect(
screen.getByRole('menuitem', { name: 'Export to PDF' }),
).toBeInTheDocument();
expect(
screen.getByRole('menuitem', { name: 'Download as Image' }),
).toBeInTheDocument();
expect(screen.getByText('Export to PDF')).toBeInTheDocument();
expect(screen.getByText('Download as Image')).toBeInTheDocument();
});

0 comments on commit 37a4ead

Please sign in to comment.