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


TypeScript simulate-event.simulate函數代碼示例

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


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

示例1: it

      it('should disconnect a node from a command', () => {
        let called = false;
        let command = 'commandlinker:disconnect-node';
        let commands =new CommandRegistry();
        let linker = new CommandLinker({ commands });
        let node = document.createElement('div');
        let disposable = commands.addCommand(command, {
          execute: () => { called = true; }
        });

        document.body.appendChild(node);
        linker.connectNode(node, command, null);

        // Make sure connection is working.
        expect(called).to.be(false);
        simulate(node, 'click');
        expect(called).to.be(true);

        // Reset flag.
        called = false;

        // Make sure disconnection is working.
        linker.disconnectNode(node);
        expect(called).to.be(false);
        simulate(node, 'click');
        expect(called).to.be(false);

        document.body.removeChild(node);
        linker.dispose();
        disposable.dispose();
      });
開發者ID:rlugojr,項目名稱:jupyterlab,代碼行數:31,代碼來源:commandlinker.spec.ts

示例2: it

 it('should set the focus number of the widget', () => {
   let tracker = new FocusTracker();
   let widget0 = createWidget();
   let widget1 = createWidget();
   widget0.node.focus();
   tracker.add(widget0);
   tracker.add(widget1);
   simulate(widget1.node, 'focus');
   expect(tracker.focusNumber(widget0)).to.be(0);
   simulate(widget0.node, 'focus');
   expect(tracker.focusNumber(widget0)).to.be(2);
 });
開發者ID:rlugojr,項目名稱:phosphor,代碼行數:12,代碼來源:focustracker.spec.ts

示例3: it

 it('should create a new folder', (done) => {
   Widget.attach(buttons, document.body);
   let node = buttons.createNode;
   simulate(node, 'mousedown');
   let menu = document.getElementsByClassName('p-Menu')[0];
   simulate(menu, 'keydown', { keyCode: 40 });
   simulate(menu, 'keydown', { keyCode: 13 });
   model.fileChanged.connect((sender, args) => {
     expect(args.newValue.type).to.be('directory');
     done();
   });
 });
開發者ID:rlugojr,項目名稱:jupyterlab,代碼行數:12,代碼來源:buttons.spec.ts

示例4: it

 it('should wrap the select node', () => {
   let select = document.createElement('select');
   let wrapper = Styling.wrapSelect(select);
   expect(wrapper.className).to.equal('jp-select-wrapper');
   expect(select.parentElement).to.equal(wrapper);
   expect(select.className).to.equal('jp-mod-styled');
   document.body.appendChild(wrapper);
   select.focus();
   simulate(select, 'focus');
   expect(wrapper.className).to.contain('jp-mod-focused');
   select.blur();
   simulate(select, 'blur');
   expect(wrapper.className).to.not.contain('jp-mod-focused');
   document.body.removeChild(wrapper);
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:15,代碼來源:styling.spec.ts

示例5: it

      it('should connect a node to a command', () => {
        let called = false;
        const command = 'commandlinker:connect-node';
        const commands = new CommandRegistry();
        const linker = new CommandLinker({ commands });
        let node: HTMLElement;
        let vnode: VirtualNode;
        const disposable = commands.addCommand(command, {
          execute: () => {
            called = true;
          }
        });

        vnode = h.div({ dataset: linker.populateVNodeDataset(command, null) });
        node = VirtualDOM.realize(vnode);
        document.body.appendChild(node);

        expect(called).to.equal(false);
        simulate(node, 'click');
        expect(called).to.equal(true);

        document.body.removeChild(node);
        linker.dispose();
        disposable.dispose();
      });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:25,代碼來源:commandlinker.spec.ts

示例6: it

      it('should run and advance when clicked', async () => {
        const button = ToolbarItems.createRunButton(panel);
        const widget = panel.content;

        // Clear and select the first two cells.
        const codeCell = widget.widgets[0] as CodeCell;
        codeCell.model.outputs.clear();
        widget.select(codeCell);
        const mdCell = widget.widgets[1] as MarkdownCell;
        mdCell.rendered = false;
        widget.select(mdCell);

        Widget.attach(button, document.body);
        await context.ready;
        await context.session.ready;
        await context.session.kernel.ready;
        const p = new PromiseDelegate();
        context.session.statusChanged.connect((sender, status) => {
          // Find the right status idle message
          if (status === 'idle' && codeCell.model.outputs.length > 0) {
            expect(mdCell.rendered).to.equal(true);
            expect(widget.activeCellIndex).to.equal(2);
            button.dispose();
            p.resolve(0);
          }
        });
        await framePromise();
        simulate(button.node.firstChild as HTMLElement, 'mousedown');
        await p.promise;
      }).timeout(30000); // Allow for slower CI
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:30,代碼來源:default-toolbar.spec.ts

示例7: focusWidget

 function focusWidget(widget: Widget): void {
   widget.node.focus();
   if (Platform.IS_IE) {
     // Ensure we get a synchronous event on IE for testing.
     simulate(widget.node, 'focus');
   }
 }
開發者ID:afshin,項目名稱:phosphor,代碼行數:7,代碼來源:focustracker.spec.ts

示例8: blurWidget

 function blurWidget(widget: Widget): void {
   widget.node.blur();
   if (Platform.IS_IE) {
     // Ensure we get a synchronous event on IE for testing.
     simulate(widget.node, 'blur');
   }
 }
開發者ID:afshin,項目名稱:phosphor,代碼行數:7,代碼來源:focustracker.spec.ts


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