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


TypeScript testing.flushMicrotasks函數代碼示例

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


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

示例1: it

    it('should open multiple overlays', fakeAsyncTest(() => {
      let pizzaOverlayRef: OverlayRef;
      let cakeOverlayRef: OverlayRef;

      overlay.create().then(ref => {
        pizzaOverlayRef = ref;
        pizzaOverlayRef.attach(componentPortal);
      });

      flushMicrotasks();

      overlay.create().then(ref => {
        cakeOverlayRef = ref;
        cakeOverlayRef.attach(templatePortal);
      });

      flushMicrotasks();

      expect(overlayContainerElement.childNodes.length).toBe(2);
      expect(overlayContainerElement.textContent).toContain('Pizza');
      expect(overlayContainerElement.textContent).toContain('Cake');

      pizzaOverlayRef.dispose();
      expect(overlayContainerElement.childNodes.length).toBe(1);
      expect(overlayContainerElement.textContent).toContain('Cake');

      cakeOverlayRef.dispose();
      expect(overlayContainerElement.childNodes.length).toBe(0);
      expect(overlayContainerElement.textContent).toBe('');
    }));
開發者ID:9590,項目名稱:material2,代碼行數:30,代碼來源:overlay.spec.ts

示例2: it

    it('should default the element to position: absolute', fakeAsyncTest(() => {
      strategy.apply(element);

      flushMicrotasks();

      expect(element.style.position).toBe('absolute');
    }));
開發者ID:marangor,項目名稱:material2,代碼行數:7,代碼來源:global-position-strategy.spec.ts

示例3: beforeEach

    beforeEach(inject(deps, fakeAsync((tcb: TestComponentBuilder, o: Overlay) => {
      builder = tcb;
      overlay = o;

      builder.createAsync(TestComponentWithTemplatePortals).then(fixture => {
        fixture.detectChanges();
        templatePortal = fixture.componentInstance.templatePortal;
        componentPortal = new ComponentPortal(PizzaMsg, fixture.componentInstance.elementRef);
      });

      flushMicrotasks();
    })));
開發者ID:9590,項目名稱:material2,代碼行數:12,代碼來源:overlay.spec.ts

示例4: it

    it('should apply the aria-live value polite by default', fakeAsyncTest(() => {
      let appFixture: ComponentFixture = null;

      builder.createAsync(TestApp).then(fixture => {
        appFixture = fixture;
      });

      flushMicrotasks();

      live.announce('Hey Google');

      // This flushes our 100ms timeout for the screenreaders.
      tick(100);

      expect(liveEl.textContent).toBe('Hey Google');
      expect(liveEl.getAttribute('aria-live')).toBe('polite');
    }));
開發者ID:AlmeroSteyn,項目名稱:material2,代碼行數:17,代碼來源:live-announcer.spec.ts


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