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

TypeScript testing.injectAsync函数代码示例

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

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



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

示例1: describe

describe('When loading the UserAppComponent', () => {
  
  var mockRouterProvider: MockRouterProvider = new MockRouterProvider();
  
  beforeEachProviders(() => {
    return [mockRouterProvider.getProviders()];
  });
  
  it('should do something', 
    injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
      return tcb
        .createAsync(UserAppComponent)
        .then((fixture: ComponentFixture) => {
          fixture.detectChanges();
          let compiled = fixture.debugElement.nativeElement;
        });
    })
  );
  
});
开发者ID:aneagoie,项目名称:angular2-unit-test-app,代码行数:20,代码来源:user-app.component.spec.ts


示例2: describe

describe('AppComponent', () => {
    beforeEachProviders(() => [
        LoggerService,
        ROUTER_PROVIDERS,
        provide(ROUTER_PRIMARY_COMPONENT, { useValue: AppComponent }),
        provide(ApplicationRef, { useClass: MockApplicationRef }),
        provide(APP_BASE_HREF, { useValue: '/' }),
    ]);

    it('should have brand Angular 2 Starter', injectAsync([TestComponentBuilder],
        (tsb: TestComponentBuilder) => {
            return tsb.createAsync(TestComponent).then((fixture) => {
                fixture.detectChanges();
                let compiled = fixture.debugElement.nativeElement;
                expect(compiled).toBeDefined();
                expect(compiled.querySelector('a.navbar-brand'))
                    .toHaveText('Angular 2 Starter');
            });
        }));
});
开发者ID:Darkniel,项目名称:angular2-zitio,代码行数:20,代码来源:app.component.spec.ts


示例3: describe

describe('App', () => {
  let fixture: ComponentFixture;

  beforeEach(injectAsync([TestComponentBuilder], tcb => {
    return tcb.createAsync(App)
      .then(f => fixture = f);
  }));

  it('should have a title', () => {
    // given a component instance
    let appCmp = fixture.componentInstance;

    // when we trigger the change detection
    fixture.detectChanges();

    // then we should have a name
    let element = fixture.nativeElement;
    expect(element.querySelector('h1')).toHaveText('Hello, Angular2!');
  });
});
开发者ID:gdangelo,项目名称:angular2-starter,代码行数:20,代码来源:app.spec.ts


示例4: describe

describe('Testing Login Component Failed Flow', () => {
  let mockRouterProvider = new MockRouterProvider();

  beforeEachProviders(() => {
    return [
      provide(AuthService, {useClass: MockFailedAuthService}),
      mockRouterProvider.getProviders(),
      FormBuilder
    ];
  });

  it('Login should fail', injectAsync([TestComponentBuilder],
      (tcb: TestComponentBuilder) => {
    return tcb.createAsync(LoginComponent).then(fixture => {
      const instance = fixture.debugElement.componentInstance;
      instance.login();
      chai.expect(instance.message).to.equal('Incorrect credentials.');
    });
  }));
});
开发者ID:ManuCutillas,项目名称:ngCourse2,代码行数:20,代码来源:login.spec.ts


示例5: describe

describe('DashboardComponent',  () => {
  beforeEachProviders(() => [
    provide(Router, { useValue: {} }),
    provide(SpeakerService, {
      useValue: {
        getSpeakers: () => { },
        onDbReset: () => { }
    }}),
    ToastService
  ]);

  it('should instantiate component',
    injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {

      return tcb.createAsync(DashboardComponent).then(fixture => {
        expect(fixture.componentInstance instanceof DashboardComponent).toBe(true, 'should create DashboardComponent');
      });
    }));

});
开发者ID:nickbarnettworks,项目名称:event-view,代码行数:20,代码来源:dashboard.component.spec.ts


示例6: describe

describe('Search Tests', () => {

  beforeEachProviders(() => [
    HTTP_PROVIDERS,
    provide(MainService, { useClass: MockMainService })
  ]);

  it('should change if active', injectAsync([TestComponentBuilder], (tcb) => {
    return tcb
      .overrideProviders(
        Search, [provide(MainService, { useClass: MockMainService })]
      )
      .createAsync(Search).then((fixture) => {
        fixture.componentInstance.search('url');
        fixture.detectChanges();
        let compiled = fixture.debugElement.nativeElement;
        expect(compiled.outerHTML).toContain('TTT');
      });
  }));

});
开发者ID:astagi,项目名称:angular2-workbench,代码行数:21,代码来源:search.spec.ts


示例7: describe

  describe('App component', () => {

    // Support for testing component that uses Router
    beforeEachProviders(() => [
      RouteRegistry,
      DirectiveResolver,
      provide(Location, {useClass: SpyLocation}),
      provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppComponent}),
      provide(Router, {useClass: RootRouter})
    ]);

    it('should work',
      injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb.createAsync(TestComponent)
          .then(rootTC => {
            rootTC.detectChanges();
            let appDOMEl = rootTC.debugElement.children[0].nativeElement;
            expect(DOM.querySelectorAll(appDOMEl, 'c-app > c-navbar > nav > a')[1].href).toMatch(/http:\/\/localhost:\d+\/about/);
          });
      }));
  });
开发者ID:unit9,项目名称:gae-secure-scaffold-python,代码行数:21,代码来源:c-app.spec.ts


示例8: describe

describe('SampleComponent', () => {
  let fixture;
  
  //setup
  beforeEachProviders(() => [
    TestComponentBuilder
  ]);

  beforeEach(injectAsync([TestComponentBuilder], tcb => {
    return tcb
      .createAsync(TestComponent)
      .then(f => fixture = f);
  }));

  it('should say something about making a library', () => {
    let container = fixture.componentInstance,
      div = fixture.nativeElement.querySelector('div');
    expect(div.textContent).toBe('');
  });

});
开发者ID:jesperronn,项目名称:angular2-library-seed,代码行数:21,代码来源:sample.component.spec.ts


示例9: describe

describe('SanitizeDirective', () => {
  let fixture;
  
  //setup
  beforeEachProviders(() => [
    TestComponentBuilder
  ]);

  beforeEach(injectAsync([TestComponentBuilder], tcb => {
    return tcb
      .createAsync(TestComponent)
      .then(f => fixture = f);
  }));

  it('should add a class', () => {
    let container = fixture.componentInstance,
      div = fixture.nativeElement.querySelector('div');
    expect(div.getAttribute('class')).toBe('sample-class');
  });

});
开发者ID:NathanWalker,项目名称:ng2-sanitize,代码行数:21,代码来源:sanitize.directive.spec.ts


示例10: describe

describe('AppComponent', () => {

    beforeEachProviders(() => [
        AppComponent
    ]);

    it('should exist', inject([AppComponent], (appComponent:AppComponent) => {
        expect(appComponent).toBeDefined();
    }));

    it('should render a header', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
        return tcb.createAsync(AppComponent)
            .then((fixture:ComponentFixture) => {
                let element = fixture.nativeElement;
                let appComponent = fixture.componentInstance;
                fixture.detectChanges();
                expect(element.querySelectorAll('h1').length).toBe(1);
            });
    }));
    
});
开发者ID:Georg-W,项目名称:angular2-tdd-boilerplate,代码行数:21,代码来源:app.component.spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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