Fix unit tests by importing forms module
parent
eb920abce8
commit
2637ff84ca
|
@ -1,12 +1,14 @@
|
|||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { NameComponent } from './name/name.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [RouterTestingModule],
|
||||
declarations: [AppComponent]
|
||||
imports: [RouterTestingModule, ReactiveFormsModule],
|
||||
declarations: [AppComponent, NameComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
|
@ -16,18 +18,4 @@ describe('AppComponent', () => {
|
|||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have as title 'parent-form'`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app.title).toEqual('parent-form');
|
||||
});
|
||||
|
||||
it('should render title in a h1 tag', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
expect(compiled.querySelector('h1').textContent).toContain(
|
||||
'Welcome to parent-form!'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NameComponent } from './name.component';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
describe('NameComponent', () => {
|
||||
let component: NameComponent;
|
||||
|
@ -8,6 +9,7 @@ describe('NameComponent', () => {
|
|||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ReactiveFormsModule],
|
||||
declarations: [ NameComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
|
Loading…
Reference in New Issue