@@ -87,6 +87,46 @@ describe('ReactTestUtils', function() {
8787 expect ( componentWillUnmount ) . toBeCalled ( ) ;
8888 } ) ;
8989
90+ it ( 'should run all lifecycle methods' , function ( ) {
91+ var componentWillMount = mocks . getMockFunction ( ) ;
92+ var componentDidMount = mocks . getMockFunction ( ) ;
93+ var componentWillReceiveProps = mocks . getMockFunction ( ) ;
94+ var shouldComponentUpdate = mocks . getMockFunction ( ) ;
95+ var componentWillUpdate = mocks . getMockFunction ( ) ;
96+ var componentDidUpdate = mocks . getMockFunction ( ) ;
97+ var componentWillUnmount = mocks . getMockFunction ( ) ;
98+
99+ var SomeComponent = React . createClass ( {
100+ render : function ( ) {
101+ return < SomeComponent onChange = { ( ) => this . setState ( { a : 1 } ) } /> ;
102+ } ,
103+ componentWillMount,
104+ componentDidMount,
105+ componentWillReceiveProps,
106+ shouldComponentUpdate ( ) {
107+ shouldComponentUpdate ( ) ;
108+ return true ;
109+ } ,
110+ componentWillUpdate,
111+ componentDidUpdate,
112+ componentWillUnmount,
113+ } ) ;
114+
115+ var shallowRenderer = ReactTestUtils . createRenderer ( ) ;
116+ shallowRenderer . render ( < SomeComponent /> ) ;
117+ shallowRenderer . getRenderOutput ( ) . props . onChange ( ) ;
118+ shallowRenderer . render ( < SomeComponent /> ) ;
119+ shallowRenderer . unmount ( ) ;
120+
121+ expect ( componentWillMount ) . toBeCalled ( ) ;
122+ expect ( componentDidMount ) . toBeCalled ( ) ;
123+ expect ( componentWillReceiveProps ) . toBeCalled ( ) ;
124+ expect ( shouldComponentUpdate ) . toBeCalled ( ) ;
125+ expect ( componentWillUpdate ) . toBeCalled ( ) ;
126+ expect ( componentDidUpdate ) . toBeCalled ( ) ;
127+ expect ( componentWillUnmount ) . toBeCalled ( ) ;
128+ } ) ;
129+
90130 it ( 'can shallow render to null' , function ( ) {
91131 var SomeComponent = React . createClass ( {
92132 render : function ( ) {
0 commit comments