File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -268,5 +268,35 @@ describe('<UIView>', () => {
268
268
await router . stateService . go ( 'withrenderprop' ) ;
269
269
expect ( wrapper . html ( ) ) . toEqual ( `<div><span>withrenderprop</span><span>bar</span></div>` ) ;
270
270
} ) ;
271
+
272
+ it ( 'unmounts the State Component when calling stateService.reload(true)' , async ( ) => {
273
+ const componentDidMountWatcher = jest . fn ( ) ;
274
+ const componentWillUnmountWatcher = jest . fn ( ) ;
275
+ class TestUnmountComponent extends React . Component {
276
+ componentDidMount ( ) {
277
+ componentDidMountWatcher ( ) ;
278
+ }
279
+ componentWillUnmount ( ) {
280
+ componentWillUnmountWatcher ( ) ;
281
+ }
282
+ render ( ) {
283
+ return < div /> ;
284
+ }
285
+ }
286
+ const testState = {
287
+ name : 'testunmount' ,
288
+ component : TestUnmountComponent ,
289
+ } ;
290
+ router . stateRegistry . register ( testState ) ;
291
+ const wrapper = mount (
292
+ < UIRouter router = { router } >
293
+ < UIView />
294
+ </ UIRouter > ,
295
+ ) ;
296
+ await router . stateService . go ( 'testunmount' ) ;
297
+ await router . stateService . reload ( 'testunmount' ) ;
298
+ expect ( componentDidMountWatcher ) . toHaveBeenCalledTimes ( 2 ) ;
299
+ expect ( componentWillUnmountWatcher ) . toHaveBeenCalledTimes ( 1 ) ;
300
+ } ) ;
271
301
} ) ;
272
302
} ) ;
You can’t perform that action at this time.
0 commit comments