本文整理匯總了TypeScript中@jupyterlab/mainmenu/src.FileMenu類的典型用法代碼示例。如果您正苦於以下問題:TypeScript FileMenu類的具體用法?TypeScript FileMenu怎麽用?TypeScript FileMenu使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FileMenu類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('FileMenu', () => {
let commands: CommandRegistry;
let menu: FileMenu;
let tracker: InstanceTracker<Wodget>;
let wodget: Wodget;
beforeAll(() => {
commands = new CommandRegistry();
});
beforeEach(() => {
wodget = new Wodget();
menu = new FileMenu({ commands });
tracker = new InstanceTracker<Wodget>({ namespace: 'wodget' });
tracker.add(wodget);
});
afterEach(() => {
menu.dispose();
tracker.dispose();
wodget.dispose();
});
describe('#constructor()', () => {
it('should construct a new file menu', () => {
expect(menu).to.be.an.instanceof(FileMenu);
expect(menu.menu.title.label).to.equal('File');
});
});
describe('#newMenu', () => {
it('should be a submenu for `New...` commands', () => {
expect(menu.newMenu.menu.title.label).to.equal('New');
});
});
describe('#cleaners', () => {
it('should allow setting of an ICloseAndCleaner', () => {
const cleaner: IFileMenu.ICloseAndCleaner<Wodget> = {
tracker,
name: 'Wodget',
action: 'Clean',
closeAndCleanup: widget => {
widget.state = 'clean';
return Promise.resolve(void 0);
}
};
menu.closeAndCleaners.add(cleaner);
delegateExecute(wodget, menu.closeAndCleaners, 'closeAndCleanup');
expect(wodget.state).to.equal('clean');
});
});
describe('#persistAndSavers', () => {
it('should allow setting of an IPersistAndSave', () => {
const persistAndSaver: IFileMenu.IPersistAndSave<Wodget> = {
tracker,
name: 'Wodget',
action: 'with Save',
persistAndSave: widget => {
widget.state = 'saved';
return Promise.resolve(void 0);
}
};
menu.persistAndSavers.add(persistAndSaver);
delegateExecute(wodget, menu.persistAndSavers, 'persistAndSave');
expect(wodget.state).to.equal('saved');
});
});
describe('#consoleCreators', () => {
it('should allow setting of an IConsoleCreator', () => {
const creator: IFileMenu.IConsoleCreator<Wodget> = {
tracker,
name: 'Wodget',
createConsole: widget => {
widget.state = 'create';
return Promise.resolve(void 0);
}
};
menu.consoleCreators.add(creator);
delegateExecute(wodget, menu.consoleCreators, 'createConsole');
expect(wodget.state).to.equal('create');
});
});
});
示例2: afterEach
afterEach(() => {
menu.dispose();
tracker.dispose();
wodget.dispose();
});