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


TypeScript TestComponentBuilder.overrideProviders方法代碼示例

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


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

示例1: async

 async(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
   tcb.overrideProviders(TestComponent, providerArr)
     .createAsync(TestComponent)
     .then((fixture) => {
       expect(fixture.nativeElement.innerText.indexOf('HOME')).toBeTruthy();
     });
 })));
開發者ID:martinsvb,項目名稱:Angular2_bootstrap_seed,代碼行數:7,代碼來源:app.component.spec.ts

示例2: async

 async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
   tcb.overrideProviders(TestComponent, providerArr)
     .createAsync(TestComponent)
     .then((fixture) => {
       expect(true).toBeTruthy();
     });
 })));
開發者ID:arianht,項目名稱:meantweets,代碼行數:7,代碼來源:app.component.spec.ts

示例3: async

      async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        tcb.overrideProviders(TestComponent, providerArr)
          .createAsync(TestComponent)
          .then((rootTC: any) => {

            rootTC.detectChanges();

            let homeInstance = rootTC.debugElement.children[0].componentInstance;
            let homeDOMEl = rootTC.debugElement.children[0].nativeElement;

            expect(homeInstance.nameListService).toEqual(jasmine.any(NameListService));
            expect(getDOM().querySelectorAll(homeDOMEl, 'li').length).toEqual(0);

            spyOn(homeInstance.nameListService, 'add').and.callFake((name) => {
              homeInstance.nameList.push(name);
            });

            homeInstance.newName = 'Minko';
            homeInstance.addName();

            rootTC.detectChanges();

            expect(getDOM().querySelectorAll(homeDOMEl, 'li').length).toEqual(1);
            expect(getDOM().querySelectorAll(homeDOMEl, 'li')[0].textContent).toEqual('Minko');
          });
      })));
開發者ID:wawyed,項目名稱:angular2-seed,代碼行數:26,代碼來源:home.component.spec.ts

示例4: it

  it('should initialize displaying a specific task', done => {
    // We mock the TaskService provider with some fake data
    let mockTaskService = {
      taskStore: [{
          name: 'Task A'
        }, {
          name: 'Task B'
        }, {
          name: 'Task C'
        }
      ]
    };

    testComponentBuilder
    .overrideProviders(TimerWidgetComponent, [
      provide(RouteParams, { useValue: new RouteParams({ id: '1' }) }),
      provide(TaskService, { useValue: mockTaskService })
    ])
    .createAsync(TimerWidgetComponent)
    .then(componentFixture => {
      componentFixture.componentInstance.ngOnInit();
      componentFixture.detectChanges();

      expect(componentFixture.componentInstance.taskName).toEqual('Task B');
      expect(componentFixture.nativeElement.querySelector('small')).toHaveText('Task B');

      componentFixture.destroy();
      done();
    })
    .catch(e => done.fail(e));
  });
開發者ID:Jabirfayyaz,項目名稱:learning-angular2,代碼行數:31,代碼來源:timer-widget.component.spec.ts

示例5: inject

            inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
                return tcb
                    .overrideProviders(AlfrescoSearchComponent, [
                        { provide: AlfrescoSearchService, useClass: SearchServiceMock }
                    ])
                    .createAsync(AlfrescoSearchComponent)
                    .then((fixture) => {
                        let componentInstance = fixture.componentInstance;
                        componentInstance.results = [{
                            entry: {
                                id: '123',
                                name: 'MyDoc',
                                content: {
                                    mimetype: 'text/plain'
                                },
                                isFile: true
                            }
                        }];
                        fixture.detectChanges(componentInstance.results[0]);
                        componentInstance.preview.subscribe(e => {
                            expect(e.value).toBe(componentInstance.results[0]);
                        });
                        componentInstance.onItemClick();

                    });
            }));
開發者ID:binduwavell,項目名稱:alfresco-ng2-components,代碼行數:26,代碼來源:alfresco-search.component.spec.ts

示例6: async

      async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        tcb.overrideProviders(TestComponent, providerArr)
          .createAsync(TestComponent)
          .then((rootTC: any) => {
            let aboutDOMEl = rootTC.debugElement.children[0].nativeElement;

	    expect(getDOM().querySelectorAll(aboutDOMEl, 'h2')[0].textContent).toEqual('Features');
          });
        })));
開發者ID:gkoum,項目名稱:giesu,代碼行數:9,代碼來源:graph-creation.component.spec.ts

示例7: async

      async(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
        tcb.overrideProviders(TestComponent, providerArr)
          .createAsync(TestComponent)
          .then((rootTC:any) => {
            let forgotDOMEl = rootTC.debugElement.children[0].nativeElement;

            expect(getDOM().querySelectorAll(forgotDOMEl, 'h3')[0].textContent)
              .toEqual('Enter your email address to receive a reminder email.');
          });
      })));
開發者ID:everve,項目名稱:slsplay,代碼行數:10,代碼來源:forgot.component.e2e-spec.ts

示例8: it

 it('should create the component', inject([], () => {
   return builder
     .overrideProviders(SignUpComponent, [authenticationServiceProviderMock])
     .overrideDirective(SignUpComponent, MessageComponent, EmptyComponent)
     .createAsync(SignUpComponentTestController)
     .then((fixture: ComponentFixture<any>) => {
       let query = fixture.debugElement.query(By.directive(SignUpComponent));
       expect(query).toBeTruthy();
       expect(query.componentInstance).toBeTruthy();
     });
 }));
開發者ID:equalize-squad,項目名稱:equalizei-front,代碼行數:11,代碼來源:sign-up.component.spec.ts

示例9: spyOn

 (tcb: TestComponentBuilder) => {
   spyOn(service, 'list').and.returnValue(Observable.of([
     {name: 'Lyon'},
     {name: 'Los Angeles'},
     {name: 'Sidney'},
     {name: 'Tokyo'},
     {name: 'Casablanca'}
   ]));
   return tcb.overrideProviders(RacesComponent, [provide(RaceService, {useValue: service})])
     .createAsync(RacesComponent)
     .then(f => fixture = f);
 }
開發者ID:Onra,項目名稱:ponyracer,代碼行數:12,代碼來源:races.component.spec.ts

示例10: async

 return async(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
   tcb
     .overrideProviders(FollowBtnComponent, [
       {provide: FollowBtnService, useValue: followBtnService}
     ])
     .createAsync(TestComponent)
     .then((fixture:ComponentFixture<any>) => {
       testCmpDebugElement = fixture.debugElement;
       cmpDebugElement = testCmpDebugElement.query(By.directive(FollowBtnComponent));
       fixture.detectChanges();
     });
 }));
開發者ID:Angular-Reference,項目名稱:angular2-app,代碼行數:12,代碼來源:follow-btn.component.spec.ts


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