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


TypeScript src.MainMenu類代碼示例

本文整理匯總了TypeScript中@jupyterlab/mainmenu/src.MainMenu的典型用法代碼示例。如果您正苦於以下問題:TypeScript MainMenu類的具體用法?TypeScript MainMenu怎麽用?TypeScript MainMenu使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了MainMenu類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

  describe('MainMenu', () => {
    let commands: CommandRegistry;
    let mainMenu: MainMenu;

    beforeAll(() => {
      commands = new CommandRegistry();
    });

    beforeEach(() => {
      mainMenu = new MainMenu(commands);
    });

    afterEach(() => {
      mainMenu.dispose();
    });

    describe('#constructor()', () => {
      it('should construct a new main menu', () => {
        const menu = new MainMenu(new CommandRegistry());
        expect(menu).to.be.an.instanceof(MainMenu);
      });
    });

    describe('#addMenu()', () => {
      it('should add a new menu', () => {
        const menu = new Menu({ commands });
        mainMenu.addMenu(menu);
        expect(find(mainMenu.menus, m => menu === m) !== undefined).to.equal(
          true
        );
      });

      it('should take a rank as an option', () => {
        const menu1 = new Menu({ commands });
        const menu2 = new Menu({ commands });
        mainMenu.addMenu(menu1, { rank: 300 });
        mainMenu.addMenu(menu2, { rank: 200 });
        expect(ArrayExt.firstIndexOf(mainMenu.menus, menu1)).to.equal(6);
        expect(ArrayExt.firstIndexOf(mainMenu.menus, menu2)).to.equal(5);
      });
    });

    describe('#fileMenu', () => {
      it('should be a FileMenu', () => {
        expect(mainMenu.fileMenu).to.be.an.instanceof(FileMenu);
      });

      it('should be the first menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.fileMenu.menu)
        ).to.equal(0);
      });
    });

    describe('#editMenu', () => {
      it('should be a EditMenu', () => {
        expect(mainMenu.editMenu).to.be.an.instanceof(EditMenu);
      });

      it('should be the second menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.editMenu.menu)
        ).to.equal(1);
      });
    });

    describe('#viewMenu', () => {
      it('should be a ViewMenu', () => {
        expect(mainMenu.viewMenu).to.be.an.instanceof(ViewMenu);
      });

      it('should be the third menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.viewMenu.menu)
        ).to.equal(2);
      });
    });

    describe('#runMenu', () => {
      it('should be a RunMenu', () => {
        expect(mainMenu.runMenu).to.be.an.instanceof(RunMenu);
      });

      it('should be the fourth menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.runMenu.menu)
        ).to.equal(3);
      });
    });

    describe('#kernelMenu', () => {
      it('should be a KernelMenu', () => {
        expect(mainMenu.kernelMenu).to.be.an.instanceof(KernelMenu);
      });

      it('should be the fifth menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.kernelMenu.menu)
        ).to.equal(4);
      });
//.........這裏部分代碼省略.........
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:101,代碼來源:mainmenu.spec.ts

示例2: it

 it('should take a rank as an option', () => {
   const menu1 = new Menu({ commands });
   const menu2 = new Menu({ commands });
   mainMenu.addMenu(menu1, { rank: 300 });
   mainMenu.addMenu(menu2, { rank: 200 });
   expect(ArrayExt.firstIndexOf(mainMenu.menus, menu1)).to.equal(6);
   expect(ArrayExt.firstIndexOf(mainMenu.menus, menu2)).to.equal(5);
 });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:8,代碼來源:mainmenu.spec.ts

示例3: afterEach

 afterEach(() => {
   mainMenu.dispose();
 });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:3,代碼來源:mainmenu.spec.ts


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