Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: enzyme testing replaced by react tester #35809

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Button } from '@edx/paragon';
import BlockBrowserContainer from 'BlockBrowser/components/BlockBrowser/BlockBrowserContainer';
import { Provider } from 'react-redux';
import { shallow } from 'enzyme';
// import { shallow } from 'enzyme';
import React from 'react';
import renderer from 'react-test-renderer';
import store from '../../data/store';
Expand Down Expand Up @@ -76,21 +76,50 @@ describe('ProblemBrowser Main component', () => {
expect(fetchCourseBlocksMock.mock.calls.length).toBe(1);
});

// test('display dropdown on toggling dropdown', () => {
// const component = shallow(
// <Main
// courseId={courseId}
// createProblemResponsesReportTask={jest.fn()}
// excludeBlockTypes={excludedBlockTypes}
// fetchCourseBlocks={jest.fn()}
// problemResponsesEndpoint={problemResponsesEndpoint}
// onSelectBlock={jest.fn()}
// selectedBlock="some-selected-block"
// taskStatusEndpoint={taskStatusEndpoint}
// />,
// );
// expect(component.find(BlockBrowserContainer).length).toBeFalsy();
// component.find(Button).find({ label: 'Select a section or problem' }).simulate('click');
// expect(component.find(BlockBrowserContainer).length).toBeTruthy();
// });

test('display dropdown on toggling dropdown', () => {
const component = shallow(
<Main
courseId={courseId}
createProblemResponsesReportTask={jest.fn()}
excludeBlockTypes={excludedBlockTypes}
fetchCourseBlocks={jest.fn()}
problemResponsesEndpoint={problemResponsesEndpoint}
onSelectBlock={jest.fn()}
selectedBlock="some-selected-block"
taskStatusEndpoint={taskStatusEndpoint}
/>,
);
expect(component.find(BlockBrowserContainer).length).toBeFalsy();
component.find(Button).find({ label: 'Select a section or problem' }).simulate('click');
expect(component.find(BlockBrowserContainer).length).toBeTruthy();
let component;
act(() => {
component = create(
<Main
courseId={courseId}
createProblemResponsesReportTask={jest.fn()}
excludeBlockTypes={excludedBlockTypes}
fetchCourseBlocks={jest.fn()}
problemResponsesEndpoint={problemResponsesEndpoint}
onSelectBlock={jest.fn()}
selectedBlock="some-selected-block"
taskStatusEndpoint={taskStatusEndpoint}
/>
);
});

const root = component.root;

expect(() => root.findByType(BlockBrowserContainer)).toThrow();

const button = root.findByProps({ label: 'Select a section or problem' });
act(() => {
button.props.onClick();
});

expect(() => root.findByType(BlockBrowserContainer)).not.toThrow();
});
});