当前位置: 首页>>代码示例>>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;未经允许,请勿转载。