From cc7215735dabb37383ec963f57f6a536a08716c2 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Sat, 28 Oct 2017 14:27:54 +0100 Subject: [PATCH] Make tests run in Maven lifecycle --- pom.xml | 10 ++++++++++ src/main/client/package.json | 1 + src/main/client/src/app/app.component.spec.ts | 8 +++++--- src/main/client/src/app/app.component.ts | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 64e23d1..20d0b6d 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,16 @@ run-script build + + npm-test + + npm + + + run-script single-test + + test + diff --git a/src/main/client/package.json b/src/main/client/package.json index 9087e59..6c44eb3 100644 --- a/src/main/client/package.json +++ b/src/main/client/package.json @@ -6,6 +6,7 @@ "ng": "ng", "start": "ng serve", "build": "ng build", + "single-test": "ng test --single-run", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" diff --git a/src/main/client/src/app/app.component.spec.ts b/src/main/client/src/app/app.component.spec.ts index bcbdf36..764fcb4 100644 --- a/src/main/client/src/app/app.component.spec.ts +++ b/src/main/client/src/app/app.component.spec.ts @@ -1,11 +1,13 @@ import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing' describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], declarations: [ AppComponent - ], + ] }).compileComponents(); })); it('should create the app', async(() => { @@ -16,12 +18,12 @@ describe('AppComponent', () => { it(`should have as title 'app'`, async(() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('app'); + expect(app.title).toEqual('Demo'); })); it('should render title in a h1 tag', async(() => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); + expect(compiled.querySelector('h1').textContent).toContain('Welcome Demo!'); })); }); diff --git a/src/main/client/src/app/app.component.ts b/src/main/client/src/app/app.component.ts index 50e6656..3be876a 100644 --- a/src/main/client/src/app/app.component.ts +++ b/src/main/client/src/app/app.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import {HttpClient} from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; @Component({ selector: 'app-root',