keycloak-memoizeit

proper license and `ng test`

2/23/2017 9:38:09 PM

Details

diff --git a/examples/demo-template/angular2-product-app/src/main/frontend/package.json b/examples/demo-template/angular2-product-app/src/main/frontend/package.json
index 3508122..91223e5 100644
--- a/examples/demo-template/angular2-product-app/src/main/frontend/package.json
+++ b/examples/demo-template/angular2-product-app/src/main/frontend/package.json
@@ -1,7 +1,7 @@
 {
   "name": "angular2-product-app",
   "version": "0.0.0",
-  "license": "MIT",
+  "license": "Apache-2.0",
   "angular-cli": {},
   "scripts": {
     "ng": "ng",
diff --git a/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.html b/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.html
index 5556cf9..163d8db 100644
--- a/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.html
+++ b/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.html
@@ -1,9 +1,9 @@
 <div id="content-area" class="col-md-9" role="main">
   <div id="content">
-    <h1>Angular2 Product (Beta)</h1>
+    <h1>{{title}}</h1>
     <h2><span>Products</span></h2>
     <button type="button" (click)="logout()">Sign Out</button>
-    <button type="button" (click)="reloadData()">Reload</button>
+    <button type="button" id="reload-data" (click)="reloadData()">Reload</button>
     <table class="table" [hidden]="!products.length">
       <thead>
       <tr>
diff --git a/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.spec.ts b/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.spec.ts
index 13c632d..f5fc6c1 100644
--- a/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.spec.ts
+++ b/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.spec.ts
@@ -1,9 +1,32 @@
 import { TestBed, async } from '@angular/core/testing';
 import { AppComponent } from './app.component';
+import { KeycloakService } from './keycloak/keycloak.service';
+import {
+  HttpModule,
+  XHRBackend,
+  ResponseOptions,
+  Response,
+  RequestMethod
+} from '@angular/http';
+import {
+  MockBackend,
+  MockConnection
+} from '@angular/http/testing/mock_backend';
+
 
 describe('AppComponent', () => {
   beforeEach(() => {
     TestBed.configureTestingModule({
+      imports: [HttpModule],
+      providers: [
+        {
+          provide: XHRBackend,
+          useClass: MockBackend
+        },
+        {
+          provide: KeycloakService
+        }
+      ],
       declarations: [
         AppComponent
       ],
@@ -17,16 +40,27 @@ describe('AppComponent', () => {
     expect(app).toBeTruthy();
   }));
 
-  it(`should have as title 'app works!'`, async(() => {
+  it(`should have as title 'Angular2 Product'`, async(() => {
     const fixture = TestBed.createComponent(AppComponent);
     const app = fixture.debugElement.componentInstance;
-    expect(app.title).toEqual('app works!');
+    expect(app.title).toEqual('Angular2 Product');
   }));
 
   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('app works!');
+    expect(compiled.querySelector('h1').textContent).toContain('Angular2 Product');
+  }));
+
+  it('should render product list', async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    fixture.componentInstance.products = ['iphone', 'ipad', 'ipod'];
+    fixture.detectChanges();
+    const compiled = fixture.debugElement.nativeElement;
+    expect(compiled.querySelector('table thead tr th').textContent).toContain('Product Listing');
+    expect(compiled.querySelectorAll('table tbody tr td')[0].textContent).toContain('iphone');
+    expect(compiled.querySelectorAll('table tbody tr td')[1].textContent).toContain('ipad');
+    expect(compiled.querySelectorAll('table tbody tr td')[2].textContent).toContain('ipod');
   }));
 });
diff --git a/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.ts b/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.ts
index 73d116b..28b9b98 100644
--- a/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.ts
+++ b/examples/demo-template/angular2-product-app/src/main/frontend/src/app/app.component.ts
@@ -13,6 +13,8 @@ import { environment } from '../environments/environment';
   styleUrls: ['./app.component.css']
 })
 export class AppComponent {
+  title = 'Angular2 Product';
+
   products: string[] = [];
 
   constructor(private http: Http, private kc: KeycloakService) {}