Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) O3-3890 Help menu (and menu items) should use a standard Carbon… #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/tutorial/styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@use '@carbon/styles/scss/spacing';
@use '@carbon/styles/scss/type';
@use '@carbon/colors';
@use '@carbon/layout';
@import '~@openmrs/esm-styleguide/src/vars';

.description {
Expand Down Expand Up @@ -28,3 +30,11 @@

}
}

.tutorialsText {
padding: layout.$spacing-03;
}

.tutorialsText:hover {
background: colors.$white-hover;
}
25 changes: 25 additions & 0 deletions src/tutorial/tutorial.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { fireEvent, render, screen } from "@testing-library/react";
import '@testing-library/jest-dom';
import { showModal } from "@openmrs/esm-framework";
import Tutorial from "./tutorial";
import userEvent from "@testing-library/user-event";

const mockShowModal = jest.mocked(showModal)

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', async() => {
render(<Tutorial />);

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

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

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

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