-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove smart camelize chore: update logic and rewrite in typescript chore: revert back to jsx chore: rename api.ts to data.ts chore: update test
- Loading branch information
1 parent
57a5036
commit 4c40485
Showing
36 changed files
with
1,506 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/components/Rubric/CriterionContainer/CriterionFeedback.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
import { shallow } from '@edx/react-unit-test-utils'; | ||
import { feedbackRequirement } from 'data/services/lms/constants'; | ||
|
||
import CriterionFeedback from './CriterionFeedback'; | ||
|
||
describe('<CriterionFeedback />', () => { | ||
const props = { | ||
criterion: { | ||
feedbackValue: 'feedback-1', | ||
feedbackIsInvalid: false, | ||
feedbackOnChange: jest.fn().mockName('feedbackOnChange'), | ||
feedbackEnabled: true, | ||
feedbackRequired: feedbackRequirement.required, | ||
}, | ||
}; | ||
describe('renders', () => { | ||
test('feedbackEnabled', () => { | ||
const wrapper = shallow(<CriterionFeedback {...props} />); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
}); | ||
|
||
test('feedbackDisabled render empty', () => { | ||
const wrapper = shallow( | ||
<CriterionFeedback | ||
{...props} | ||
criterion={{ ...props.criterion, feedbackEnabled: false }} | ||
/>, | ||
); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
expect(wrapper.isEmptyRender()).toBe(true); | ||
}); | ||
|
||
test('feedbackRequired disabled render empty', () => { | ||
const wrapper = shallow( | ||
<CriterionFeedback | ||
{...props} | ||
criterion={{ | ||
...props.criterion, | ||
feedbackRequired: feedbackRequirement.disabled, | ||
}} | ||
/>, | ||
); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
expect(wrapper.isEmptyRender()).toBe(true); | ||
}); | ||
|
||
test('feedbackRequired: optional', () => { | ||
const wrapper = shallow( | ||
<CriterionFeedback | ||
{...props} | ||
criterion={{ | ||
...props.criterion, | ||
feedbackRequired: feedbackRequirement.optional, | ||
}} | ||
/>, | ||
); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
expect(wrapper.instance.findByType('Form.Control')[0].props.floatingLabel).toContain('Optional'); | ||
}); | ||
|
||
test('feedbackIsInvalid', () => { | ||
const wrapper = shallow( | ||
<CriterionFeedback | ||
{...props} | ||
criterion={{ ...props.criterion, feedbackIsInvalid: true }} | ||
/>, | ||
); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
expect(wrapper.instance.findByType('Form.Control.Feedback')[0].props.type).toBe('invalid'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/components/Rubric/CriterionContainer/RadioCriterion.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react'; | ||
import { shallow } from '@edx/react-unit-test-utils'; | ||
|
||
import RadioCriterion from './RadioCriterion'; | ||
|
||
describe('<RadioCriterion />', () => { | ||
const props = { | ||
isGrading: true, | ||
criterion: { | ||
name: 'criterion-1', | ||
optionsValue: 'option-1', | ||
optionsIsInvalid: true, | ||
optionsOnChange: jest.fn().mockName('optionsOnChange'), | ||
options: [ | ||
{ | ||
name: 'option-1', | ||
description: 'description-1', | ||
points: 1, | ||
}, | ||
{ | ||
name: 'option-2', | ||
description: 'description-2', | ||
points: 2, | ||
}, | ||
], | ||
}, | ||
}; | ||
describe('renders', () => { | ||
test('options is invalid', () => { | ||
const wrapper = shallow(<RadioCriterion {...props} />); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
|
||
expect(wrapper.instance.findByType('Form.Radio').length).toEqual( | ||
props.criterion.options.length, | ||
); | ||
wrapper.instance.findByType('Form.Radio').forEach((radio) => { | ||
expect(radio.props.disabled).toEqual(false); | ||
}); | ||
expect( | ||
wrapper.instance.findByType('Form.Control.Feedback')[0].props.type, | ||
).toEqual('invalid'); | ||
}); | ||
|
||
test('options is valid no invalid feedback get render', () => { | ||
const wrapper = shallow( | ||
<RadioCriterion | ||
{...props} | ||
criterion={{ ...props.criterion, optionsIsInvalid: false }} | ||
/>, | ||
); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
|
||
expect( | ||
wrapper.instance.findByType('Form.Control.Feedback').length, | ||
).toEqual(0); | ||
}); | ||
|
||
test('not isGrading all radios will be disabled', () => { | ||
const wrapper = shallow(<RadioCriterion {...props} isGrading={false} />); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
|
||
wrapper.instance.findByType('Form.Radio').forEach((radio) => { | ||
expect(radio.props.disabled).toEqual(true); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/components/Rubric/CriterionContainer/ReviewCriterion.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { shallow } from '@edx/react-unit-test-utils'; | ||
|
||
import ReviewCriterion from './ReviewCriterion'; | ||
|
||
describe('<ReviewCriterion />', () => { | ||
const props = { | ||
criterion: { | ||
options: [ | ||
{ | ||
name: 'option-1', | ||
description: 'description-1', | ||
points: 1, | ||
}, | ||
{ | ||
name: 'option-2', | ||
description: 'description-2', | ||
points: 2, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
test('renders', () => { | ||
const wrapper = shallow(<ReviewCriterion {...props} />); | ||
expect(wrapper.snapshot).toMatchSnapshot(); | ||
expect(wrapper.instance.findByType('FormControlFeedback').length).toEqual(props.criterion.options.length); | ||
}); | ||
}); |
Oops, something went wrong.