Fix unit tests by importing forms module

master
Kevin C. Coram 2019-08-27 23:39:11 -04:00
parent eb1422923f
commit c9bdc71680
Signed by: kevin
GPG Key ID: 0342351B3D61AD35
2 changed files with 6 additions and 16 deletions

View File

@ -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!'
);
});
});

View File

@ -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();