@@ -106,6 +106,34 @@ describe('ReactPropTypes', () => {
106106 ReactTestUtils = require ( 'ReactTestUtils' ) ;
107107 } ) ;
108108
109+ describe ( 'checkPropTypes' , ( ) => {
110+ it ( 'does not return a value from a validator' , ( ) => {
111+ spyOn ( console , 'error' ) ;
112+ const propTypes = {
113+ foo ( props , propName , componentName ) {
114+ return new Error ( 'some error' ) ;
115+ } ,
116+ } ;
117+ const props = { foo : 'foo' } ;
118+ const returnValue = PropTypes . checkPropTypes ( propTypes , props , 'prop' , 'testComponent' , true ) ;
119+ expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain ( 'some error' ) ;
120+ expect ( returnValue ) . toBe ( undefined ) ;
121+ } ) ;
122+
123+ it ( 'does not throw if validator throws' , ( ) => {
124+ spyOn ( console , 'error' ) ;
125+ const propTypes = {
126+ foo ( props , propName , componentName ) {
127+ throw new Error ( 'some error' ) ;
128+ } ,
129+ } ;
130+ const props = { foo : 'foo' } ;
131+ const returnValue = PropTypes . checkPropTypes ( propTypes , props , 'prop' , 'testComponent' , true ) ;
132+ expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain ( 'some error' ) ;
133+ expect ( returnValue ) . toBe ( undefined ) ;
134+ } ) ;
135+ } ) ;
136+
109137 describe ( 'Primitive Types' , ( ) => {
110138 it ( 'should warn for invalid strings' , ( ) => {
111139 typeCheckFail (
0 commit comments