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


TypeScript testing.TestComponentBuilder類代碼示例

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


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

示例1: describe

describe('Login Component', () => {
  setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
  let tcb: TestComponentBuilder;

  beforeEachProviders(() => [
    TestComponentBuilder,
    provide(DirectiveResolver, {useClass: MockDirectiveResolver}),
    provide(ViewResolver, {useClass: MockViewResolver}),
    LoginComponent,
  ]);

  beforeEach(inject([TestComponentBuilder], (tcb_) => {
    tcb = tcb_;
  }));

  it('should render form', (done) => {
    tcb.createAsync(LoginComponent)
      .then((fixture) => {
        let element = fixture.nativeElement;
        fixture.detectChanges();
        let form = element.querySelector('form');
        expect(form).toBeTruthy();
        expect(form.querySelector('input[name="username"]')).toBeTruthy();
        expect(form.querySelector('input[name="password"]')).toBeTruthy();
        done();
      });
  });
});
開發者ID:mahpah,項目名稱:ng2-pack,代碼行數:28,代碼來源:login.component.spec.ts

示例2: describe

describe('Dashboard Component', () => {
  setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
  let tcb: TestComponentBuilder;

  beforeEachProviders(() => [
    TestComponentBuilder,
    HTTP_PROVIDERS,
    ROUTER_FAKE_PROVIDERS,
    provide(Location, {useClass: SpyLocation}),
    provide(DirectiveResolver, {useClass: MockDirectiveResolver}),
    provide(ViewResolver, {useClass: MockViewResolver}),
    HeroService,
    AppComponent,
  ]);

  beforeEach(inject([TestComponentBuilder], (tcb_) => {
    tcb = tcb_;
  }));

  it('should render the title', (done) => {
    return tcb.createAsync(DashboardComponent)
      .then(fixture => {
        let component = fixture.componentInstance;
        component.title = 'Top_heroes';
        fixture.detectChanges();
        let element = fixture.nativeElement;
        expect(element.querySelector('h3').innerText).toContain('Top_heroes');
        done();
      });
  });
});
開發者ID:mahpah,項目名稱:ng2-pack,代碼行數:31,代碼來源:dashboard.component.spec.ts

示例3: async

      async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
      tcb.createAsync(DashboardComponent).then(fixture => {
        comp = fixture.debugElement.componentInstance;

        expect(comp.heroes.length).toEqual(0,
          'should not have heroes before OnInit');
      });
    })));
開發者ID:GeertJohan,項目名稱:angular.io,代碼行數:8,代碼來源:dashboard.component.spec.ts

示例4: spyOn

      (tcb: TestComponentBuilder, router: MockRouter) => {

      let spy = spyOn(router, 'navigate').and.callThrough();

      tcb.createAsync(DashboardComponent).then(fixture => {
        let hero: Hero = {id: 42, name: 'Abbracadabra' };
        comp = fixture.debugElement.componentInstance;
        comp.gotoDetail(hero);

        let linkParams = spy.calls.mostRecent().args[0];
        expect(linkParams[0]).toEqual('HeroDetail', 'should nav to "HeroDetail"');
        expect(linkParams[1].id).toEqual(hero.id, 'should nav to fake hero\'s id');

      });
    })));
開發者ID:GeertJohan,項目名稱:angular.io,代碼行數:15,代碼來源:dashboard.component.spec.ts

示例5: it

 it('should render the title', (done) => {
   return tcb.createAsync(DashboardComponent)
     .then(fixture => {
       let component = fixture.componentInstance;
       component.title = 'Top_heroes';
       fixture.detectChanges();
       let element = fixture.nativeElement;
       expect(element.querySelector('h3').innerText).toContain('Top_heroes');
       done();
     });
 });
開發者ID:mahpah,項目名稱:ng2-pack,代碼行數:11,代碼來源:dashboard.component.spec.ts

示例6: it

 it('should render form', (done) => {
   tcb.createAsync(LoginComponent)
     .then((fixture) => {
       let element = fixture.nativeElement;
       fixture.detectChanges();
       let form = element.querySelector('form');
       expect(form).toBeTruthy();
       expect(form.querySelector('input[name="username"]')).toBeTruthy();
       expect(form.querySelector('input[name="password"]')).toBeTruthy();
       done();
     });
 });
開發者ID:mahpah,項目名稱:ng2-pack,代碼行數:12,代碼來源:login.component.spec.ts


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