当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TestBed.overrideComponent方法代码示例

本文整理汇总了TypeScript中@angular/core/testing.TestBed.overrideComponent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestBed.overrideComponent方法的具体用法?TypeScript TestBed.overrideComponent怎么用?TypeScript TestBed.overrideComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/core/testing.TestBed的用法示例。


在下文中一共展示了TestBed.overrideComponent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should throw if mdl-card-actions has no mdl-card parent', () => {

    TestBed.overrideComponent(TestApp, { set: {
      template: '<mdl-card-actions></mdl-card-actions>' }
    });
    let fixture = TestBed.createComponent(TestApp);

    expect( () => fixture.detectChanges() )
      .toThrow();

  });
开发者ID:mseemann,项目名称:angular2-mdl,代码行数:11,代码来源:mdl-card.component.spec.ts

示例2: it

    it('should override the template', async(() => {
      TestBed.overrideComponent(GreetingComponent, {set: {
        template: `<span>Foo {{greeting}}<span>`
      }}).compileComponents().then(() => {
        var fixture = TestBed.createComponent(GreetingComponent);
        fixture.detectChanges();

        var compiled = fixture.debugElement.nativeElement;
        expect(compiled).toHaveText('Foo Enter PIN');
      });
    }));
开发者ID:marcysutton,项目名称:ng2-test-seed,代码行数:11,代码来源:greeting-component_test.ts

示例3: it

    it('should work in a template element', async(() => {
         const template =
             '<div><template [ngIf]="booleanCondition"><span>hello2</span></template></div>';

         TestBed.overrideComponent(TestComponent, {set: {template: template}});
         let fixture = TestBed.createComponent(TestComponent);
         fixture.detectChanges();
         expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'span').length)
             .toEqual(1);
         expect(fixture.debugElement.nativeElement).toHaveText('hello2');
       }));
开发者ID:SekibOmazic,项目名称:angular,代码行数:11,代码来源:ng_if_spec.ts

示例4: it

    it('should support string selector', () => {
      TestBed.overrideComponent(
          ViewChildrenStringSelectorComponent,
          {set: {template: `<simple #child1></simple><simple #child2></simple>`}});
      const view = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
                       .createComponent(ViewChildrenStringSelectorComponent);
      view.detectChanges();
      expect(view.componentInstance.children).toBeDefined();
      expect(view.componentInstance.children.length).toBe(2);

    });
开发者ID:Cammisuli,项目名称:angular,代码行数:11,代码来源:di_spec.ts

示例5: it

  it('should throw if an unsupported colored type is provided', () => {

    TestBed.overrideComponent(MdlTestButtonComponent, { set: {
      template: '<mdl-button mdl-colored="didNotExist"></mdl-button>' }
    });
    let fixture = TestBed.createComponent(MdlTestButtonComponent);

    expect( () => fixture.detectChanges() ).toThrow();


  });
开发者ID:mseemann,项目名称:angular2-mdl,代码行数:11,代码来源:mdl-button.component.spec.ts

示例6: createDashboardTestComponent

 function createDashboardTestComponent() {
   return TestBed
     .overrideComponent(SkyTileDashboardComponent, {
       add: {
         providers: [
           {provide: SkyMediaQueryService, useValue: mockMediaQueryService}
         ]
       }
     })
     .createComponent(TileDashboardTestComponent);
 }
开发者ID:Blackbaud-DanHamlin,项目名称:skyux2,代码行数:11,代码来源:tile-dashboard.service.spec.ts

示例7: beforeEach

 beforeEach(() => {
   TestBed.configureTestingModule({
     declarations: [TestAlertComponent],
     imports: [AlertModule.forRoot()]
   });
   TestBed.overrideComponent(TestAlertComponent, {
     set: {template: overTemplate}
   });
   fixture = TestBed.createComponent(TestAlertComponent);
   context = fixture.debugElement.componentInstance;
   fixture.detectChanges();
 });
开发者ID:OlegDubrovskyi,项目名称:ngx-bootstrap,代码行数:12,代码来源:alert.component.spec.ts

示例8: it

  it('should add the css class mdl-layout__tab-panel to the host element', () => {

    TestBed.overrideComponent(MdlTestComponent, { set: {
      template: '<mdl-layout-tab-panel>x</mdl-layout-tab-panel>' }
    });
    let fixture = TestBed.createComponent(MdlTestComponent);
    fixture.detectChanges();

    let tabPanelEl: HTMLElement = fixture.nativeElement.children.item(0);
    expect(tabPanelEl.classList.contains('mdl-layout__tab-panel')).toBe(true);

  });
开发者ID:mseemann,项目名称:angular2-mdl,代码行数:12,代码来源:mdl-layout-tab-panel.component.spec.ts

示例9: it

    it('should render all components', () => {
        TestBed.overrideComponent(TestContainerComponent, {
            set: {
                template: `
                    ${componentNames.map((name) => `<dx-${name}></dx-${name}>`).join('')}
                `
            }
        });

        let fixture = TestBed.createComponent(TestContainerComponent);
        expect(fixture.detectChanges.bind(fixture)).not.toThrow();
    });
开发者ID:DevExpress,项目名称:devextreme-angular2,代码行数:12,代码来源:ssr-components.spec.ts

示例10: it

    it("it should ...", async(() => {
        TestBed.overrideComponent(BarGraphDirective, {set: {
            template: "<p>Content</p>"
        }});
        TestBed.compileComponents().then(() => {
            let fixture = TestBed.createComponent(BarGraphDirective);
            fixture.detectChanges();
            let compiled = fixture.debugElement.nativeElement;

            expect(fixture).toBeTruthy();
        });
    }));
开发者ID:theAlgorithmist,项目名称:Angular2CLI-D3,代码行数:12,代码来源:bar-graph.directive.spec.ts


注:本文中的@angular/core/testing.TestBed.overrideComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。