test: Deprecate react-unit-test-utils 3/15 (#655)
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`WidgetSidebar snapshots 1`] = `
|
||||
<PluginSlot
|
||||
id="org.openedx.frontend.learner_dashboard.widget_sidebar.v1"
|
||||
idAliases={
|
||||
[
|
||||
"widget_sidebar_slot",
|
||||
]
|
||||
}
|
||||
>
|
||||
<LookingForChallengeWidget />
|
||||
</PluginSlot>
|
||||
`;
|
||||
@@ -1,18 +1,26 @@
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { reduxHooks } from 'hooks';
|
||||
import WidgetSidebarSlot from '.';
|
||||
|
||||
jest.mock('widgets/LookingForChallengeWidget', () => 'LookingForChallengeWidget');
|
||||
jest.unmock('react');
|
||||
jest.unmock('@edx/frontend-platform/i18n');
|
||||
jest.unmock('@openedx/paragon');
|
||||
|
||||
jest.mock('@openedx/frontend-plugin-framework', () => ({
|
||||
PluginSlot: 'PluginSlot',
|
||||
jest.mock('hooks', () => ({
|
||||
reduxHooks: {
|
||||
usePlatformSettingsData: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('WidgetSidebar', () => {
|
||||
beforeEach(() => jest.resetAllMocks());
|
||||
const courseSearchUrl = 'mock-url';
|
||||
|
||||
test('snapshots', () => {
|
||||
const wrapper = shallow(<WidgetSidebarSlot />);
|
||||
expect(wrapper.snapshot).toMatchSnapshot();
|
||||
describe('WidgetSidebar', () => {
|
||||
it('renders PluginSlot with correct children', () => {
|
||||
reduxHooks.usePlatformSettingsData.mockReturnValueOnce({ courseSearchUrl });
|
||||
render(<IntlProvider locale="en"><WidgetSidebarSlot /></IntlProvider>);
|
||||
const pluginSlot = screen.getByText('Looking for a new challenge?');
|
||||
expect(pluginSlot).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user