Skip to content

Commit

Permalink
fix(panel): return value from dispose (#3895)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss authored Jun 27, 2019
1 parent d737196 commit bceb78f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/widgets/panel/__tests__/panel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,19 @@ describe('Lifecycle', () => {
expect(widget.render).toHaveBeenCalledTimes(1);
expect(widget.dispose).toHaveBeenCalledTimes(1);
});

test('returns the `state` from the widget dispose function', () => {
const widget = {
dispose: jest.fn(() => 'nextState'),
};
const widgetFactory = () => widget;

const widgetWithPanel = panel()(widgetFactory)({
container: document.createElement('div'),
});

const nextState = widgetWithPanel.dispose({});

expect(nextState).toBe('nextState');
});
});
4 changes: 3 additions & 1 deletion src/widgets/panel/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ export default function panel({
unmountComponentAtNode(getContainerNode(container));

if (typeof widget.dispose === 'function') {
widget.dispose.call(this, ...args);
return widget.dispose.call(this, ...args);
}

return undefined;
},
render(...args) {
const [options] = args;
Expand Down

0 comments on commit bceb78f

Please sign in to comment.