Skip to content

Commit

Permalink
test: improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Nov 12, 2024
1 parent af3b1a5 commit f8e00da
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/course-unit/__mocks__/courseSectionVertical.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,26 @@ module.exports = {
},
beta: true,
},
{
type: 'itembank',
templates: [
{
display_name: 'Problem Bank',
category: 'itembank',
boilerplate_name: null,
hinted: false,
tab: 'advanced',
support_level: true,
},
],
display_name: 'Problem Bank',
support_legend: {
show_legend: false,
allow_unsupported_xblocks: false,
documentation_label: 'Your Platform Name Here Support Levels:',
},
beta: true,
},
],
course_sequence_ids: [
'block-v1:edx+876+2030+type@sequential+block@297321078a0f4c26a50d671ed87642a6',
Expand Down
16 changes: 16 additions & 0 deletions src/course-unit/add-component/AddComponent.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ describe('<AddComponent />', () => {
}, expect.any(Function));
});

it('calls handleCreateNewCourseXBlock with correct parameters when Problem bank xblock create button is clicked', () => {
const { getByRole } = renderComponent();

const problemBankBtn = getByRole('button', {
name: new RegExp(`${messages.buttonText.defaultMessage} Problem Bank`, 'i'),
});

userEvent.click(problemBankBtn);
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalled();
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalledWith({
parentLocator: '123',
type: COMPONENT_TYPES.itembank,
category: 'itembank',
});
});

it('calls handleCreateNewCourseXBlock with correct parameters when Video xblock create button is clicked', () => {
const { getByRole } = renderComponent();

Expand Down
6 changes: 5 additions & 1 deletion src/course-unit/add-component/add-component-btn/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ const AddComponentButton = ({
);
};

AddComponentButton.defaultProps = {
beta: false,
};

AddComponentButton.propTypes = {
type: PropTypes.string.isRequired,
displayName: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
beta: PropTypes.bool.isRequired,
beta: PropTypes.bool,
};

export default AddComponentButton;
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ const ComponentModalView = ({
const isDisplaySupportLabel = supportLegend.showLegend && supportLabels[componentTemplate.supportLevel];

return (
<div className="d-flex justify-content-between w-100 mb-2.5 align-items-end">
<div
key={componentTemplate.displayName}
className="d-flex justify-content-between w-100 mb-2.5 align-items-end"
>
<Form.Radio
key={componentTemplate.displayName}
className="add-component-modal-radio"
value={value}
>
Expand Down

0 comments on commit f8e00da

Please sign in to comment.