Skip to content

Commit

Permalink
fix: remove MockErrorBoundary
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxFrank13 committed Oct 23, 2024
1 parent a6d63d0 commit c3c816c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 62 deletions.
24 changes: 11 additions & 13 deletions src/plugins/PluginContainer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
import React from 'react';
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import { IntlProvider } from '@edx/frontend-platform/i18n';

import PluginContainer from './PluginContainer';
import { IFRAME_PLUGIN, DIRECT_PLUGIN } from './data/constants';
import PluginContainerDirect from './PluginContainerDirect';
import MockErrorBoundary from '../test/MockErrorBoundary';

jest.mock('./PluginContainerIframe', () => jest.fn(() => 'Iframe plugin'));

jest.mock('./PluginContainerDirect', () => jest.fn(() => 'Direct plugin'));

jest.mock('@edx/frontend-platform/react', () => ({
...jest.requireActual,
ErrorBoundary: (props) => <MockErrorBoundary {...props} />,
jest.mock('@edx/frontend-platform/i18n', () => ({
getLocale: jest.fn(),
getMessages: jest.fn(),
FormattedMessage: ({ defaultMessage }) => defaultMessage,
IntlProvider: ({ children }) => <div>{children}</div>,
}));

jest.mock('@edx/frontend-platform/logging', () => ({
Expand All @@ -29,12 +29,10 @@ const mockConfig = {

function PluginContainerWrapper({ type = DIRECT_PLUGIN, config = mockConfig, slotErrorFallbackComponent }) {
return (
<IntlProvider locale="en">
<PluginContainer
config={{ type, ...config }}
slotErrorFallbackComponent={slotErrorFallbackComponent}
/>
</IntlProvider>
<PluginContainer
config={{ type, ...config }}
slotErrorFallbackComponent={slotErrorFallbackComponent}
/>
);
}

Expand Down Expand Up @@ -96,8 +94,8 @@ describe('PluginContainer', () => {
});

it('renders default fallback <ErrorPage /> when there is no fallback set in configuration', () => {
const { getByText } = render(<PluginContainerWrapper />);
expect(getByText('Try again')).toBeInTheDocument();
const { getByRole } = render(<PluginContainerWrapper />);
expect(getByRole('button', { name: 'Try again' })).toBeInTheDocument();
});
});
});
49 changes: 0 additions & 49 deletions src/test/MockErrorBoundary.jsx

This file was deleted.

0 comments on commit c3c816c

Please sign in to comment.