• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript testing.flushMicrotasks函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@angular/core/testing.flushMicrotasks函数的典型用法代码示例。如果您正苦于以下问题:TypeScript flushMicrotasks函数的具体用法?TypeScript flushMicrotasks怎么用?TypeScript flushMicrotasks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了flushMicrotasks函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

    it('should re-focus trigger element when dialog closes', fakeAsync(() => {
      // Create a element that has focus before the dialog is opened.
      let button = document.createElement('button');
      button.id = 'dialog-trigger';
      document.body.appendChild(button);
      button.focus();

      let dialogRef = dialog.open(PizzaMsg, {
        viewContainerRef: testViewContainerRef
      });

      viewContainerFixture.detectChanges();
      flushMicrotasks();

      expect(document.activeElement.id)
          .not.toBe('dialog-trigger', 'Expected the focus to change when dialog was opened.');

      dialogRef.close();
      tick(500);
      viewContainerFixture.detectChanges();
      flushMicrotasks();

      expect(document.activeElement.id)
          .toBe('dialog-trigger', 'Expected that the trigger was refocused after dialog close');
    }));
开发者ID:justin-echternach,项目名称:material2,代码行数:25,代码来源:dialog.spec.ts


示例2: 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:Angular2-BD,项目名称:material2,代码行数:30,代码来源:overlay.spec.ts


示例3: it

  it('should overwrite previously applied positioning', fakeAsyncTest(() => {
    strategy.centerHorizontally().centerVertically().apply(element);
    flushMicrotasks();

    strategy.top('10px').left('40%').apply(element);
    flushMicrotasks();

    let elementStyle = element.style;
    let parentStyle = (element.parentNode as HTMLElement).style;

    expect(elementStyle.marginTop).toBe('10px');
    expect(elementStyle.marginLeft).toBe('40%');
    expect(elementStyle.marginBottom).toBe('');
    expect(elementStyle.marginRight).toBe('');

    expect(parentStyle.justifyContent).toBe('flex-start');
    expect(parentStyle.alignItems).toBe('flex-start');

    strategy.bottom('70px').right('15em').apply(element);

    flushMicrotasks();

    expect(element.style.marginTop).toBe('');
    expect(element.style.marginLeft).toBe('');
    expect(element.style.marginBottom).toBe('70px');
    expect(element.style.marginRight).toBe('15em');

    expect(parentStyle.justifyContent).toBe('flex-end');
    expect(parentStyle.alignItems).toBe('flex-end');
  }));
开发者ID:Chintuz,项目名称:material2,代码行数:30,代码来源:global-position-strategy.spec.ts


示例4: it

    it('should listen on start and done on the animation builder\'s player', fakeAsync(() => {
         @Component({
           selector: 'ani-cmp',
           template: '...',
         })
         class Cmp {
           @ViewChild('target') public target: any;

           constructor(public builder: AnimationBuilder) {}

           build() {
             const definition =
                 this.builder.build([style({opacity: 0}), animate(1000, style({opacity: 1}))]);

             return definition.create(this.target);
           }
         }

         TestBed.configureTestingModule({declarations: [Cmp]});

         const fixture = TestBed.createComponent(Cmp);
         const cmp = fixture.componentInstance;
         fixture.detectChanges();

         const player = cmp.build();

         let started = false;
         player.onStart(() => started = true);

         let finished = false;
         player.onDone(() => finished = true);

         let destroyed = false;
         player.onDestroy(() => destroyed = true);

         player.init();
         flushMicrotasks();
         expect(started).toBeFalsy();
         expect(finished).toBeFalsy();
         expect(destroyed).toBeFalsy();

         player.play();
         flushMicrotasks();
         expect(started).toBeTruthy();
         expect(finished).toBeFalsy();
         expect(destroyed).toBeFalsy();

         player.finish();
         flushMicrotasks();
         expect(started).toBeTruthy();
         expect(finished).toBeTruthy();
         expect(destroyed).toBeFalsy();

         player.destroy();
         flushMicrotasks();
         expect(started).toBeTruthy();
         expect(finished).toBeTruthy();
         expect(destroyed).toBeTruthy();
       }));
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:59,代码来源:browser_animation_builder_spec.ts


示例5: it

        it("stores translation when promise got resolved", fakeAsync(() => {
            translateComponent.key = "TEXT";

            flushMicrotasks();

            expect(translateComponent.translation).toBe("This is a text");
        }));
开发者ID:tflori,项目名称:angular2-translator,代码行数:7,代码来源:TranslateComponent.spec.ts


示例6: it

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

      flushMicrotasks();

      expect(element.style.position).toBe('absolute');
    }));
开发者ID:AlexYates,项目名称:material2,代码行数:7,代码来源:global-position-strategy.spec.ts


示例7: it

  it('should reset the vertical position and offset when the height is 100%', fakeAsync(() => {
    strategy.centerVertically().height('100%').apply(element);

    flushMicrotasks();

    expect(element.style.top).toBe('0px');
    expect(element.style.transform).toBe('');
  }));
开发者ID:dudko-av,项目名称:material2,代码行数:8,代码来源:global-position-strategy.spec.ts



注:本文中的@angular/core/testing.flushMicrotasks函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript testing.getTestBed函数代码示例发布时间:2022-05-28
下一篇:
TypeScript testing.flush函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap