Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(async () => {
context0 = await initNotebookContext();
panel0 = NBTestUtils.createNotebookPanel(context0);
NBTestUtils.populateNotebook(panel0.content);
context1 = await initNotebookContext();
panel1 = NBTestUtils.createNotebookPanel(context1);
NBTestUtils.populateNotebook(panel1.content);
tracker = new NotebookTracker({ namespace: 'notebook' });
await tracker.add(panel0);
await tracker.add(panel1);
notebookTools = new NotebookTools({ tracker });
tabpanel = new TabPanel();
tabpanel.addWidget(panel0);
tabpanel.addWidget(panel1);
tabpanel.addWidget(notebookTools);
tabpanel.node.style.height = '800px';
Widget.attach(tabpanel, document.body);
// Give the posted messages a chance to be handled.
await sleep();
});
beforeEach(async () => {
context0 = await initNotebookContext();
panel0 = NBTestUtils.createNotebookPanel(context0);
NBTestUtils.populateNotebook(panel0.content);
context1 = await initNotebookContext();
panel1 = NBTestUtils.createNotebookPanel(context1);
NBTestUtils.populateNotebook(panel1.content);
tracker = new NotebookTracker({ namespace: 'notebook' });
await tracker.add(panel0);
await tracker.add(panel1);
notebookTools = new NotebookTools({ tracker });
tabpanel = new TabPanel();
tabpanel.addWidget(panel0);
tabpanel.addWidget(panel1);
tabpanel.addWidget(notebookTools);
tabpanel.node.style.height = '800px';
Widget.attach(tabpanel, document.body);
// Give the posted messages a chance to be handled.
await sleep();
it('should be safe to call more than once', () => {
const panel = NBTestUtils.createNotebookPanel(context);
panel.dispose();
panel.dispose();
expect(panel.isDisposed).to.equal(true);
});
});
it('should get the document context for the widget', () => {
const panel = NBTestUtils.createNotebookPanel(context);
expect(panel.context).to.equal(context);
});
});
it('should be the toolbar used by the widget', () => {
const panel = NBTestUtils.createNotebookPanel(context);
expect(panel.toolbar).to.be.an.instanceof(Toolbar);
});
});
it('should emit a signal when the active cell changes', async () => {
const tracker = new NotebookTracker({ namespace });
const panel = NBTestUtils.createNotebookPanel(context);
let count = 0;
tracker.activeCellChanged.connect(() => {
count++;
});
panel.content.model!.fromJSON(NBTestUtils.DEFAULT_CONTENT);
await tracker.add(panel);
expect(count).to.equal(1);
panel.content.activeCellIndex = 1;
expect(count).to.equal(2);
panel.dispose();
});
});
it('should be the notebook content widget', () => {
const panel = NBTestUtils.createNotebookPanel(context);
expect(panel.content).to.be.an.instanceof(Notebook);
});
});
beforeEach(async () => {
context = await initNotebookContext();
panel = NBTestUtils.createNotebookPanel(context);
context.model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
});
beforeEach(async () => {
context = await initNotebookContext({ startKernel: true });
panel = NBTestUtils.createNotebookPanel(context);
context.model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
});
beforeEach(async () => {
context = await createNotebookContext();
await context.initialize(true);
panel = NBTestUtils.createNotebookPanel(context);
context.model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
});