test: replacing snapshot tests with RTL tests part 11 (#2214)

This commit is contained in:
jacobo-dominguez-wgu
2025-06-24 04:04:03 -06:00
committed by GitHub
parent 31fc0453b4
commit 71fa247c61
14 changed files with 185 additions and 465 deletions

View File

@@ -1,36 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CourseUnitHeaderActionsSlot pluginProps are set correctly 1`] = `
<PluginSlot
id="org.openedx.frontend.authoring.course_unit_header_actions.v1"
idAliases={
[
"course_unit_header_actions_slot",
]
}
pluginProps={
{
"category": "vertical",
"headerNavigationsActions": {
"handleEdit": [MockFunction],
"handlePreview": [MockFunction],
"handleViewLive": [MockFunction],
},
"isUnitVerticalType": true,
"unitTitle": "Mock Unit",
"verticalBlocks": [],
}
}
>
<HeaderNavigations
category="vertical"
headerNavigationsActions={
{
"handleEdit": [MockFunction],
"handlePreview": [MockFunction],
"handleViewLive": [MockFunction],
}
}
/>
</PluginSlot>
`;

View File

@@ -1,7 +1,7 @@
import { shallow } from '@edx/react-unit-test-utils';
import { render, initializeMocks } from '@src/testUtils';
import renderer from 'react-test-renderer';
import { COURSE_BLOCK_NAMES } from 'CourseAuthoring/constants';
import { COURSE_BLOCK_NAMES } from '@src/constants';
import CourseUnitHeaderActionsSlot from '.';
jest.mock('CourseAuthoring/course-unit/header-navigations/HeaderNavigations', () => 'HeaderNavigations');
@@ -19,15 +19,18 @@ const headerNavProps = {
},
category: 'vertical',
unitTitle: 'Mock Unit',
isUnitVerticalType: false,
verticalBlocks: [],
};
describe('CourseUnitHeaderActionsSlot', () => {
beforeEach(() => jest.resetAllMocks());
beforeEach(() => initializeMocks());
test('pluginProps are set correctly', () => {
const wrapper = shallow(<CourseUnitHeaderActionsSlot unitTitle="Mock Title" verticalBlocks={[]} {...headerNavProps} />);
expect(wrapper.snapshot).toMatchSnapshot();
const { container } = render(<CourseUnitHeaderActionsSlot {...headerNavProps} />);
expect(container.querySelector('pluginslot')).toBeInTheDocument();
expect(container.querySelector('headernavigations')).toBeInTheDocument();
expect(container.querySelector('headernavigations')?.getAttribute('category')).toBe('vertical');
});
test('isUnitVerticalType is set correctly', () => {