Skip to content

Commit

Permalink
Merge pull request #76 from rstgroup/fixExportsAndErrorsContainer
Browse files Browse the repository at this point in the history
fix exports and ErrorsContainer
  • Loading branch information
mprzodala authored Mar 20, 2019
2 parents 34cc7d6 + 08dc006 commit ab12779
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/components/ErrorsContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const parseErrors = (data) => {

class ErrorsContainer extends Component {
getErrors() {
const { getAllErrors } = this.context;
return parseErrors(getAllErrors());
const { getAllValidationErrors } = this.context;
return parseErrors(getAllValidationErrors());
}
render() {
const errors = this.getErrors();
Expand All @@ -50,7 +50,7 @@ class ErrorsContainer extends Component {
}

ErrorsContainer.contextTypes = {
getAllErrors: PropTypes.func,
getAllValidationErrors: PropTypes.func,
};

export default ErrorsContainer;
1 change: 1 addition & 0 deletions src/components/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export { default as fieldsRestyle } from './FieldsRestyle';
export { default as FormEventsEmitter } from './FormEventsEmitter';
export { default as ErrorField } from './ErrorField';
export { default as ErrorsContainer } from './ErrorsContainer';
export { default as FormController } from './FormController';
3 changes: 3 additions & 0 deletions src/components/separate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ export {SelectField} from '../SelectField';
export {NumberField} from '../NumberField';
export {DateField} from '../DateField';
export {CheckboxField} from '../CheckboxField';
export {RadioField} from '../RadioField';
export {ObjectField} from '../ObjectField';
export {ListField} from '../ListField';
export {ErrorField} from '../ErrorField';
export {ErrorsContainer} from '../ErrorsContainer';
12 changes: 6 additions & 6 deletions tests/unit/ErrorsContainer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('ErrorsContainer', () => {

it('should prepare errors list properly', () => {
const context = {
getAllErrors: () => errors,
getAllValidationErrors: () => errors,
};
const wrapper = mount(<ErrorsContainer />, { context });
expect(wrapper.find(ErrorField).props().errors.length).toBe(3);
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('ErrorsContainer', () => {
},
};
const context = {
getAllErrors: () => listFieldErrors,
getAllValidationErrors: () => listFieldErrors,
};
const wrapper = mount(<ErrorsContainer />, { context });
expect(wrapper.find(ErrorField).props().errors).toEqual(availableErrors);
Expand All @@ -81,7 +81,7 @@ describe('ErrorsContainer', () => {
'error1',
];
const context = {
getAllErrors: () => errorsArray,
getAllValidationErrors: () => errorsArray,
};
const wrapper = mount(<ErrorsContainer />, { context });
expect(wrapper.find(ErrorField).props().errors).toEqual(errorsArray);
Expand All @@ -90,23 +90,23 @@ describe('ErrorsContainer', () => {
it('should prepare errors list properly when errors data is string', () => {
const errorsArray = ['error0'];
const context = {
getAllErrors: () => errorsArray[0],
getAllValidationErrors: () => errorsArray[0],
};
const wrapper = mount(<ErrorsContainer />, { context });
expect(wrapper.find(ErrorField).props().errors).toEqual(errorsArray);
});

it('should prepare errors list properly when errors data is undefined', () => {
const context = {
getAllErrors: () => undefined,
getAllValidationErrors: () => undefined,
};
const wrapper = mount(<ErrorsContainer />, { context });
expect(wrapper.find(ErrorField).props().errors).toEqual([]);
});

it('should pass ErrorComponent prop to ErrorField', () => {
const context = {
getAllErrors: () => errors,
getAllValidationErrors: () => errors,
};
const ErrorComponent = () => (
<div>error</div>
Expand Down

0 comments on commit ab12779

Please sign in to comment.