From 08dc00687502704be64a251c984e6de0f29d9b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Przoda=C5=82a?= Date: Wed, 20 Mar 2019 09:41:45 +0100 Subject: [PATCH] fix exports and ErrorsContainer --- src/components/ErrorsContainer.jsx | 6 +++--- src/components/index.jsx | 1 + src/components/separate/index.js | 3 +++ tests/unit/ErrorsContainer.test.jsx | 12 ++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/ErrorsContainer.jsx b/src/components/ErrorsContainer.jsx index 1295232..a7dbe2a 100644 --- a/src/components/ErrorsContainer.jsx +++ b/src/components/ErrorsContainer.jsx @@ -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(); @@ -50,7 +50,7 @@ class ErrorsContainer extends Component { } ErrorsContainer.contextTypes = { - getAllErrors: PropTypes.func, + getAllValidationErrors: PropTypes.func, }; export default ErrorsContainer; diff --git a/src/components/index.jsx b/src/components/index.jsx index 19d7280..f6fa4e6 100644 --- a/src/components/index.jsx +++ b/src/components/index.jsx @@ -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'; diff --git a/src/components/separate/index.js b/src/components/separate/index.js index bb8b4ee..8960b87 100644 --- a/src/components/separate/index.js +++ b/src/components/separate/index.js @@ -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'; diff --git a/tests/unit/ErrorsContainer.test.jsx b/tests/unit/ErrorsContainer.test.jsx index b80facb..c9a9af7 100644 --- a/tests/unit/ErrorsContainer.test.jsx +++ b/tests/unit/ErrorsContainer.test.jsx @@ -16,7 +16,7 @@ describe('ErrorsContainer', () => { it('should prepare errors list properly', () => { const context = { - getAllErrors: () => errors, + getAllValidationErrors: () => errors, }; const wrapper = mount(, { context }); expect(wrapper.find(ErrorField).props().errors.length).toBe(3); @@ -69,7 +69,7 @@ describe('ErrorsContainer', () => { }, }; const context = { - getAllErrors: () => listFieldErrors, + getAllValidationErrors: () => listFieldErrors, }; const wrapper = mount(, { context }); expect(wrapper.find(ErrorField).props().errors).toEqual(availableErrors); @@ -81,7 +81,7 @@ describe('ErrorsContainer', () => { 'error1', ]; const context = { - getAllErrors: () => errorsArray, + getAllValidationErrors: () => errorsArray, }; const wrapper = mount(, { context }); expect(wrapper.find(ErrorField).props().errors).toEqual(errorsArray); @@ -90,7 +90,7 @@ 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(, { context }); expect(wrapper.find(ErrorField).props().errors).toEqual(errorsArray); @@ -98,7 +98,7 @@ describe('ErrorsContainer', () => { it('should prepare errors list properly when errors data is undefined', () => { const context = { - getAllErrors: () => undefined, + getAllValidationErrors: () => undefined, }; const wrapper = mount(, { context }); expect(wrapper.find(ErrorField).props().errors).toEqual([]); @@ -106,7 +106,7 @@ describe('ErrorsContainer', () => { it('should pass ErrorComponent prop to ErrorField', () => { const context = { - getAllErrors: () => errors, + getAllValidationErrors: () => errors, }; const ErrorComponent = () => (
error