File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -119,25 +119,36 @@ Object.entries(POLYFILLS).forEach(([name, polyfill]) => {
119119 constructor ( props ) {
120120 super ( props ) ;
121121 this . state = { count : 1 } ;
122+ this . setRef = ref => {
123+ this . divRef = ref ;
124+ } ;
122125 }
123126 static getDerivedStateFromProps ( nextProps , prevState ) {
124127 return {
125128 count : prevState . count + nextProps . incrementBy ,
126129 } ;
127130 }
128131 getSnapshotBeforeUpdate ( prevProps , prevState ) {
129- return prevState . count * 2 + this . state . count * 3 ;
132+ expect ( prevProps ) . toEqual ( { incrementBy : 2 } ) ;
133+ expect ( prevState ) . toEqual ( { count : 3 } ) ;
134+ return this . divRef . textContent ;
130135 }
131136 componentDidUpdate ( prevProps , prevState , snapshot ) {
132137 expect ( prevProps ) . toEqual ( { incrementBy : 2 } ) ;
133138 expect ( prevState ) . toEqual ( { count : 3 } ) ;
134139 expect ( this . props ) . toEqual ( { incrementBy : 3 } ) ;
135140 expect ( this . state ) . toEqual ( { count : 6 } ) ;
136- expect ( snapshot ) . toBe ( 24 ) ;
141+ expect ( snapshot ) . toBe ( '3' ) ;
137142 componentDidUpdateCalled = true ;
138143 }
139144 render ( ) {
140- return React . createElement ( 'div' , null , this . state . count ) ;
145+ return React . createElement (
146+ 'div' ,
147+ {
148+ ref : this . setRef ,
149+ } ,
150+ this . state . count
151+ ) ;
141152 }
142153 }
143154
You can’t perform that action at this time.
0 commit comments