fix: when there is no options, the validation should be valid
This commit is contained in:
committed by
leangseu-edx
parent
3e685be116
commit
a07d6f9b80
@@ -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 !== '',
|
||||
})),
|
||||
);
|
||||
|
||||
|
||||
@@ -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: '' };
|
||||
@@ -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]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user