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 copy the selected cells to a NBTestUtils.clipboard', () => {
const next = widget.widgets[1];
widget.select(next);
NotebookActions.copy(widget);
expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(true);
const data = NBTestUtils.clipboard.getData(JUPYTER_CELL_MIME);
expect(data.length).to.equal(2);
});
it('should cut when clicked', async () => {
const button = ToolbarItems.createCutButton(panel);
const count = panel.content.widgets.length;
Widget.attach(button, document.body);
await framePromise();
simulate(button.node.firstChild as HTMLElement, 'mousedown');
expect(panel.content.widgets.length).to.equal(count - 1);
expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(true);
button.dispose();
});
it('should be a no-op if there is no model', () => {
widget.model = null;
NotebookActions.cut(widget);
expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(
false
);
});
it('should delete metadata.deletable', () => {
const next = widget.widgets[1];
widget.select(next);
next.model.metadata.set('deletable', false);
NotebookActions.copy(widget);
const data = NBTestUtils.clipboard.getData(
JUPYTER_CELL_MIME
) as JSONArray;
data.map(cell => {
expect(((cell as JSONObject).metadata as JSONObject).deletable).to.be
.undefined;
});
});
});
it('should copy when clicked', async () => {
const button = ToolbarItems.createCopyButton(panel);
const count = panel.content.widgets.length;
Widget.attach(button, document.body);
await framePromise();
simulate(button.node.firstChild as HTMLElement, 'mousedown');
expect(panel.content.widgets.length).to.equal(count);
expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(
true
);
button.dispose();
});
it('should delete metadata.deletable', () => {
const next = widget.widgets[1];
widget.select(next);
next.model.metadata.set('deletable', false);
NotebookActions.copy(widget);
const data = NBTestUtils.clipboard.getData(
JUPYTER_CELL_MIME
) as JSONArray;
data.map(cell => {
expect(((cell as JSONObject).metadata as JSONObject).deletable).to.be
.undefined;
});
});
});
it('should copy when clicked', async () => {
const button = ToolbarItems.createCopyButton(panel);
const count = panel.content.widgets.length;
Widget.attach(button, document.body);
await framePromise();
simulate(button.node.firstChild as HTMLElement, 'mousedown');
expect(panel.content.widgets.length).to.equal(count);
expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(true);
button.dispose();
});
it('should cut when clicked', async () => {
const button = ToolbarItems.createCutButton(panel);
const count = panel.content.widgets.length;
Widget.attach(button, document.body);
await framePromise();
simulate(button.node.firstChild as HTMLElement, 'mousedown');
expect(panel.content.widgets.length).to.equal(count - 1);
expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(
true
);
button.dispose();
});
afterEach(() => {
widget.dispose();
NBTestUtils.clipboard.clear();
});
afterEach(() => {
widget.dispose();
NBTestUtils.clipboard.clear();
});