Skip to content

Commit

Permalink
UIREQMED-3: Add Search field for Mediated requests activity page
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy-Litvinenko committed Jun 20, 2024
1 parent 1454d47 commit b137ae5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ import {
} from '@folio/jest-config-stripes/testing-library/react';

import MediatedRequestsFilters from './MediatedRequestsFilters';

import {
MediatedRequestLevelFilter,
MediatedRequestStatusFilter,
Search,
} from './components';
import NavigationMenu from '../../../NavigationMenu';
import { getMediatedRequestsActivitiesUrl } from '../../../../constants';

jest.mock('./components', () => ({
MediatedRequestLevelFilter: jest.fn((props) => (<div {...props} />)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MediatedRequestLevelFilter = () => {
>
<CheckboxFilter
data-testid={`${MEDIATED_REQUEST_FILTER_TYPES.MEDIATED_REQUEST_LEVELS}Filter`}
dataOptions={transformRequestFilterOptions(MEDIATED_REQUEST_LEVEL_TRANSLATIONS, formatMessage)}
dataOptions={transformRequestFilterOptions(formatMessage, MEDIATED_REQUEST_LEVEL_TRANSLATIONS)}
name={MEDIATED_REQUEST_FILTER_TYPES.MEDIATED_REQUEST_LEVELS}
onChange={() => {}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MediatedRequestStatusFilter = () => {
>
<CheckboxFilter
data-testid={`${MEDIATED_REQUEST_FILTER_TYPES.MEDIATED_REQUEST_STATUS}Filter`}
dataOptions={transformRequestFilterOptions(MEDIATED_REQUEST_STATUS_TRANSLATIONS, formatMessage)}
dataOptions={transformRequestFilterOptions(formatMessage, MEDIATED_REQUEST_STATUS_TRANSLATIONS)}
name={MEDIATED_REQUEST_FILTER_TYPES.MEDIATED_REQUEST_STATUS}
onChange={() => {}}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/NavigationMenu/NavigationMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
getSendItemInTransitUrl,
} from '../../constants';

import styles from './NavigationMenu.css';

export const getDataOptions = (intl) => ([
{
label: intl.formatMessage({ id: 'ui-requests-mediated.app.mediatedRequestsActivities.navigation' }),
Expand Down Expand Up @@ -44,8 +46,6 @@ export const handleChangeMenu = (event, location, history) => {
history.push(destination);
};

import styles from './NavigationMenu.css';

const NavigationMenu = ({
value,
separator,
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const transformRequestFilterOptions = (source = [], formatMessage) => (
export const transformRequestFilterOptions = (formatMessage, source = []) => (
source.map(({ label, value }) => ({
label: formatMessage({ id: label }),
value,
Expand Down
19 changes: 19 additions & 0 deletions src/utils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
transformRequestFilterOptions,
} from './utils';

describe('transformRequestFilterOptions', () => {
const formatMessage = jest.fn(({ id }) => id);
const option = {
label: 'label',
value: 'value',
};

it('should return data options', () => {
expect(transformRequestFilterOptions(formatMessage, [option])).toEqual([option]);
});

it('should not return data options', () => {
expect(transformRequestFilterOptions(formatMessage)).toEqual([]);
});
});

0 comments on commit b137ae5

Please sign in to comment.