Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01d0103

Browse files
Added tests and code linting.
1 parent 4048b72 commit 01d0103

File tree

14 files changed

+289
-28
lines changed

14 files changed

+289
-28
lines changed

‎README.md‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,3 @@ npm run build:universal
3737

3838
npm run serve:universal
3939
```
40-
41-
### ToDo
42-
43-
- Server side linting
44-
- Unit tests on server Code
45-
- e2e tests

‎e2e/app.e2e-spec.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AppPage } from './app.po';
2+
import { ContactPage } from './contact.po';
23

34
describe('angular-nestjs-render App', () => {
45
let page: AppPage;
@@ -9,6 +10,14 @@ describe('angular-nestjs-render App', () => {
910

1011
it('should display welcome message', () => {
1112
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('Welcome to app!');
13+
expect(page.getParagraphText()).toEqual('Universal App ( Server side rendering ) using NestJS and Angular 5+');
14+
});
15+
16+
it('navigate to contact page', async () => {
17+
const contact = new ContactPage();
18+
19+
contact.navigateTo();
20+
const response = await contact.getCodeResponse();
21+
expect(response).toEqual('{ "message": "Hello World!" }');
1322
});
1423
});

‎e2e/contact.po.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { browser, by, element } from 'protractor';
2+
3+
export class ContactPage {
4+
navigateTo() {
5+
return browser.get('/contact');
6+
}
7+
8+
async getCodeResponse() {
9+
return await element(by.css('app-contact code')).getText();
10+
}
11+
}

‎package-lock.json‎

Lines changed: 155 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"scripts": {
66
"ng": "ng",
77
"start": "concurrently --kill-others \"npm run server:watch\" \"ng serve --aot --progress=false --proxy-config proxy.conf.json\"",
8-
"build": "ng build --prod",
9-
"test": "ng test",
10-
"lint": "ng lint",
8+
"client:build": "ng build --prod",
9+
"client:test": "ng test",
10+
"client:lint": "ng lint --fix",
11+
"server:lint": "tslint './src/server/**/*.ts' -c tslint.server.json --fix",
12+
"server:test": "jasmine-ts ./src/server/**/*.spec.ts",
1113
"e2e": "ng e2e",
1214
"server:watch": "nodemon",
1315
"build:universal": "npm run helper:build:client-and-server && npm run helper:webpack:nest",
@@ -42,15 +44,16 @@
4244
"@angular/cli": "1.6.3",
4345
"@angular/compiler-cli": "^5.0.0",
4446
"@angular/language-service": "^5.0.0",
47+
"@types/dotenv": "^4.0.2",
4548
"@types/express": "^4.11.0",
4649
"@types/jasmine": "~2.5.53",
4750
"@types/jasminewd2": "~2.0.2",
48-
"@types/dotenv": "^4.0.2",
4951
"@types/node": "~6.0.60",
5052
"codelyzer": "^4.0.1",
5153
"concurrently": "^3.5.1",
5254
"jasmine-core": "~2.6.2",
5355
"jasmine-spec-reporter": "~4.1.0",
56+
"jasmine-ts": "^0.2.1",
5457
"karma": "~1.7.0",
5558
"karma-chrome-launcher": "~2.1.1",
5659
"karma-cli": "~1.0.1",

‎spec/support/jasmine.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"stopSpecOnExpectationFailure": false,
3+
"random": false,
4+
"reporters": [
5+
{
6+
"name": "jasmine-spec-reporter#SpecReporter",
7+
"options": {
8+
"displayStacktrace": "all"
9+
}
10+
}
11+
]
12+
}

‎src/client/app/app.component.html‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<!--The content below is only a placeholder and can be replaced.-->
22
<div style="text-align:center">
3-
<h1>
4-
Universal App ( Server side rendering ) using NestJS and Angular 5+
5-
</h1>
3+
<h1>Universal App ( Server side rendering ) using NestJS and Angular 5+</h1>
64
<a href="https://angular.io" target="blank"><img height="155px" src="https://angular.io/assets/images/logos/angular/angular.svg" /></a>
75
<a href="http://nestjs.com/" target="blank"><img height="155px" src="http://kamilmysliwiec.com/public/nest-logo.png#1" alt="Nest Logo" /></a>
86
</div>

‎src/client/app/app.component.spec.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
import { TestBed,async } from '@angular/core/testing';
1+
import { async,TestBed } from '@angular/core/testing';
22
import { AppComponent } from './app.component';
3+
import { RouterTestingModule } from '@angular/router/testing';
4+
35
describe('AppComponent', () => {
6+
47
beforeEach(async(() => {
58
TestBed.configureTestingModule({
9+
imports: [
10+
RouterTestingModule,
11+
],
612
declarations: [
713
AppComponent
814
],
915
}).compileComponents();
1016
}));
17+
1118
it('should create the app', async(() => {
1219
const fixture = TestBed.createComponent(AppComponent);
1320
const app = fixture.debugElement.componentInstance;
1421
expect(app).toBeTruthy();
1522
}));
16-
it(`should have as title 'app'`, async(() => {
17-
const fixture = TestBed.createComponent(AppComponent);
18-
const app = fixture.debugElement.componentInstance;
19-
expect(app.title).toEqual('app');
20-
}));
23+
2124
it('should render title in a h1 tag', async(() => {
2225
const fixture = TestBed.createComponent(AppComponent);
2326
fixture.detectChanges();
2427
const compiled = fixture.debugElement.nativeElement;
25-
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
28+
expect(compiled.querySelector('h1').textContent).toContain('Universal App ( Server side rendering ) using NestJS and Angular 5+');
2629
}));
2730
});

‎src/client/app/contact/contact.component.spec.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { ContactComponent } from './contact.component';
4+
import { HttpClientTestingModule } from '@angular/common/http/testing';
45

56
describe('ContactComponent', () => {
67
let component: ContactComponent;
78
let fixture: ComponentFixture<ContactComponent>;
89

910
beforeEach(async(() => {
1011
TestBed.configureTestingModule({
12+
imports: [
13+
HttpClientTestingModule
14+
],
1115
declarations: [ ContactComponent ]
1216
})
1317
.compileComponents();

‎src/server/app.module.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { StaticModule } from './modules/static/static.module';
66
@Module({
77
imports: [
88
ApiModule,
9-
StaticModule
9+
StaticModule,
1010
],
1111
controllers: [],
1212
components: [],

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /