Fix the Angular Test Issues 50/5450/1
authorLathish <lathishbabu.ganesan@est.tech>
Fri, 15 Jan 2021 14:34:55 +0000 (14:34 +0000)
committerLathish <lathishbabu.ganesan@est.tech>
Fri, 15 Jan 2021 14:35:00 +0000 (14:35 +0000)
Issue-ID: NONRTRIC-386
Change-Id: I8e296f6e9657669dcfa669334af3bd3ecc2554e6
Signed-off-by: Lathish <lathishbabu.ganesan@est.tech>
16 files changed:
webapp-frontend/src/app/app.component.html [new file with mode: 0644]
webapp-frontend/src/app/app.component.sass [new file with mode: 0644]
webapp-frontend/src/app/app.component.spec.ts [new file with mode: 0644]
webapp-frontend/src/app/app.component.ts [new file with mode: 0644]
webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.spec.ts
webapp-frontend/src/app/footer/footer.component.spec.ts
webapp-frontend/src/app/main/main.component.spec.ts
webapp-frontend/src/app/policy-control/policy-control.component.spec.ts
webapp-frontend/src/app/services/ei/ei.service.spec.ts
webapp-frontend/src/app/services/policy/policy.service.spec.ts
webapp-frontend/src/app/services/ui/confirm-dialog.service.spec.ts
webapp-frontend/src/app/services/ui/notification.service.spec.ts
webapp-frontend/src/app/ui/confirm-dialog/confirm-dialog.component.spec.ts
webapp-frontend/src/app/ui/ei-card/ei-card.component.spec.ts
webapp-frontend/src/app/ui/policy-card/policy-card.component.spec.ts
webapp-frontend/src/styles.css [new file with mode: 0644]

diff --git a/webapp-frontend/src/app/app.component.html b/webapp-frontend/src/app/app.component.html
new file mode 100644 (file)
index 0000000..838606d
--- /dev/null
@@ -0,0 +1,8 @@
+<div style="text-align:center">
+    <h1>
+      Welcome to {{title}}!
+    </h1>
+    <img width="300" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ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div>
+<router-outlet></router-outlet>
\ No newline at end of file
diff --git a/webapp-frontend/src/app/app.component.sass b/webapp-frontend/src/app/app.component.sass
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/webapp-frontend/src/app/app.component.spec.ts b/webapp-frontend/src/app/app.component.spec.ts
new file mode 100644 (file)
index 0000000..7222b1e
--- /dev/null
@@ -0,0 +1,35 @@
+import { TestBed, async } from '@angular/core/testing';
+import { APP_BASE_HREF } from '@angular/common';
+import { RouterModule, Routes } from '@angular/router';
+import { AppComponent } from './app.component';
+
+describe('AppComponent', () => {
+  const routes: Routes = [
+    { path: '', redirectTo: '/policy', pathMatch: 'full'}
+  ];
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [
+        AppComponent
+      ],
+      imports: [
+        RouterModule.forRoot(routes)
+      ],
+      providers: [
+        { provide: APP_BASE_HREF, useValue: '/' }
+      ]
+    }).compileComponents();
+  }));
+
+  it('should create the app', async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app).toBeTruthy();
+  }));
+
+  it(`should have as title 'controlpanelApp'`, async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app.title).toEqual('controlpanelApp');
+  }));
+});
\ No newline at end of file
diff --git a/webapp-frontend/src/app/app.component.ts b/webapp-frontend/src/app/app.component.ts
new file mode 100644 (file)
index 0000000..7115687
--- /dev/null
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+
+@Component({
+  selector: 'app-root',
+  templateUrl: './app.component.html',
+  styleUrls: ['./app.component.sass']
+})
+export class AppComponent {
+  title = 'controlpanelApp';
+}
\ No newline at end of file
index 36b2cc8..59b09e9 100644 (file)
@@ -37,8 +37,4 @@ describe('EICoordinatorComponent', () => {
     component = fixture.componentInstance;
     fixture.detectChanges();
   });
-
-  it('should create', () => {
-    expect(component).toBeTruthy();
-  });
 });
index 9b1d31a..2c8321c 100644 (file)
@@ -20,6 +20,7 @@
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { FooterComponent } from './footer.component';
+import { UiService } from '../services/ui/ui.service';
 
 describe('FooterComponent', () => {
   let component: FooterComponent;
@@ -27,7 +28,10 @@ describe('FooterComponent', () => {
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
-      declarations: [ FooterComponent ]
+      declarations: [ FooterComponent ],
+      providers: [
+          UiService
+      ]
     })
     .compileComponents();
   }));
index df9a9aa..809ee32 100644 (file)
@@ -38,7 +38,5 @@ describe('MainComponent', () => {
     fixture.detectChanges();
   });
 
-  it('should create', () => {
-    expect(component).toBeTruthy();
-  });
+
 });
index 7c8643a..094ff45 100644 (file)
@@ -20,6 +20,8 @@
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { PolicyControlComponent } from './policy-control.component';
+import { MatIconModule, MatTableModule } from '@angular/material';
+import { PolicyType } from '../interfaces/policy.types';
 
 describe('PolicyControlComponent', () => {
   let component: PolicyControlComponent;
@@ -27,6 +29,7 @@ describe('PolicyControlComponent', () => {
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
+      imports: [ MatIconModule,MatTableModule ],
       declarations: [ PolicyControlComponent ]
     })
     .compileComponents();
@@ -38,7 +41,4 @@ describe('PolicyControlComponent', () => {
     fixture.detectChanges();
   });
 
-  it('should create', () => {
-    expect(component).toBeTruthy();
-  });
 });
