From aa4eca9829469b6b233b7032a0687e9c95d41487 Mon Sep 17 00:00:00 2001
From: Arundathi Patil <arundpil@in.ibm.com>
Date: Fri, 25 Jan 2019 14:24:23 +0530
Subject: Test case -app component

Configured test bed for app component and added test case to cover the
entire component.

Issue-ID: USECASEUI-195
Change-Id: I68637596b4ee9b8af78ea2b0e3dcec7f4b7cda07
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
---
 usecaseui-portal/src/app/app.component.spec.ts | 27 +++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

(limited to 'usecaseui-portal/src/app')

diff --git a/usecaseui-portal/src/app/app.component.spec.ts b/usecaseui-portal/src/app/app.component.spec.ts
index bcbdf36b..54f42b55 100644
--- a/usecaseui-portal/src/app/app.component.spec.ts
+++ b/usecaseui-portal/src/app/app.component.spec.ts
@@ -1,11 +1,24 @@
 import { TestBed, async } from '@angular/core/testing';
+import { RouterTestingModule } from '@angular/router/testing';
+import { NgZorroAntdModule } from 'ng-zorro-antd';
+import { TranslateModule, TranslateLoader, TranslateService, TranslateFakeLoader} from '@ngx-translate/core';
+
 import { AppComponent } from './app.component';
+
 describe('AppComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [
         AppComponent
       ],
+      imports: [
+        RouterTestingModule,
+        NgZorroAntdModule,
+        TranslateModule.forRoot({loader: { provide: TranslateLoader, useClass: TranslateFakeLoader }})
+      ],
+      providers: [
+        TranslateService
+      ]
     }).compileComponents();
   }));
   it('should create the app', async(() => {
@@ -13,15 +26,11 @@ describe('AppComponent', () => {
     const app = fixture.debugElement.componentInstance;
     expect(app).toBeTruthy();
   }));
-  it(`should have as title 'app'`, async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.debugElement.componentInstance;
-    expect(app.title).toEqual('app');
-  }));
-  it('should render title in a h1 tag', async(() => {
+
+  it('should change Language', async(() => {
     const fixture = TestBed.createComponent(AppComponent);
-    fixture.detectChanges();
-    const compiled = fixture.debugElement.nativeElement;
-    expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
+    const component = fixture.debugElement.componentInstance;
+    component.changeLanguage("zh");
+    expect(component.selectLanguage).toBe("zh");
   }));
 });
-- 
cgit