當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript src.FileMenu類代碼示例

本文整理匯總了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');
      });
    });
  });
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:86,代碼來源:file.spec.ts

示例2: afterEach

 afterEach(() => {
   menu.dispose();
   tracker.dispose();
   wodget.dispose();
 });
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:5,代碼來源:file.spec.ts


注:本文中的@jupyterlab/mainmenu/src.FileMenu類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。