test: Deprecate react-unit-test-utils 3/15 (#655)

This commit is contained in:
Diana Villalvazo
2025-06-17 18:00:44 -06:00
committed by GitHub
parent b0daefa2bf
commit 5c4dfd5de3
6 changed files with 185 additions and 159 deletions

View File

@@ -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>
`;

View File

@@ -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();
});
});