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


TypeScript core.TestComponentBuilder類代碼示例

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


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

示例1: beforeEach

 beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
   builder = tcb
     .overrideTemplate(RepoBrowserComponent, require("./repo-browser.html"))
     .overrideProviders(RepoBrowserComponent, [
       provide(GitHub, {useClass: MockGitHub})
     ]);
 }));
開發者ID:laco0416,項目名稱:angular2-seed,代碼行數:7,代碼來源:repo-browser.spec.ts

示例2: describe

describe("HomeComponent", () => {

  beforeEachProviders(() => [
  ]);

  let builder: TestComponentBuilder;
  beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
    builder = tcb
      .overrideTemplate(HomeComponent, require("./home.html"));
  }));

  it("can create", async(
    inject([], () => {
      builder.createAsync(HomeComponent);
    }))
  );

  it("has expected view", async(
    inject([], () => {
      builder
        .createAsync(HomeComponent)
        .then(fixture => {
          assert.equal(fixture.debugElement.nativeElement.innerHTML, `<h3>Home Component</h3>
<p>Welcome to Angular Seed</p>`);
        });
    }))
  );
});
開發者ID:laco0416,項目名稱:angular2-seed,代碼行數:28,代碼來源:home.spec.ts

示例3: describe

describe("AboutComponent", () => {

  beforeEachProviders(() => [
    MockBackend,
    BaseRequestOptions,
    provide(Http, {
      useFactory: (backend: MockBackend, options: BaseRequestOptions) => new Http(backend, options),
      deps: [MockBackend, BaseRequestOptions]
    })
  ]);

  let builder: TestComponentBuilder;
  beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
    builder = tcb
      .overrideTemplate(AboutComponent, require("./about.html"));
  }));

  it("can create", async(
    inject([], () => {
      builder.createAsync(AboutComponent);
    }))
  );

  it("has expected view", async(
    inject([], () => {
      builder
        .createAsync(AboutComponent)
        .then(fixture => {
          assert.equal(fixture.debugElement.nativeElement.innerHTML, `<h3>About Component</h3>
<p>This is the about component!</p>`);
        });
    }))
  );
});
開發者ID:laco0416,項目名稱:angular2-seed,代碼行數:34,代碼來源:about.spec.ts

示例4: describe

describe('Component: WeatherWidget', () => {
  let builder: TestComponentBuilder;

  beforeEachProviders(() => [KelvinToCelsiusPipe]);

  beforeEach(inject([ TestComponentBuilder ], (tcb: TestComponentBuilder) => {
    builder = tcb.overrideProviders(
      WeatherWidget,
      [ provide(OpenWeatherApi, { useClass : MockOpenWeatherApi }) ]);
  }));

  it('can create', () => {
    return builder.createAsync(WeatherWidget).then(fixture => {
      expect(fixture).to.exist;
    });
  });

  it('should display the city name', () => {
    return builder.createAsync(WeatherWidget).then(fixture => {
      let component = fixture.componentInstance,
          element = fixture.nativeElement;

      component.city = 'Berlin';

      fixture.detectChanges();
      expect(element.querySelector('.weather__city').innerText)
        .to.equal('Berlin');
    });
  });

  it('should transform the temperature from Kelvin to Celcius and display it',
     () => {
       return builder.createAsync(WeatherWidget).then(fixture => {
         let component = fixture.componentInstance,
             element = fixture.nativeElement;

         component.city = 'Berlin';

         fixture.detectChanges();
         expect(element.querySelector('.weather__detail__temp').innerText)
           .to.equal('21.91°C');
       });
     });

  it('should contain an icon with a url by open weather api', () => {
    return builder.createAsync(WeatherWidget).then(fixture => {
      let component = fixture.componentInstance,
          element = fixture.nativeElement;

      component.city = 'Berlin';

      fixture.detectChanges();
      expect(element.querySelector('img').getAttribute('src'))
        .to.equal('http://openweathermap.org/img/w/01d.png');
      expect(component.generateIconUrl())
        .to.equal('http://openweathermap.org/img/w/01d.png');
    });
  });
});
開發者ID:luhmann,項目名稱:ng2-webpack-weather-widget,代碼行數:59,代碼來源:weather-widget.component.spec.ts

示例5: xdescribe

xdescribe('Component: App', () => {
  let builder: TestComponentBuilder;

  beforeEach(inject([ TestComponentBuilder ], (tcb: TestComponentBuilder) => {
    builder = tcb.overrideProviders(AppComponent, []);
  }));

  it('can create', () => {
    builder.createAsync(AppComponent).then(fixture => {
      expect(fixture).to.exist;
    });
  });
});
開發者ID:luhmann,項目名稱:ng2-webpack-weather-widget,代碼行數:13,代碼來源:app.component.spec.ts

示例6: it

 it("should has text: 'My Test'", async(() => {
   builder.createAsync(AppComponent)
     .then(fixture => {
       let el = fixture.debugElement;
       assert(el.query(By.css("p")).nativeElement.innerHTML === "My Test");
     });
 }));
開發者ID:ovrmrw,項目名稱:angular2-testing-lite-5min-sample,代碼行數:7,代碼來源:app.spec.ts

示例7: inject

    inject([], () => {
      builder
        .createAsync(HomeComponent)
        .then(fixture => {
          assert.equal(fixture.debugElement.nativeElement.innerHTML, `<h3>Home Component</h3>
<p>Welcome to Angular Seed</p>`);
        });
    }))
開發者ID:laco0416,項目名稱:angular2-seed,代碼行數:8,代碼來源:home.spec.ts

示例8: inject

    inject([], () => {
      builder
        .createAsync(AboutComponent)
        .then(fixture => {
          assert.equal(fixture.debugElement.nativeElement.innerHTML, `<h3>About Component</h3>
<p>This is the about component!</p>`);
        });
    }))
開發者ID:laco0416,項目名稱:angular2-seed,代碼行數:8,代碼來源:about.spec.ts

示例9: it

  it('should display the city name', () => {
    return builder.createAsync(WeatherWidget).then(fixture => {
      let component = fixture.componentInstance,
          element = fixture.nativeElement;

      component.city = 'Berlin';

      fixture.detectChanges();
      expect(element.querySelector('.weather__city').innerText)
        .to.equal('Berlin');
    });
  });
開發者ID:luhmann,項目名稱:ng2-webpack-weather-widget,代碼行數:12,代碼來源:weather-widget.component.spec.ts

示例10: expect

     () => {
       return builder.createAsync(WeatherWidget).then(fixture => {
         let component = fixture.componentInstance,
             element = fixture.nativeElement;

         component.city = 'Berlin';

         fixture.detectChanges();
         expect(element.querySelector('.weather__detail__temp').innerText)
           .to.equal('21.91°C');
       });
     });
開發者ID:luhmann,項目名稱:ng2-webpack-weather-widget,代碼行數:12,代碼來源:weather-widget.component.spec.ts


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