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 change the selected cell type(s)', () => {
let next = widget.widgets[1];
widget.select(next);
NotebookActions.changeCellType(widget, 'raw');
expect(widget.activeCell).to.be.an.instanceof(RawCell);
next = widget.widgets[widget.activeCellIndex + 1];
expect(next).to.be.an.instanceof(RawCell);
});
it('should preserve the types of each cell', () => {
NotebookActions.changeCellType(widget, 'markdown');
NotebookActions.splitCell(widget);
expect(widget.activeCell).to.be.an.instanceof(MarkdownCell);
const prev = widget.widgets[0];
expect(prev).to.be.an.instanceof(MarkdownCell);
});
it('should create a raw mimetype selector', () => {
let optionsMap: { [key: string]: JSONValue } = {
None: '-',
LaTeX: 'text/latex',
reST: 'text/restructuredtext',
HTML: 'text/html',
Markdown: 'text/markdown',
Python: 'text/x-python'
};
optionsMap.None = '-';
const tool = NotebookTools.createNBConvertSelector(optionsMap);
tool.selectNode.selectedIndex = -1;
notebookTools.addItem({ tool });
simulate(panel0.node, 'focus');
NotebookActions.changeCellType(panel0.content, 'raw');
tabpanel.currentIndex = 2;
expect(tool).to.be.an.instanceof(NotebookTools.KeySelector);
expect(tool.key).to.equal('raw_mimetype');
const select = tool.selectNode;
expect(select.value).to.equal('');
const metadata = notebookTools.activeCell!.model.metadata;
expect(metadata.get('raw_mimetype')).to.be.undefined;
simulate(select, 'focus');
tool.selectNode.selectedIndex = 2;
simulate(select, 'change');
expect(metadata.get('raw_mimetype')).to.equal('text/restructuredtext');
});
it('should change the selected cell type(s)', () => {
let next = widget.widgets[1];
widget.select(next);
NotebookActions.changeCellType(widget, 'raw');
expect(widget.activeCell).to.be.an.instanceof(RawCell);
next = widget.widgets[widget.activeCellIndex + 1];
expect(next).to.be.an.instanceof(RawCell);
});
it('should create a raw mimetype selector', () => {
let optionsMap: { [key: string]: JSONValue } = {
None: '-',
LaTeX: 'text/latex',
reST: 'text/restructuredtext',
HTML: 'text/html',
Markdown: 'text/markdown',
Python: 'text/x-python'
};
optionsMap.None = '-';
const tool = NotebookTools.createNBConvertSelector(optionsMap);
tool.selectNode.selectedIndex = -1;
notebookTools.addItem({ tool });
simulate(panel0.node, 'focus');
NotebookActions.changeCellType(panel0.content, 'raw');
tabpanel.currentIndex = 2;
expect(tool).to.be.an.instanceof(NotebookTools.KeySelector);
expect(tool.key).to.equal('raw_mimetype');
const select = tool.selectNode;
expect(select.value).to.equal('');
const metadata = notebookTools.activeCell.model.metadata;
expect(metadata.get('raw_mimetype')).to.be.undefined;
simulate(select, 'focus');
tool.selectNode.selectedIndex = 2;
simulate(select, 'change');
expect(metadata.get('raw_mimetype')).to.equal('text/restructuredtext');
});
execute: args => {
const current = getCurrent(args);
if (current) {
return NotebookActions.changeCellType(current.content, 'code');
}
},
isEnabled
execute: () => NotebookActions.changeCellType(nbWidget.content, 'code')
});
execute: args => {
const current = getCurrent(args);
if (current) {
return NotebookActions.changeCellType(current.notebook, 'markdown');
}
},
isEnabled
execute: () => NotebookActions.changeCellType(nbWidget.content, 'markdown')
});
execute: args => {
const current = getCurrent(args);
if (current) {
return NotebookActions.changeCellType(current.notebook, 'code');
}
},
isEnabled