Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should dispose of the resources held by the widget', () => {
const widget = new MarkdownCell({ model, rendermime, contentFactory });
widget.initializeState();
widget.dispose();
expect(widget.isDisposed).toEqual(true);
});
it('should default to true', async () => {
const widget = new MarkdownCell({ model, rendermime, contentFactory });
widget.initializeState();
Widget.attach(widget, document.body);
expect(widget.rendered).toEqual(true);
await framePromise();
expect(widget.node.classList.contains(RENDERED_CLASS)).toEqual(true);
});
it('should unrender the widget', async () => {
const widget = new MarkdownCell({ model, rendermime, contentFactory });
widget.initializeState();
Widget.attach(widget, document.body);
widget.rendered = false;
await framePromise();
expect(widget.node.classList.contains(RENDERED_CLASS)).toEqual(false);
widget.dispose();
});
});
it('should be safe to call multiple times', () => {
const widget = new MarkdownCell({ model, rendermime, contentFactory });
widget.initializeState();
widget.dispose();
widget.dispose();
expect(widget.isDisposed).toEqual(true);
});
});
it('should accept a custom contentFactory', () => {
const widget = new MarkdownCell({ model, rendermime, contentFactory });
widget.initializeState();
expect(widget).toBeInstanceOf(MarkdownCell);
});
createMarkdownCell(
options: MarkdownCell.IOptions,
parent: StaticNotebook
): MarkdownCell {
if (!options.contentFactory) {
options.contentFactory = this;
}
return new MarkdownCell(options);
}
createCell(options: MarkdownCell.IOptions): MarkdownCell {
return new MarkdownCell(options);
}
}
createMarkdownCell(options: MarkdownCell.IOptions, parent: StaticNotebook): MarkdownCell {
if (!options.contentFactory) {
options.contentFactory = this;
}
return new MarkdownCell(options);
}
createCell(options: MarkdownCell.IOptions): MarkdownCell {
return new MarkdownCell(options);
}
}
createMarkdownCell(
options: MarkdownCell.IOptions,
parent: StaticNotebook
): MarkdownCell {
if (!options.contentFactory) {
options.contentFactory = this;
}
return new MarkdownCell(options).initializeState();
}