Skip to content

Commit

Permalink
(fix) O3-3890 Help menu (and menu items) should use a standard Carbon…
Browse files Browse the repository at this point in the history
… menu
  • Loading branch information
Samstar10 committed Sep 26, 2024
1 parent 9f24ae4 commit 994dbdb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/tutorial/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@

}
}

.tutorialMenuItem {
color: black !important;
&:focus {
outline: none;
}
}
26 changes: 26 additions & 0 deletions src/tutorial/tutorial.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import '@testing-library/jest-dom';
import { showModal } from "@openmrs/esm-framework";
import Tutorial from "./tutorial";

jest.mock('@openmrs/esm-framework', () => ({
showModal: jest.fn(),
}))

describe('Tutorial Component', () => {
it('renders the menu item with the correct label', () => {
render(<Tutorial />);

expect(screen.getByText(/Tutorials/i)).toBeInTheDocument();
})

it('calls showModal when the menu item is clicked', () => {
render(<Tutorial />);

const menuItem = screen.getByText(/Tutorials/i);
fireEvent.click(menuItem);

expect(showModal).toHaveBeenCalledWith('tutorial-modal', expect.any(Object))
})
})
8 changes: 7 additions & 1 deletion src/tutorial/tutorial.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { showModal } from '@openmrs/esm-framework';
import { MenuItem } from '@carbon/react';
import styles from './styles.scss';

const Tutorial = () => {
const { t } = useTranslation();
Expand All @@ -13,7 +15,11 @@ const Tutorial = () => {

return (
<>
<div onClick={handleOpenModal}>{t('tutorials', 'Tutorials')}</div>
<MenuItem
onClick={handleOpenModal}
label={t('tutorials', 'Tutorials')}
className={styles.tutorialMenuItem}
/>
</>
);
};
Expand Down

0 comments on commit 994dbdb

Please sign in to comment.