Skip to content

Commit

Permalink
Make tests run in Maven lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Oct 28, 2017
1 parent ed43fb1 commit cc72157
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@
<arguments>run-script build</arguments>
</configuration>
</execution>
<execution>
<id>npm-test</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script single-test</arguments>
</configuration>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
1 change: 1 addition & 0 deletions src/main/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions src/main/client/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand All @@ -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!');
}));
});
2 changes: 1 addition & 1 deletion src/main/client/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit cc72157

Please sign in to comment.