File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -182,4 +182,19 @@ describe('Lifecycle', () => {
182182 expect ( widget . render ) . toHaveBeenCalledTimes ( 1 ) ;
183183 expect ( widget . dispose ) . toHaveBeenCalledTimes ( 1 ) ;
184184 } ) ;
185+
186+ test ( 'returns the `state` from the widget dispose function' , ( ) => {
187+ const widget = {
188+ dispose : jest . fn ( ( ) => 'nextState' ) ,
189+ } ;
190+ const widgetFactory = ( ) => widget ;
191+
192+ const widgetWithPanel = panel ( ) ( widgetFactory ) ( {
193+ container : document . createElement ( 'div' ) ,
194+ } ) ;
195+
196+ const nextState = widgetWithPanel . dispose ( { } ) ;
197+
198+ expect ( nextState ) . toBe ( 'nextState' ) ;
199+ } ) ;
185200} ) ;
Original file line number Diff line number Diff line change @@ -179,8 +179,10 @@ export default function panel({
179179 unmountComponentAtNode ( getContainerNode ( container ) ) ;
180180
181181 if ( typeof widget . dispose === 'function' ) {
182- widget . dispose . call ( this , ...args ) ;
182+ return widget . dispose . call ( this , ...args ) ;
183183 }
184+
185+ return undefined ;
184186 } ,
185187 render ( ...args ) {
186188 const [ options ] = args ;
You can’t perform that action at this time.
0 commit comments