Skip to content

Commit

Permalink
update tests | remove unused reactItl.mock.js | update reactIntl.mock.js
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 16, 2023
1 parent a6037d8 commit 047acd8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 45 deletions.
9 changes: 6 additions & 3 deletions src/components/BulkEditLogs/BulkEditLogs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';

import '../../../test/jest/__mock__';
import { IntlProvider } from 'react-intl';
import { bulkEditLogsData } from '../../../test/jest/__mock__/fakeData';

import { LOGS_COLUMNS } from '../../constants';
Expand All @@ -20,9 +21,11 @@ jest.mock('../../hooks/api', () => ({

const renderBulkEditLogs = () => {
render(
<MemoryRouter initialEntries={['/bulk-edit?criteria=logs']}>
<BulkEditLogs />
</MemoryRouter>,
<IntlProvider locale="en">
<MemoryRouter initialEntries={['/bulk-edit?criteria=logs']}>
<BulkEditLogs />
</MemoryRouter>,
</IntlProvider>
);
};

Expand Down
21 changes: 12 additions & 9 deletions test/jest/__mock__/reactIntl.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ jest.mock('react-intl', () => {
formatNumber: value => value,
};

const sharedMockFn = jest.fn(({
value, children,
}) => {
if (children) {
return children([value]);
}

return value;
});

return {
...jest.requireActual('react-intl'),
FormattedMessage: jest.fn(({
Expand All @@ -20,15 +30,8 @@ jest.mock('react-intl', () => {

return id;
}),
FormattedTime: jest.fn(({
value, children,
}) => {
if (children) {
return children([value]);
}

return value;
}),
FormattedTime: sharedMockFn,
FormattedNumber: sharedMockFn,
useIntl: () => intl,
injectIntl: Component => props => (
<Component
Expand Down
33 changes: 0 additions & 33 deletions test/jest/__mock__/reactItl.mock.js

This file was deleted.

0 comments on commit 047acd8

Please sign in to comment.