Skip to content

Commit

Permalink
change default export to named export
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Nov 8, 2023
1 parent ebbf189 commit 8f71be6
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/Donors/Donors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@folio/stripes/components';

import { defaultColumnMapping } from './constants';
import DonorsContainer from './DonorsContainer';
import { DonorsContainer } from './DonorsContainer';
import { useFetchDonors } from './hooks';

export function Donors({ name, donorOrganizationIds, ...rest }) {
Expand Down
8 changes: 3 additions & 5 deletions lib/Donors/DonorsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { useIntl } from 'react-intl';
import { useStripes } from '@folio/stripes/core';

import { defaultVisibleColumns } from './constants';
import DonorsList from './DonorsList';
import DonorsLookup from './DonorsLookup';
import { DonorsList } from './DonorsList';
import { DonorsLookup } from './DonorsLookup';
import {
getDonorsListFormatter,
getUnAssignDonorFormatter,
} from './utils';

function DonorsContainer({
export function DonorsContainer({
columnMapping,
columnWidths,
donors,
Expand Down Expand Up @@ -114,5 +114,3 @@ DonorsContainer.defaultProps = {
showTriggerButton: true,
visibleColumns: defaultVisibleColumns,
};

export default DonorsContainer;
41 changes: 24 additions & 17 deletions lib/Donors/DonorsContainer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,36 @@ import user from '@testing-library/user-event';

import stripesFinalForm from '@folio/stripes/final-form';

import DonorsContainer from './DonorsContainer';
import { DonorsContainer } from './DonorsContainer';
import { useFetchDonors } from './hooks';

const mockVendor = { id: '1', name: 'Amazon' };

jest.mock('./DonorsList', () => jest.fn(({ contentData }) => {
if (!contentData.length) {
return 'stripes-components.tableEmpty';
}

return contentData.map(({ name }) => <div key={name}>{name}</div>);
jest.mock('./DonorsList', () => ({
DonorsList: jest.fn(({ contentData }) => {
return (
<div>
{contentData.map(({ name }) => (
<div key={name}>{name}</div>
))}
</div>
);
}),
}));

jest.mock('./DonorsLookup', () => jest.fn(({ onAddDonors, name }) => {
return (
<button
type="button"
id={name}
onClick={() => onAddDonors([mockVendor])}
>
Add donor
</button>
);
jest.mock('./DonorsLookup', () => ({
DonorsLookup: jest.fn(({ onAddDonors }) => {
return (
<div>
<button
type="button"
onClick={() => onAddDonors([mockVendor])}
>
Add donor
</button>
</div>
);
}),
}));

const setDonorIds = jest.fn();
Expand Down
4 changes: 1 addition & 3 deletions lib/Donors/DonorsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
defaultVisibleColumns,
} from './constants';

const DonorsList = ({
export const DonorsList = ({
columnMapping,
columnWidths,
contentData,
Expand Down Expand Up @@ -44,5 +44,3 @@ DonorsList.defaultProps = {
formatter: defaultFormatter,
visibleColumns: defaultVisibleColumns,
};

export default DonorsList;
2 changes: 1 addition & 1 deletion lib/Donors/DonorsList.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MemoryRouter } from 'react-router-dom';
import { render, screen } from '@testing-library/react';

import DonorsList from './DonorsList';
import { DonorsList } from './DonorsList';

const defaultProps = {
contentData: [],
Expand Down
4 changes: 1 addition & 3 deletions lib/Donors/DonorsLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
visibleFilters,
} from './constants';

const DonorsLookup = ({
export const DonorsLookup = ({
name,
onAddDonors,
searchLabel,
Expand Down Expand Up @@ -60,5 +60,3 @@ DonorsLookup.defaultProps = {
searchLabel: <FormattedMessage id="stripes-acq-components.donors.button.addDonor" />,
visibleColumns: pluginVisibleColumns,
};

export default DonorsLookup;
2 changes: 1 addition & 1 deletion lib/Donors/DonorsLookup.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import user from '@testing-library/user-event';

import DonorsLookup from './DonorsLookup';
import { DonorsLookup } from './DonorsLookup';

const mockVendorData = { id: '1', name: 'Amazon' };

Expand Down
14 changes: 13 additions & 1 deletion lib/Donors/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { getDonorsListFormatter } from './utils';
import {
getDonorsListFormatter,
getUnAssignDonorFormatter,
} from './utils';

const defaultProps = {
canViewOrganizations: true,
Expand All @@ -17,6 +20,15 @@ describe('getDonorsListFormatter', () => {
expect(result).toEqual(expect.objectContaining({
name: expect.any(Function),
code: expect.any(Function),
}));
});
});

describe('getUnAssignDonorFormatter', () => {
it('should return object with name, code and unassignDonor functions', () => {
const result = getUnAssignDonorFormatter(defaultProps);

expect(result).toEqual(expect.objectContaining({
unassignDonor: expect.any(Function),
}));
});
Expand Down

0 comments on commit 8f71be6

Please sign in to comment.