Skip to content

Commit 0f0bef5

Browse files
committed
Add GroupByOrgActionMenuItem Component
1 parent 76eca3b commit 0f0bef5

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import PropTypes from 'prop-types';
2+
import { FormattedMessage } from 'react-intl';
3+
4+
import {
5+
Button,
6+
Icon,
7+
} from '@folio/stripes/components';
8+
9+
export const GroupByOrgActionMenuItem = ({
10+
onClick,
11+
}) => {
12+
return (
13+
<Button
14+
data-testid="group-by-org-button"
15+
buttonStyle="dropdownItem"
16+
onClick={onClick}
17+
>
18+
<Icon icon="house">
19+
<FormattedMessage id="stripes-acq-components.claiming.action.groupByOrganization" />
20+
</Icon>
21+
</Button>
22+
);
23+
};
24+
25+
GroupByOrgActionMenuItem.propTypes = {
26+
onClick: PropTypes.func.isRequired,
27+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {
2+
render,
3+
screen,
4+
} from '@testing-library/react';
5+
import userEvent from '@testing-library/user-event';
6+
7+
import { GroupByOrgActionMenuItem } from './GroupByOrgActionMenuItem';
8+
9+
const defaultProps = {
10+
onClick: jest.fn(),
11+
};
12+
13+
const renderComponent = (props = {}) => render(
14+
<GroupByOrgActionMenuItem
15+
{...defaultProps}
16+
{...props}
17+
/>,
18+
);
19+
20+
describe('GroupByOrgActionMenuItem', () => {
21+
afterEach(() => {
22+
jest.clearAllMocks();
23+
});
24+
25+
it('should render the button', () => {
26+
renderComponent();
27+
28+
expect(screen.getByTestId('group-by-org-button')).toBeInTheDocument();
29+
});
30+
31+
it('should call onClick when button is clicked', async () => {
32+
renderComponent();
33+
34+
await userEvent.click(screen.getByTestId('group-by-org-button'));
35+
36+
expect(defaultProps.onClick).toHaveBeenCalled();
37+
});
38+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GroupByOrgActionMenuItem } from './GroupByOrgActionMenuItem';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { DelayClaimActionMenuItem } from './DelayClaimActionMenuItem';
22
export { MarkUnreceivableActionMenuItem } from './MarkUnreceivableActionMenuItem';
33
export { SendClaimActionMenuItem } from './SendClaimActionMenuItem';
4+
export { GroupByOrgActionMenuItem } from './GroupByOrgActionMenuItem';

translations/stripes-acq-components/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"receiving.itemStatus.Order closed": "Order closed",
145145
"receiving.itemStatus.Undefined": "Undefined",
146146

147+
"claiming.action.groupByOrganization": "Group by organization",
147148
"claiming.action.sendClaim": "Send claim",
148149
"claiming.action.delayClaim": "Delay claim",
149150
"claiming.action.unreceivable": "Unreceivable",

0 commit comments

Comments
 (0)