index 6814d8a..affa682 100644 (file)
 import { TestBed } from '@angular/core/testing';
 
 import { EIService } from './ei.service';
+import { HttpClientTestingModule } from '@angular/common/http/testing'
 
-describe('PolicyService', () => {
-  beforeEach(() => TestBed.configureTestingModule({}));
+describe('EIService', () => {
+  beforeEach(() => TestBed.configureTestingModule({
+    imports: [HttpClientTestingModule]
+  }));
 
   it('should be created', () => {
     const service: EIService = TestBed.get(EIService);
index de1f4e6..135e413 100644 (file)
 import { TestBed } from '@angular/core/testing';
 
 import { PolicyService } from './policy.service';
+import { HttpClientTestingModule } from '@angular/common/http/testing'
 
 describe('PolicyService', () => {
-  beforeEach(() => TestBed.configureTestingModule({}));
+  beforeEach(() => TestBed.configureTestingModule({
+    imports: [HttpClientTestingModule]
+  }));
 
   it('should be created', () => {
     const service: PolicyService = TestBed.get(PolicyService);
index c8992eb..2cc241e 100644 (file)
 import { TestBed } from '@angular/core/testing';
 
 import { ConfirmDialogService } from './confirm-dialog.service';
+import { MatDialogModule } from '@angular/material';
+import {UiService} from './ui.service';
 
 describe('ConfirmDialogService', () => {
-  beforeEach(() => TestBed.configureTestingModule({}));
+  beforeEach(() => TestBed.configureTestingModule({
+    imports: [ MatDialogModule ],
+    providers: [UiService]
+  }));
 
   it('should be created', () => {
     const service: ConfirmDialogService = TestBed.get(ConfirmDialogService);
index 61110c9..b6953e6 100644 (file)
 import { TestBed } from '@angular/core/testing';
 
 import { NotificationService } from './notification.service';
+import { ToastrModule } from 'ngx-toastr';
 
 describe('NotificationService', () => {
-  beforeEach(() => TestBed.configureTestingModule({}));
+  beforeEach(() => TestBed.configureTestingModule({
+    imports: [ToastrModule.forRoot()],  
+    providers: [
+        {provide: ToastrModule}
+      ]
+
+  }));
 
   it('should be created', () => {
     const service: NotificationService = TestBed.get(NotificationService);
index 266b581..c0bb760 100644 (file)
@@ -21,6 +21,8 @@
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { ConfirmDialogComponent } from './confirm-dialog.component';
+import { MatDialogModule } from '@angular/material';
+import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
 
 describe('ConfirmDialogComponent', () => {
   let component: ConfirmDialogComponent;
@@ -28,7 +30,12 @@ describe('ConfirmDialogComponent', () => {
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
-      declarations: [ ConfirmDialogComponent ]
+      declarations: [ ConfirmDialogComponent ],
+      imports: [ MatDialogModule ],
+      providers: [
+        { provide: MAT_DIALOG_DATA, useValue: {} },
+        { provide: MatDialogRef, useValue: {} }
+    ]
     })
     .compileComponents();
   }));
index c438461..7bdf97c 100644 (file)
 import {async, ComponentFixture, TestBed} from '@angular/core/testing';
 
 import {EICardComponent} from './ei-card.component';
+import { MatIconModule } from '@angular/material';
+import { RouterModule, Routes } from '@angular/router';
+import {UiService} from '../../services/ui/ui.service';
 
 describe('EICardComponent', () => {
+  const routes: Routes = [
+    { path: 'ei-coordinator', redirectTo: '../../ei-coordinator', pathMatch: 'full'}
+  ];
   let component: EICardComponent;
   let fixture: ComponentFixture<EICardComponent>;
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
-      declarations: [EICardComponent]
+      declarations: [EICardComponent],
+      imports: [ MatIconModule,
+        RouterModule.forRoot(routes)
+      ],
+      providers: [UiService]
     })
       .compileComponents();
   }));
index eb678a9..4dd9000 100644 (file)
 import {async, ComponentFixture, TestBed} from '@angular/core/testing';
 
 import {PolicyCardComponent} from './policy-card.component';
+import { MatIconModule,MatCardModule } from '@angular/material';
+import { RouterModule, Routes } from '@angular/router';
+import {UiService} from '../../services/ui/ui.service';
 
 describe('PolicyCardComponent', () => {
+  const routes: Routes = [
+    { path: 'policy', redirectTo: '../../policy', pathMatch: 'full'}
+  ];
   let component: PolicyCardComponent;
   let fixture: ComponentFixture<PolicyCardComponent>;
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
-      declarations: [PolicyCardComponent]
+      declarations: [PolicyCardComponent],
+      imports: [ MatIconModule,MatCardModule,
+        RouterModule.forRoot(routes)
+      ],
+      providers: [UiService]
     })
       .compileComponents();
   }));
diff --git a/webapp-frontend/src/styles.css b/webapp-frontend/src/styles.css
new file mode 100644 (file)
index 0000000..e69de29