當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。