Skip to content
This repository was archived by the owner on Jan 23, 2022. It is now read-only.

Commit 2be4f2e

Browse files
committed
Made basic unit tests work
1 parent 3ad3a31 commit 2be4f2e

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

generators/app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ module.exports = yeoman.Base.extend({
7474
"./protractor.conf.js",
7575
"./src/app/app.component.css",
7676
"./src/app/app.component.html",
77-
"./src/app/app.component.spec.ts",
7877
"./src/app/app.module.ts",
7978
"./src/app/index.ts",
8079
"./src/app/shared/auth.service.ts",
@@ -97,6 +96,7 @@ module.exports = yeoman.Base.extend({
9796
"./package.json",
9897
"./README.md",
9998
"./src/app/app.component.ts",
99+
"./src/app/app.component.spec.ts",
100100
"./src/environments/firebaseConfig.ts",
101101
"./src/index.html"
102102
];

generators/app/templates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"ng2-bootstrap": "^1.1.16-9",
2828
"rxjs": "^5.0.2",
2929
"ts-helpers": "^1.1.1",
30-
"zone.js": "^0.7.4"
30+
"zone.js": "0.7.2"
3131
},
3232
"devDependencies": {
3333
"@angular/compiler-cli": "^2.4.1",

generators/app/templates/src/app/app.component.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22

33
import { TestBed, async } from '@angular/core/testing';
44
import { AppComponent } from './app.component';
5+
import { AuthService } from './shared/auth.service';
6+
import { FormsModule } from '@angular/forms';
7+
import {AsyncSubject} from "rxjs";
58

69
describe('AppComponent', () => {
710
beforeEach(() => {
11+
let authServiceStub = {
12+
login: function () { return true },
13+
logout: function () { return true },
14+
isLoggedIn: function () {
15+
return new AsyncSubject<boolean>();
16+
}
17+
};
18+
819
TestBed.configureTestingModule({
20+
imports: [ FormsModule ],
921
declarations: [
1022
AppComponent
1123
],
24+
providers: [
25+
{ provide: AuthService, useValue: authServiceStub }
26+
]
1227
});
1328
});
1429

@@ -21,13 +36,13 @@ describe('AppComponent', () => {
2136
it(`should have as title 'app works!'`, async(() => {
2237
let fixture = TestBed.createComponent(AppComponent);
2338
let app = fixture.debugElement.componentInstance;
24-
expect(app.title).toEqual('app works!');
39+
expect(app.title).toEqual('app works! - <%= name %>');
2540
}));
2641

2742
it('should render title in a h1 tag', async(() => {
2843
let fixture = TestBed.createComponent(AppComponent);
2944
fixture.detectChanges();
3045
let compiled = fixture.debugElement.nativeElement;
31-
expect(compiled.querySelector('h1').textContent).toContain('app works!');
46+
expect(compiled.querySelector('h1').textContent).toContain('app works! - <%= name %>');
3247
}));
3348
});

generators/app/templates/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {UserInfo} from "app/shared/user-info";
99
styleUrls: ['./app.component.css']
1010
})
1111
export class AppComponent {
12-
title = 'app works! - ' + 'myproject';
12+
title = 'app works! - <%= name %>';
1313

1414
email: string;
1515
password: string;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-angular2-firebase-bootstrap",
3-
"version": "1.0.5",
3+
"version": "1.0.6-SNAPSHOT",
44
"description": "Generator for Angular 2 - Firebase - Bootstrap projects",
55
"homepage": "",
66
"author": {

0 commit comments

Comments
 (0)