From c9bdc7168015564c21ae1f0ef922acbdbe9cebd1 Mon Sep 17 00:00:00 2001 From: "Kevin C. Coram" Date: Tue, 27 Aug 2019 23:39:11 -0400 Subject: [PATCH] Fix unit tests by importing forms module --- .../parent-form/src/app/app.component.spec.ts | 20 ++++--------------- .../src/app/name/name.component.spec.ts | 2 ++ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/apps/parent-form/src/app/app.component.spec.ts b/apps/parent-form/src/app/app.component.spec.ts index 5b9db6c..1f20bd8 100644 --- a/apps/parent-form/src/app/app.component.spec.ts +++ b/apps/parent-form/src/app/app.component.spec.ts @@ -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!' - ); - }); }); diff --git a/apps/parent-form/src/app/name/name.component.spec.ts b/apps/parent-form/src/app/name/name.component.spec.ts index ec53998..f072f64 100644 --- a/apps/parent-form/src/app/name/name.component.spec.ts +++ b/apps/parent-form/src/app/name/name.component.spec.ts @@ -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();