File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -86,16 +86,22 @@ exports.default = function (Component) {
8686 externalError : null ,
8787 formSubmitted : false
8888 } ;
89+
8990 _this . getErrorMessage = _this . getErrorMessage . bind ( _this ) ;
9091 _this . getErrorMessages = _this . getErrorMessages . bind ( _this ) ;
9192 _this . getValue = _this . getValue . bind ( _this ) ;
93+ _this . hasValue = _this . hasValue . bind ( _this ) ;
9294 _this . isFormDisabled = _this . isFormDisabled . bind ( _this ) ;
9395 _this . isPristine = _this . isPristine . bind ( _this ) ;
96+ _this . isFormSubmitted = _this . isFormSubmitted . bind ( _this ) ;
9497 _this . isRequired = _this . isRequired . bind ( _this ) ;
98+ _this . isValidValue = _this . isValidValue . bind ( _this ) ;
9599 _this . isValid = _this . isValid . bind ( _this ) ;
96100 _this . resetValue = _this . resetValue . bind ( _this ) ;
101+ _this . setValidations = _this . setValidations . bind ( _this ) ;
97102 _this . setValue = _this . setValue . bind ( _this ) ;
98103 _this . showRequired = _this . showRequired . bind ( _this ) ;
104+ _this . showError = _this . showError . bind ( _this ) ;
99105 return _this ;
100106 }
101107
Original file line number Diff line number Diff line change @@ -59,16 +59,22 @@ export default (Component) => {
5959 externalError : null ,
6060 formSubmitted : false ,
6161 } ;
62+
6263 this . getErrorMessage = this . getErrorMessage . bind ( this ) ;
6364 this . getErrorMessages = this . getErrorMessages . bind ( this ) ;
6465 this . getValue = this . getValue . bind ( this ) ;
66+ this . hasValue = this . hasValue . bind ( this ) ;
6567 this . isFormDisabled = this . isFormDisabled . bind ( this ) ;
6668 this . isPristine = this . isPristine . bind ( this ) ;
69+ this . isFormSubmitted = this . isFormSubmitted . bind ( this ) ;
6770 this . isRequired = this . isRequired . bind ( this ) ;
71+ this . isValidValue = this . isValidValue . bind ( this ) ;
6872 this . isValid = this . isValid . bind ( this ) ;
6973 this . resetValue = this . resetValue . bind ( this ) ;
74+ this . setValidations = this . setValidations . bind ( this ) ;
7075 this . setValue = this . setValue . bind ( this ) ;
7176 this . showRequired = this . showRequired . bind ( this ) ;
77+ this . showError = this . showError . bind ( this ) ;
7278 }
7379
7480 componentWillMount ( ) {
Original file line number Diff line number Diff line change @@ -608,6 +608,43 @@ export default {
608608
609609 test . done ( ) ;
610610
611+ } ,
612+
613+ 'binds all necessary methods' : function ( test ) {
614+ const onInputRef = input => {
615+ [
616+ 'getErrorMessage' ,
617+ 'getErrorMessages' ,
618+ 'getValue' ,
619+ 'hasValue' ,
620+ 'isFormDisabled' ,
621+ 'isValid' ,
622+ 'isPristine' ,
623+ 'isFormSubmitted' ,
624+ 'isRequired' ,
625+ 'isValidValue' ,
626+ 'resetValue' ,
627+ 'setValidations' ,
628+ 'setValue' ,
629+ 'showRequired' ,
630+ 'showError' ,
631+ ] . forEach ( fnName => {
632+ const fn = input [ fnName ] ;
633+ try {
634+ fn ( ) ;
635+ } catch ( e ) {
636+ throw new Error ( `Method '${ fnName } ' isn't bound.` ) ;
637+ }
638+ } ) ;
639+
640+ test . done ( ) ;
641+ }
642+
643+ TestUtils . renderIntoDocument (
644+ < Formsy >
645+ < TestInput ref = { onInputRef } name = "name" value = "foo" />
646+ </ Formsy >
647+ ) ;
611648 }
612649
613650} ;
You can’t perform that action at this time.
0 commit comments