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


TypeScript testing.ComponentFixture類代碼示例

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


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

示例1:

 return tcb.createAsync(MyMainComponent).then((fixture: ComponentFixture<any>) => {
   fixture.detectChanges();
 });
開發者ID:Kungkrist,項目名稱:EventFinder,代碼行數:3,代碼來源:my-main.component.spec.ts

示例2: expect

 .then((fixture: ComponentFixture<TestComponent>) => {
   fixture.detectChanges();
   expect(highlightHtml(fixture)).toBe(`<span class="ngb-highlight">0</span>`);
 });
開發者ID:Brocco,項目名稱:ng-bootstrap,代碼行數:4,代碼來源:highlight.spec.ts

示例3: describe

  describe('navigation', () => {

    var tcb: TestComponentBuilder;
    var fixture: ComponentFixture<any>;
    var rtr: any /** TODO #9100 */;

    beforeEachProviders(() => TEST_ROUTER_PROVIDERS);

    beforeEach(inject([TestComponentBuilder, Router], (tcBuilder: any /** TODO #9100 */, router: any /** TODO #9100 */) => {
      tcb = tcBuilder;
      rtr = router;
      childCmpInstanceCount = 0;
      cmpInstanceCount = 0;
    }));

    it('should work in a simple case', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
         compile(tcb)
             .then((rtc) => {fixture = rtc})
             .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
             .then((_) => rtr.navigateByUrl('/test'))
             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('hello');
               async.done();
             });
       }));


    it('should navigate between components with different parameters',
       inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
         compile(tcb)
             .then((rtc) => {fixture = rtc})
             .then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})]))
             .then((_) => rtr.navigateByUrl('/user/brian'))
             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('hello brian');
             })
             .then((_) => rtr.navigateByUrl('/user/igor'))
             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('hello igor');
               async.done();
             });
       }));

    it('should navigate to child routes', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
         compile(tcb, 'outer { <router-outlet></router-outlet> }')
             .then((rtc) => {fixture = rtc})
             .then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
             .then((_) => rtr.navigateByUrl('/a/b'))
             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
               async.done();
             });
       }));

    it('should navigate to child routes that capture an empty path',
       inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {

         compile(tcb, 'outer { <router-outlet></router-outlet> }')
             .then((rtc) => {fixture = rtc})
             .then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
             .then((_) => rtr.navigateByUrl('/a'))
             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
               async.done();
             });
       }));

    it('should navigate to child routes when the root component has an empty path',
       inject([AsyncTestCompleter, Location], (async: any /** TODO #9100 */, location: any /** TODO #9100 */) => {
         compile(tcb, 'outer { <router-outlet></router-outlet> }')
             .then((rtc) => {fixture = rtc})
             .then((_) => rtr.config([new Route({path: '/...', component: ParentCmp})]))
             .then((_) => rtr.navigateByUrl('/b'))
             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
               expect(location.urlChanges).toEqual(['/b']);
               async.done();
             });
       }));

    it('should navigate to child routes of async routes', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
         compile(tcb, 'outer { <router-outlet></router-outlet> }')
             .then((rtc) => {fixture = rtc})
             .then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})]))
             .then((_) => rtr.navigateByUrl('/a/b'))
             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
               async.done();
             });
       }));


    it('should replace state when normalized paths are equal',
//.........這裏部分代碼省略.........
開發者ID:aftab10662,項目名稱:angular,代碼行數:101,代碼來源:navigation_spec.ts

示例4: expect

 expect(() => {
   fixture.detectChanges();
 }).toThrowError(/tile with colspan 5 is wider than grid/);
開發者ID:Angular2-BD,項目名稱:material2,代碼行數:3,代碼來源:grid-list.spec.ts

示例5: expect

 .then((_) => {
   rootTC.detectChanges();
   expect(rootTC.debugElement.nativeElement).toHaveText('goodbye');
   expect(location.urlChanges).toEqual(['/bye']);
   async.done();
 });
開發者ID:davewragg,項目名稱:angular,代碼行數:6,代碼來源:redirect_route_spec.ts

示例6: expect

 .then((_) => {
   fixture.detectChanges();
   expect(fixture.debugElement.nativeElement).toHaveText('hello igor');
   async.done();
 });
開發者ID:aftab10662,項目名稱:angular,代碼行數:5,代碼來源:navigation_spec.ts


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