Skip to content

Commit

Permalink
Add GroupByOrgActionMenuItem Component
Browse files Browse the repository at this point in the history
  • Loading branch information
azizjonnurov committed Jan 6, 2025
1 parent 76eca3b commit 0f0bef5
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

import {
Button,
Icon,
} from '@folio/stripes/components';

export const GroupByOrgActionMenuItem = ({
onClick,
}) => {
return (
<Button
data-testid="group-by-org-button"
buttonStyle="dropdownItem"
onClick={onClick}
>
<Icon icon="house">
<FormattedMessage id="stripes-acq-components.claiming.action.groupByOrganization" />
</Icon>
</Button>
);
};

GroupByOrgActionMenuItem.propTypes = {
onClick: PropTypes.func.isRequired,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
render,
screen,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { GroupByOrgActionMenuItem } from './GroupByOrgActionMenuItem';

const defaultProps = {
onClick: jest.fn(),
};

const renderComponent = (props = {}) => render(
<GroupByOrgActionMenuItem
{...defaultProps}
{...props}
/>,
);

describe('GroupByOrgActionMenuItem', () => {
afterEach(() => {
jest.clearAllMocks();
});

it('should render the button', () => {
renderComponent();

expect(screen.getByTestId('group-by-org-button')).toBeInTheDocument();
});

it('should call onClick when button is clicked', async () => {
renderComponent();

await userEvent.click(screen.getByTestId('group-by-org-button'));

expect(defaultProps.onClick).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { GroupByOrgActionMenuItem } from './GroupByOrgActionMenuItem';
1 change: 1 addition & 0 deletions lib/claiming/components/menu-items/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { DelayClaimActionMenuItem } from './DelayClaimActionMenuItem';
export { MarkUnreceivableActionMenuItem } from './MarkUnreceivableActionMenuItem';
export { SendClaimActionMenuItem } from './SendClaimActionMenuItem';
export { GroupByOrgActionMenuItem } from './GroupByOrgActionMenuItem';
1 change: 1 addition & 0 deletions translations/stripes-acq-components/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"receiving.itemStatus.Order closed": "Order closed",
"receiving.itemStatus.Undefined": "Undefined",

"claiming.action.groupByOrganization": "Group by organization",
"claiming.action.sendClaim": "Send claim",
"claiming.action.delayClaim": "Delay claim",
"claiming.action.unreceivable": "Unreceivable",
Expand Down

0 comments on commit 0f0bef5

Please sign in to comment.