Skip to content

Commit

Permalink
fix: proptypes
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Mar 2, 2024
1 parent a6e2771 commit da9fd27
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/course-outline/card-header/CardHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,13 @@ CardHeader.defaultProps = {
discussionEnabled: false,
discussionsSettings: {},
parentInfo: {},
cardId: '',
};

CardHeader.propTypes = {
title: PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
cardId: PropTypes.string.isRequired,
cardId: PropTypes.string,
hasChanges: PropTypes.bool.isRequired,
onClickPublish: PropTypes.func.isRequired,
onClickConfigure: PropTypes.func.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/course-outline/card-header/StatusBadge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ StatusBadge.defaultProps = {

StatusBadge.propTypes = {
text: PropTypes.string,
icon: PropTypes.string,
icon: PropTypes.func,
iconClassName: PropTypes.string,
};

Expand Down
6 changes: 5 additions & 1 deletion src/course-outline/section-card/SectionCard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let store;
const section = {
id: '123',
displayName: 'Section Name',
category: 'chapter',
published: true,
visibilityState: 'live',
hasChanges: false,
Expand All @@ -38,17 +39,20 @@ const renderComponent = (props) => render(
<IntlProvider locale="en">
<SectionCard
section={section}
index="1"
index={1}
canMoveItem={jest.fn()}
onOrderChange={jest.fn()}
onOpenPublishModal={jest.fn()}
onOpenHighlightsModal={jest.fn()}
onOpenDeleteModal={jest.fn()}
onOpenConfigureModal={jest.fn()}
savingStatus=""
onEditSectionSubmit={onEditSectionSubmit}
onDuplicateSubmit={jest.fn()}
isSectionsExpanded
onNewSubsectionSubmit={jest.fn()}
isSelfPaced={false}
isCustomRelativeDatesActive={false}
{...props}
>
<span>children</span>
Expand Down
11 changes: 9 additions & 2 deletions src/course-outline/subsection-card/SubsectionCard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const section = {
const subsection = {
id: '123',
displayName: 'Subsection Name',
category: 'sequential',
published: true,
visibilityState: 'live',
hasChanges: false,
Expand All @@ -47,6 +48,7 @@ const subsection = {
duplicable: true,
},
isHeaderVisible: true,
releasedToStudents: true,
};

const onEditSubectionSubmit = jest.fn();
Expand All @@ -58,17 +60,22 @@ const renderComponent = (props, entry = '/') => render(
<SubsectionCard
section={section}
subsection={subsection}
index="1"
canMoveItem={jest.fn()}
index={1}
isSelfPaced={false}
getPossibleMoves={jest.fn()}
onOrderChange={jest.fn()}
onOpenPublishModal={jest.fn()}
onOpenHighlightsModal={jest.fn()}
onOpenDeleteModal={jest.fn()}
onNewUnitSubmit={jest.fn()}
isCustomRelativeDatesActive={false}
onEditClick={jest.fn()}
savingStatus=""
onEditSubmit={onEditSubectionSubmit}
onDuplicateSubmit={jest.fn()}
namePrefix="subsection"
onOpenConfigureModal={jest.fn()}
onPasteClick={jest.fn()}
{...props}
>
<span>children</span>
Expand Down
9 changes: 7 additions & 2 deletions src/course-outline/unit-card/UnitCard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const subsection = {
const unit = {
id: '123',
displayName: 'unit Name',
category: 'vertical',
published: true,
visibilityState: 'live',
hasChanges: false,
Expand All @@ -55,15 +56,19 @@ const renderComponent = (props) => render(
section={section}
subsection={subsection}
unit={unit}
index="1"
canMoveItem={jest.fn()}
index={1}
getPossibleMoves={jest.fn()}
onOrderChange={jest.fn()}
onOpenPublishModal={jest.fn()}
onOpenDeleteModal={jest.fn()}
onOpenConfigureModal={jest.fn()}
onCopyToClipboardClick={jest.fn()}
savingStatus=""
onEditSubmit={jest.fn()}
onDuplicateSubmit={jest.fn()}
getTitleLink={(id) => `/some/${id}`}
isSelfPaced={false}
isCustomRelativeDatesActive={false}
{...props}
/>
</IntlProvider>,
Expand Down
4 changes: 2 additions & 2 deletions src/course-outline/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const getItemStatusBadgeContent = (status, messages, intl) => {
case ITEM_BADGE_STATUS.publishedNotLive:
return {
badgeTitle: intl.formatMessage(messages.statusBadgePublishedNotLive),
badgeIcon: '',
badgeIcon: null,
};
case ITEM_BADGE_STATUS.staffOnly:
return {
Expand All @@ -81,7 +81,7 @@ const getItemStatusBadgeContent = (status, messages, intl) => {
default:
return {
badgeTitle: '',
badgeIcon: '',
badgeIcon: null,
};
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/course-outline/xblock-status/GradingPolicyAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ const GradingPolicyAlert = ({
GradingPolicyAlert.defaultProps = {
graded: false,
gradingType: '',
courseGraders: [],
};

GradingPolicyAlert.propTypes = {
graded: PropTypes.bool,
gradingType: PropTypes.string,
courseGraders: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
courseGraders: PropTypes.arrayOf(PropTypes.string.isRequired),
};

export default GradingPolicyAlert;
6 changes: 4 additions & 2 deletions src/course-outline/xblock-status/ReleaseStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ const ReleaseStatus = ({

ReleaseStatus.defaultProps = {
explanatoryMessage: '',
releaseDate: '',
releasedToStudents: false,
};

ReleaseStatus.propTypes = {
isInstructorPaced: PropTypes.bool.isRequired,
explanatoryMessage: PropTypes.string,
releaseDate: PropTypes.string.isRequired,
releasedToStudents: PropTypes.bool.isRequired,
releaseDate: PropTypes.string,
releasedToStudents: PropTypes.bool,
};

export default ReleaseStatus;
7 changes: 4 additions & 3 deletions src/course-outline/xblock-status/StatusMessages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ StatusMessages.defaultProps = {
prereq: '',
prereqs: [],
userPartitionInfo: {},
hasPartitionGroupComponents: false,
};

StatusMessages.propTypes = {
Expand All @@ -79,10 +80,10 @@ StatusMessages.propTypes = {
blockDisplayName: PropTypes.string.isRequired,
})),
userPartitionInfo: PropTypes.shape({
selectedPartitionIndex: PropTypes.number.isRequired,
selectedGroupsLabel: PropTypes.string.isRequired,
selectedPartitionIndex: PropTypes.number,
selectedGroupsLabel: PropTypes.string,
}),
hasPartitionGroupComponents: PropTypes.bool.isRequired,
hasPartitionGroupComponents: PropTypes.bool,
};

export default StatusMessages;
12 changes: 6 additions & 6 deletions src/course-outline/xblock-status/XBlockStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ XBlockStatus.propTypes = {
blockData: PropTypes.shape({
category: PropTypes.string.isRequired,
explanatoryMessage: PropTypes.string,
releasedToStudents: PropTypes.bool.isRequired,
releaseDate: PropTypes.string.isRequired,
releasedToStudents: PropTypes.bool,
releaseDate: PropTypes.string,
isProctoredExam: PropTypes.bool,
isOnboardingExam: PropTypes.bool,
isPracticeExam: PropTypes.bool,
Expand All @@ -105,16 +105,16 @@ XBlockStatus.propTypes = {
})),
staffOnlyMessage: PropTypes.bool,
userPartitionInfo: PropTypes.shape({
selectedPartitionIndex: PropTypes.number.isRequired,
selectedGroupsLabel: PropTypes.string.isRequired,
selectedPartitionIndex: PropTypes.number,
selectedGroupsLabel: PropTypes.string,
}),
hasPartitionGroupComponents: PropTypes.bool.isRequired,
hasPartitionGroupComponents: PropTypes.bool,
format: PropTypes.string,
dueDate: PropTypes.string,
relativeWeeksDue: PropTypes.number,
isTimeLimited: PropTypes.bool,
graded: PropTypes.bool,
courseGraders: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
courseGraders: PropTypes.arrayOf(PropTypes.string.isRequired),
hideAfterDue: PropTypes.bool,
}).isRequired,
};
Expand Down

0 comments on commit da9fd27

Please sign in to comment.