本文整理汇总了TypeScript中@jupyterlab/notebook.NotebookPanel类的典型用法代码示例。如果您正苦于以下问题:TypeScript NotebookPanel类的具体用法?TypeScript NotebookPanel怎么用?TypeScript NotebookPanel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NotebookPanel类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('ToolbarItems', () => {
let context: Context<INotebookModel>;
let panel: NotebookPanel;
beforeEach(async () => {
context = await createNotebookContext();
await context.initialize(true);
panel = createNotebookPanel(context);
context.model.fromJSON(DEFAULT_CONTENT);
});
afterEach(async () => {
await context.session.shutdown();
context.dispose();
panel.dispose();
});
describe('#createSaveButton()', () => {
it('should save when clicked', done => {
let button = ToolbarItems.createSaveButton(panel);
Widget.attach(button, document.body);
context.fileChanged.connect(() => {
button.dispose();
done();
});
button.node.click();
});
it("should have the `'jp-SaveIcon'` class", () => {
let button = ToolbarItems.createSaveButton(panel);
expect(button.hasClass('jp-SaveIcon')).to.be(true);
});
});
describe('#createInsertButton()', () => {
it('should insert below when clicked', () => {
let button = ToolbarItems.createInsertButton(panel);
Widget.attach(button, document.body);
button.node.click();
expect(panel.content.activeCellIndex).to.be(1);
expect(panel.content.activeCell).to.be.a(CodeCell);
button.dispose();
});
it("should have the `'jp-AddIcon'` class", () => {
let button = ToolbarItems.createInsertButton(panel);
expect(button.hasClass('jp-AddIcon')).to.be(true);
});
});
describe('#createCutButton()', () => {
it('should cut when clicked', () => {
let button = ToolbarItems.createCutButton(panel);
let count = panel.content.widgets.length;
Widget.attach(button, document.body);
button.node.click();
expect(panel.content.widgets.length).to.be(count - 1);
expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
button.dispose();
});
it("should have the `'jp-CutIcon'` class", () => {
let button = ToolbarItems.createCutButton(panel);
expect(button.hasClass('jp-CutIcon')).to.be(true);
});
});
describe('#createCopyButton()', () => {
it('should copy when clicked', () => {
let button = ToolbarItems.createCopyButton(panel);
let count = panel.content.widgets.length;
Widget.attach(button, document.body);
button.node.click();
expect(panel.content.widgets.length).to.be(count);
expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
button.dispose();
});
it("should have the `'jp-CopyIcon'` class", () => {
let button = ToolbarItems.createCopyButton(panel);
expect(button.hasClass('jp-CopyIcon')).to.be(true);
});
});
describe('#createPasteButton()', () => {
it('should paste when clicked', async () => {
let button = ToolbarItems.createPasteButton(panel);
let count = panel.content.widgets.length;
Widget.attach(button, document.body);
NotebookActions.copy(panel.content);
button.node.click();
await sleep();
expect(panel.content.widgets.length).to.be(count + 1);
button.dispose();
});
it("should have the `'jp-PasteIcon'` class", () => {
let button = ToolbarItems.createPasteButton(panel);
expect(button.hasClass('jp-PasteIcon')).to.be(true);
});
//.........这里部分代码省略.........
示例2: describe
describe('ToolbarItems', () => {
let panel: NotebookPanel;
const contentFactory = createNotebookPanelFactory();
beforeEach(() => {
panel = new NotebookPanel({ rendermime, contentFactory,
mimeTypeService });
context.model.fromJSON(DEFAULT_CONTENT);
panel.context = context;
});
afterEach(() => {
panel.dispose();
});
describe('#createSaveButton()', () => {
it('should save when clicked', (done) => {
let button = ToolbarItems.createSaveButton(panel);
Widget.attach(button, document.body);
context.fileChanged.connect(() => {
button.dispose();
done();
});
button.node.click();
});
it('should have the `\'jp-SaveIcon\'` class', () => {
let button = ToolbarItems.createSaveButton(panel);
expect(button.hasClass('jp-SaveIcon')).to.be(true);
});
});
describe('#createInsertButton()', () => {
it('should insert below when clicked', () => {
let button = ToolbarItems.createInsertButton(panel);
Widget.attach(button, document.body);
button.node.click();
expect(panel.notebook.activeCellIndex).to.be(1);
expect(panel.notebook.activeCell).to.be.a(CodeCell);
button.dispose();
});
it('should have the `\'jp-AddIcon\'` class', () => {
let button = ToolbarItems.createInsertButton(panel);
expect(button.hasClass('jp-AddIcon')).to.be(true);
});
});
describe('#createCutButton()', () => {
it('should cut when clicked', () => {
let button = ToolbarItems.createCutButton(panel);
let count = panel.notebook.widgets.length;
Widget.attach(button, document.body);
button.node.click();
expect(panel.notebook.widgets.length).to.be(count - 1);
expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
button.dispose();
});
it('should have the `\'jp-CutIcon\'` class', () => {
let button = ToolbarItems.createCutButton(panel);
expect(button.hasClass('jp-CutIcon')).to.be(true);
});
});
describe('#createCopyButton()', () => {
it('should copy when clicked', () => {
let button = ToolbarItems.createCopyButton(panel);
let count = panel.notebook.widgets.length;
Widget.attach(button, document.body);
button.node.click();
expect(panel.notebook.widgets.length).to.be(count);
expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
button.dispose();
});
it('should have the `\'jp-CopyIcon\'` class', () => {
let button = ToolbarItems.createCopyButton(panel);
expect(button.hasClass('jp-CopyIcon')).to.be(true);
});
});
describe('#createPasteButton()', () => {
it('should paste when clicked', (done) => {
let button = ToolbarItems.createPasteButton(panel);
let count = panel.notebook.widgets.length;
Widget.attach(button, document.body);
NotebookActions.copy(panel.notebook);
button.node.click();
requestAnimationFrame(() => {
//.........这里部分代码省略.........
示例4: afterEach
afterEach(async () => {
await context.session.shutdown();
context.dispose();
panel.dispose();
});
示例5: afterEach
afterEach(() => {
panel.dispose();
});
示例6:
return current.context.session.shutdown().then(() => {
current.dispose();
});