本文整理匯總了TypeScript中@jupyterlab/mainmenu.JupyterLabMenu類的典型用法代碼示例。如果您正苦於以下問題:TypeScript JupyterLabMenu類的具體用法?TypeScript JupyterLabMenu怎麽用?TypeScript JupyterLabMenu使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了JupyterLabMenu類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('JupyterLabMenu', () => {
let commands: CommandRegistry;
let menu: JupyterLabMenu;
beforeAll(() => {
commands = new CommandRegistry();
commands.addCommand('run1', {
label: 'Run 1',
execute: () => void 0
});
commands.addCommand('run2', {
label: 'Run 2',
execute: () => void 0
});
commands.addCommand('run3', {
label: 'Run 3',
execute: () => void 0
});
commands.addCommand('run4', {
label: 'Run 4',
execute: () => void 0
});
});
beforeEach(() => {
menu = new JupyterLabMenu({ commands });
});
afterEach(() => {
menu.dispose();
});
describe('#constructor()', () => {
it('should construct a new main menu', () => {
expect(menu).to.be.an.instanceof(JupyterLabMenu);
});
it('should accept useSeparators as an option', () => {
const menu1 = new JupyterLabMenu({ commands }, false);
const menu2 = new JupyterLabMenu({ commands }, true);
menu1.addGroup([{ command: 'run1' }, { command: 'run2' }]);
menu2.addGroup([{ command: 'run1' }, { command: 'run2' }]);
expect(menu1.menu.items.length).to.equal(2);
expect(menu2.menu.items.length).to.equal(4);
});
});
describe('#addGroup()', () => {
it('should add a new group to the menu', () => {
menu.addGroup([{ command: 'run1' }, { command: 'run2' }]);
const idx1 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run1'
);
const idx2 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run2'
);
expect(idx1 === -1).to.equal(false);
expect(idx2 === -1).to.equal(false);
expect(idx1 > idx2).to.equal(false);
});
it('should take a rank as an option', () => {
menu.addGroup([{ command: 'run1' }, { command: 'run2' }], 2);
menu.addGroup([{ command: 'run3' }, { command: 'run4' }], 1);
const idx1 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run1'
);
const idx2 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run2'
);
const idx3 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run3'
);
const idx4 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run4'
);
expect(idx3 < idx4).to.equal(true);
expect(idx4 < idx1).to.equal(true);
expect(idx1 < idx2).to.equal(true);
});
it('should return a disposable that can be used to remove the group', () => {
const group1 = [{ command: 'run1' }, { command: 'run2' }];
const group2 = [{ command: 'run3' }, { command: 'run4' }];
const disposable = menu.addGroup(group1);
menu.addGroup(group2);
disposable.dispose();
const idx1 = ArrayExt.findFirstIndex(
menu.menu.items,
//.........這裏部分代碼省略.........
示例2: it
it('should return a disposable that can be used to remove the group', () => {
const group1 = [{ command: 'run1' }, { command: 'run2' }];
const group2 = [{ command: 'run3' }, { command: 'run4' }];
const disposable = menu.addGroup(group1);
menu.addGroup(group2);
disposable.dispose();
const idx1 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run1'
);
const idx2 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run2'
);
const idx3 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run3'
);
const idx4 = ArrayExt.findFirstIndex(
menu.menu.items,
m => m.command === 'run4'
);
expect(idx1).to.equal(-1);
expect(idx2).to.equal(-1);
expect(idx3 === -1).to.equal(false);
expect(idx4 === -1).to.equal(false);
});
示例3: it
it('should take a rank as an option', () => {
menu.addGroup([ { command: 'run1'}, { command: 'run2' }], 2);
menu.addGroup([ { command: 'run3'}, { command: 'run4' }], 1);
let idx1 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run1');
let idx2 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run2');
let idx3 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run3');
let idx4 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run4');
expect(idx3 < idx4).to.be(true);
expect(idx4 < idx1).to.be(true);
expect(idx1 < idx2).to.be(true);
});
示例4: afterEach
afterEach(() => {
menu.dispose();
});