Skip to content

Commit

Permalink
test: deserializer for container widget
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Mar 28, 2023
1 parent db730df commit 022b454
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/base/test/src/widget_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ describe('serialize/deserialize', function () {
model_id: 'widgetChild',
});

this.widgetChild2 = await this.manager.new_widget({
model_name: 'WidgetModel',
model_module: '@jupyter-widgets/base',
model_module_version: '1.2.0',
view_name: 'WidgetView',
view_module: '@jupyter-widgets/base',
view_module_version: '1.2.0',
model_id: 'widgetChild2',
});

this.widgetContainer = await this.manager.new_widget(
{
model_name: 'ContainerWidget',
Expand Down Expand Up @@ -111,6 +121,16 @@ describe('serialize/deserialize', function () {
children: ['IPY_MODEL_widgetChild'],
});
});
it('deserializes', async function () {
const serializedState = { children: ['IPY_MODEL_widgetChild2'] };
const state = await (
this.widgetContainer.constructor as typeof WidgetModel
)._deserialize_state(serializedState, this.manager);
await this.widgetContainer.set_state(state);
expect(this.widgetContainer.get('children')).to.deep.equal([
this.widgetChild2,
]);
});
});

describe('WidgetModel', function () {
Expand Down

0 comments on commit 022b454

Please sign in to comment.