Skip to content

Commit

Permalink
fix: when there is no options, the validation should be valid
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Jun 7, 2023
1 parent 3e685be commit a07d6f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/data/redux/grading/selectors/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ validation.criteria = createSelector(
criterion.feedback === feedbackRequirement.required
&& gradingData.criteria[index].feedback === ''
),
selectedOption: gradingData.criteria[index].selectedOption !== '',
selectedOption: rubricConfig.criteria[index].options.length === 0 || gradingData.criteria[index].selectedOption !== '',
})),
);

Expand Down
12 changes: 10 additions & 2 deletions src/data/redux/grading/selectors/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('validation grading selectors unit tests', () => {
expect(preSelectors).toEqual([selected.gradingData, appSelectors.rubric.config]);
});
describe('returned object', () => {
const feedbackOptional = { feedback: feedbackRequirement.optional };
const feedbackRequired = { feedback: feedbackRequirement.required };
const feedbackOptional = { feedback: feedbackRequirement.optional, options: [1] };
const feedbackRequired = { feedback: feedbackRequirement.required, options: [1] };
describe('feedback', () => {
const validFeedback = { feedback: 'Fair' };
const emptyFeedback = { feedback: '' };
Expand All @@ -85,6 +85,14 @@ describe('validation grading selectors unit tests', () => {
);
expect(output.map(({ selectedOption }) => selectedOption)).toEqual([true, false]);
});
it('returns true criteria options are empty', () => {
const emptyOptionsFeedback = { ...feedbackOptional, options: [] };
const output = cb(
{ criteria: [{ selectedOption: '' }, { selectedOption: 'Invalid' }] },
{ criteria: [emptyOptionsFeedback, emptyOptionsFeedback] },
);
expect(output.map(({ selectedOption }) => selectedOption)).toEqual([true, true]);
});
});
});
});
Expand Down

0 comments on commit a07d6f9

Please sign in to comment.