summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts61
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts57
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts107
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts64
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts69
5 files changed, 307 insertions, 51 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts
index 4a12cd9f..ecbbcc60 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts
@@ -4,7 +4,7 @@
* ===================================================================
* Copyright © 2019 AT&T Intellectual Property. All rights reserved.
* ===================================================================
- * Modification Copyright © 2020 IBM.
+ * * Modification Copyright © 2020 IBM.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -37,7 +37,7 @@
*
*
*/
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { HttpClientModule } from '@angular/common/http';
@@ -47,15 +47,23 @@ import { LayoutModule } from '../../layout.module';
import { CookieService } from 'ngx-cookie-service';
import { HeaderService } from 'src/app/shared/services/header/header.service';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { Router } from '@angular/router';
+import { MockBackend, MockConnection } from '@angular/http/testing';
+//import { observable, Observable } from 'rxjs';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
+import { BaseRequestOptions, Http } from '@angular/http';
describe('HeaderComponent', () => {
let headerService:HeaderService;
+ let cookieService:CookieService;
+ let router:Router;
let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;
+ let spy: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
- providers:[CookieService],
imports: [
LayoutModule,
RouterTestingModule,
@@ -63,6 +71,13 @@ describe('HeaderComponent', () => {
HttpClientModule,
HttpClientTestingModule
],
+ providers:[CookieService,HeaderService,MockBackend, BaseRequestOptions, {
+ provide: Http,
+ useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
+ return new Http(backend, defaultOptions);
+ },
+ deps: [MockBackend, BaseRequestOptions],
+ }]
})
.compileComponents();
}));
@@ -72,27 +87,35 @@ describe('HeaderComponent', () => {
component = fixture.componentInstance;
fixture.detectChanges();
headerService = TestBed.get(HeaderService);
+ cookieService=TestBed.get(CookieService);
+
});
it('should create', () => {
expect(component).toBeTruthy();
});
- it('should test ngOnInit method',()=>{
- fixture.detectChanges();
- component.ngOnInit();
- if(component.cookieService.get('show_app_header')=='false')
- expect(component.showHeader).toBe(false);
- expect(component.pushRightClass).toEqual('push-right');
- (done: DoneFn)=> {
- headerService.getTopMenuItems().subscribe(res=>{
- expect(component.response).toEqual(res);
- expect(component.userFirstName).toBe(component.response.firstName);
- expect(component.userEmail).toBe(component.response.email);
- expect(component.userId).toBe(component.response.userId);
- expect(component.userName).toBe(component.response.userName);
- done();
+ describe('should test ngOnInit',()=>{
+ it('should validate on ngOnInit',()=>{
+ let spy=spyOn(headerService, 'getTopMenuItems').and.returnValue(Observable.of('you object'));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
})
- }
- });
+ })
+
+
+ it('should test isToggled method',()=>{
+ expect(component.isToggled()).toBe(false);
+ })
+
+ it('should test toggleSidebar method',()=>{
+ component.pushRightClass="kumar";
+ expect(component.toggleSidebar()).toBeUndefined;
+ })
+
+ it('should test on onLoggedout method',()=>{
+ expect(localStorage.getItem('isLoggedin')).toBeFalsy
+ })
+
+
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts
index ad425219..38902784 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts
@@ -41,27 +41,47 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { HttpClientModule } from '@angular/common/http';
-//import { CookieModule, CookieService } from 'ngx-cookie';
import { SidebarComponent } from './sidebar.component';
import { LayoutModule } from '../../layout.module';
import { Session } from 'protractor';
import { CookieService } from 'ngx-cookie-service';
+import { SidebarService } from 'src/app/shared/services';
+import { ReplaySubject } from 'rxjs';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
+import { BaseRequestOptions, Http, XHRBackend } from '@angular/http';
+import { MockBackend } from '@angular/http/testing';
+import { environment } from 'src/environments/environment';
+import { inject } from '@angular/core';
+import { Response } from '@angular/http';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('SidebarComponent', () => {
let component: SidebarComponent;
let fixture: ComponentFixture<SidebarComponent>;
+ let sidebarService: SidebarService;
+ let spy:any;
+
+ let mockSidebarService = {
+ navigate: jasmine.createSpy('navigate')
+ };
beforeEach(async(() => {
TestBed.configureTestingModule({
- providers:[CookieService],
imports: [
LayoutModule,
RouterTestingModule,
TranslateModule.forRoot(),
HttpClientModule,
- // CookieModule.forRoot()
+ HttpClientTestingModule
],
- // providers:[CookieService]
+ providers:[CookieService, SidebarService,MockBackend, BaseRequestOptions, {
+ provide: Http,
+ useFactory: (backend: XHRBackend, defaultOptions: BaseRequestOptions) => {
+ return new Http(backend, defaultOptions);
+ },
+ deps: [MockBackend, BaseRequestOptions],
+ }],
})
.compileComponents();
}));
@@ -70,12 +90,26 @@ describe('SidebarComponent', () => {
fixture = TestBed.createComponent(SidebarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ sidebarService = TestBed.get(SidebarService);
});
it('should create', () => {
expect(component).toBeTruthy();
});
+ describe('should test ngOnInit',()=>{
+ it('should validate on ngOnInit',(done)=>{
+ var result=sidebarService.getLeftMenu()
+ spy=spyOn(sidebarService, 'getLeftMenu').and.returnValue(result);
+ fixture.detectChanges();
+ sidebarService.getLeftMenu();
+ expect(spy).toHaveBeenCalled();
+ component.ngOnInit();
+ done()
+ //expect(component.result).toEqual(result)
+ })
+ })
+
it('should test addExpandClass if element and showMenu variable value are same', () => {
component.showMenu= '1';
component.addExpandClass('1');
@@ -100,8 +134,17 @@ describe('SidebarComponent', () => {
expect(component.isActive).toBe(false);
});
- it('should test ngOnInit function', () => {
- component.ngOnInit();
- });
+ it('should test isToggled method',()=>{
+ expect(component.isToggled()).toBe(false);
+ })
+
+ it('should test toggleSidebar method',()=>{
+ component.pushRightClass="kumar";
+ expect(component.toggleSidebar()).toBeUndefined;
+ })
+
+ it('should test on onLoggedout method',()=>{
+ expect(localStorage.getItem('isLoggedin')).toBeFalsy
+ })
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts
index 1dab68ba..8d9003fc 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts
@@ -6,6 +6,7 @@ import { FormsModule } from '@angular/forms';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MatDialogModule, MatSnackBarModule } from '@angular/material';
import { CommonModule } from '@angular/common';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
describe('FormFieldsComponent', () => {
let component: FormFieldsComponent;
@@ -15,7 +16,13 @@ describe('FormFieldsComponent', () => {
TestBed.configureTestingModule({
schemas:[CUSTOM_ELEMENTS_SCHEMA],
declarations: [ FormFieldsComponent ],
- imports:[FormsModule,HttpClientTestingModule,MatDialogModule,MatSnackBarModule]
+ imports:[
+ FormsModule,
+ HttpClientTestingModule,
+ MatDialogModule,
+ MatSnackBarModule,
+ // BrowserAnimationsModule
+ ]
})
.compileComponents();
}));
@@ -50,4 +57,102 @@ describe('FormFieldsComponent', () => {
}
});
+ it('should test setDisplayMode method',()=>{
+ component.setDisplayMode("setDisplayMode");
+ });
+
+ it('should test edit method',()=>{
+ component.edit("Id");
+
+ })
+
+ it('should test add method',()=>{
+ component.add();
+ expect(component.showDialog).toBe(true);
+ expect(component.closable).toBe(true);
+ expect(component.validationType).toEqual("");
+ expect(component.visible).toEqual("YES");
+ expect(component.message).toBe("");
+ expect(component.groupFormField).toBe(false);
+ expect(component.fieldType).toBe("");
+ expect(component.fieldSQL).toBe("");
+ expect(component.fieldName).toBe("");
+ expect(component.fieldId).toBe("");
+ expect(component.fieldDefaultSQL).toBe('');
+ expect(component.errorStackTrace).toBe("");
+ expect(component.errorMessage).toBe("");
+ expect(component.defaultValue).toBe(false);
+ expect(component.predefinedValueList).toEqual([]);
+ expect(component.showDialog).toBe(true);
+ expect(component.closable).toBe(true);
+ expect(component.mode).toEqual("Add");
+ });
+
+ it('should test close method1',()=>{
+ component.showDialog=true;
+ component.close();
+ expect(component.showDialog).toBe(false);
+ expect(component.closable).toBe(false);
+ });
+
+ it('should test close method2',()=>{
+ component.showDialog=false;
+ component.close();
+ expect(component.showDialog).toBe(true);
+ expect(component.closable).toBe(false);
+});
+
+ it('should test loseValidateModal method1',()=>{
+ component.showDialog1=true;
+ component.closeValidateModal();
+ expect(component.showDialog1).toBe(false);
+ expect(component.showVerifySpinner).toBe(false);
+ })
+
+ it('should test loseValidateModal method2',()=>{
+ component.showDialog1=false;
+ component.closeValidateModal();
+ expect(component.showDialog1).toBe(true);
+ expect(component.showVerifySpinner).toBe(false);
+});
+
+it('should test addToList method',()=>{
+ component.addToList("attrib")
+ {
+ expect(component.predefinedValueList.pop()).toEqual({id:'attrib', name:'attrib',selected:false});
+ }
+});
+
+it('should test deleteFromList method',()=>{
+component.deleteFromList("attrib");
+});
+
+it('should test save method',()=>{
+ component.save();
+ expect(component.showSpinner).toBe(true);
+ expect(component.showDialog).toBe(false);
+ expect(component.finalPOSTObj["validationType"]).toEqual(component.validationType);
+ if(component.visible=="YES")
+ expect(component.finalPOSTObj["visible"]).toBe(true);
+ else
+ expect(component.finalPOSTObj["visible"]).toBe(false);
+ expect(component.finalPOSTObj["orderSeq"]).toEqual(component.orderSeq);
+ expect(component.finalPOSTObj["message"]).toEqual(component.message);
+ expect(component.finalPOSTObj["groupFormField"]).toEqual(component.groupFormField);
+ expect(component.finalPOSTObj["fieldType"]).toEqual(component.fieldType);
+ expect(component.finalPOSTObj["fieldSQL"]).toEqual(component.fieldSQL);
+ expect(component.finalPOSTObj["fieldName"]).toEqual(component.fieldName);
+ expect(component.finalPOSTObj["fieldId"]).toEqual(component.fieldId);
+ expect(component.finalPOSTObj["errorStackTrace"]).toEqual(component.errorStackTrace);
+ expect(component.finalPOSTObj["errorMessage"]).toEqual(component.errorMessage);
+ expect(component.finalPOSTObj["defaultValue"]).toEqual(component.defaultValue);
+ if(component.defaultValue===false)
+ expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null);
+ else
+ expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL);
+ expect(component.finalPOSTObj["predefinedValueList"]).toEqual(component.predefinedValueList);
+
+});
+
+
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts
index 96dcdbaa..9e1cd459 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts
@@ -6,6 +6,12 @@ import { RouterModule } from '@angular/router';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { DashboardReportService } from './dashboard-report.service';
+import { MockBackend, MockConnection } from '@angular/http/testing';
+import { Http, BaseRequestOptions } from '@angular/http';
+import { Observable } from 'rxjs';
+import 'rxjs/add/observable/empty';
+import 'rxjs/add/observable/of';
+import { environment } from 'src/environments/environment';
describe('RunDashboardReportComponent', () => {
let component: RunDashboardReportComponent;
@@ -17,7 +23,13 @@ describe('RunDashboardReportComponent', () => {
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ RunDashboardReportComponent ],
imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule],
- providers: [DashboardReportService]
+ providers:[DashboardReportService, MockBackend, BaseRequestOptions, {
+ provide: Http,
+ useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
+ return new Http(backend, defaultOptions);
+ },
+ deps: [MockBackend, BaseRequestOptions],
+ }]
})
.compileComponents();
dashboardService = TestBed.get(DashboardReportService);
@@ -49,10 +61,13 @@ describe('RunDashboardReportComponent', () => {
expect(component.dataSource.paginator).toEqual(component.paginator);
});
- it('should test ngOnChanges method', () => {
- component.initialQueryString !== component.queryString;
+ it('should test ngOnChanges methods if condition', () => {
+
+ component.hitCnt = 1;
+ component.queryString = "testing"
+ component.initialQueryString === "test";
component.initCounter > 0;
- component.runButtonHitCounter !== component.hitCnt;
+ component.runButtonHitCounter === 2;
component.ngOnChanges();
expect(component.initialQueryString).toEqual(component.queryString);
@@ -67,26 +82,33 @@ describe('RunDashboardReportComponent', () => {
});
- it('should test afterViewInitProcesses method', () => {
- component.afterViewInitProcesses();
- expect(component.displayedColumnsArr).toEqual(new Array());
- expect(component.displayedRowObj).toEqual(new Array());
- expect(component.displayedColumns).toEqual(new Array());
- expect(component.formFieldList).toEqual(new Array());
- expect(component.showSpinner).toEqual(true);
- expect(component.isReady).toEqual(false);
- expect(component.NEWdisplayedColumns).toEqual(new Array());
-
- dashboardService.getReportDataWithFormFields("dummy", "test").subscribe((Response) => {
- expect(component.formFieldPresent).toEqual(false);
- expect(component.responseFormFieldListLength).toEqual(0);
- expect(component.reportName).toEqual(Response["reportName"]);
- });
- });
-
it('should test applyFilter method', () => {
component.applyFilter("testing");
expect(component.dataSource.filter).toEqual("testing".trim().toLowerCase());
});
+
+ it('should test afterViewInitProcesses method', () => {
+ component.afterViewInitProcesses();
+ expect(component.displayedColumnsArr).toEqual(new Array());
+ expect(component.displayedRowObj).toEqual(new Array());
+ expect(component.displayedColumns).toEqual(new Array());
+ expect(component.formFieldList).toEqual(new Array());
+ expect(component.showSpinner).toEqual(true);
+ expect(component.isReady).toEqual(false);
+ expect(component.NEWdisplayedColumns).toEqual(new Array());
+ });
+
+ describe('Should test afterViewInitProcesses', () => {
+ it('should validate on afterViewInitProcesses subscribe return', () => {
+ let spy = spyOn(dashboardService, 'getReportDataWithFormFields')
+ .and.returnValue(Observable.of());
+ component.afterViewInitProcesses();
+ // expect(component.formFieldPresent).toEqual(false);
+ // expect(component.responseFormFieldListLength).toEqual(0);
+ expect(spy).toHaveBeenCalled();
+
+ });
+});
+
}); \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts
index b61e9c56..359bee9f 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts
@@ -2,22 +2,30 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
-import { MatTableModule } from '@angular/material/table';
+import { MatTableModule, MatTableDataSource } from '@angular/material/table';
import { ReportListComponent } from './report-list.component';
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { RouterTestingModule } from '@angular/router/testing';
+import { Router } from '@angular/router';
+import { AllReportsDataSource } from './report-list-datasource';
-describe('AllReportsComponent', () => {
+describe('ReportListComponent', () => {
let component: ReportListComponent;
let fixture: ComponentFixture<ReportListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ ReportListComponent ],
imports: [
NoopAnimationsModule,
MatPaginatorModule,
MatSortModule,
MatTableModule,
+ HttpClientTestingModule,
+ RouterTestingModule
]
}).compileComponents();
}));
@@ -31,4 +39,59 @@ describe('AllReportsComponent', () => {
it('should compile', () => {
expect(component).toBeTruthy();
});
-});
+
+ it('should test initializeReportList method', () => {
+ component.initializeReportList();
+ expect(component.showSpinner).toEqual(true);
+ expect(component.dataSource).toEqual(new AllReportsDataSource());
+ expect(component.intermediateDisplayedColumns).toEqual(new Array());
+ expect(component.finalGETObj).toEqual(new Object());
+ expect(component.finalGETObjRowsArr).toEqual(new Array());
+ expect(component.rowArr).toEqual(new Array());
+ expect(component.reportIdArr).toEqual(new Array());
+ expect(component.toggle).toEqual(false);
+ expect(component.toggle1).toEqual(false);
+ expect(component.finalRowArr).toEqual(new Array());
+ });
+
+ it('should test ngOnInit method', () => {
+ component.ngOnInit();
+ expect(component.toggle).toEqual(false);
+ });
+
+ it('should test confirmDelete method', () => {
+ component.confirmDelete("test");
+ expect(component.showDialog).toEqual(true);
+ expect(component.closable).toEqual(true);
+ expect(component.newReportId).toEqual("test");
+ });
+
+ it('should test ngAfterViewInit method', () => {
+ component.ngAfterViewInit();
+ expect(component.dataSource.sort).toEqual(component.sort);
+ expect(component.dataSource.paginator).toEqual(component.paginator);
+ expect(component.table.dataSource).toEqual(component.dataSource);
+ });
+
+ it('should test displayReport method', () => {
+ component.displayReport("Testing");
+ expect(component.reportId).toEqual("Testing");
+ });
+
+ it('should test runReport method', () => {
+ component.runReport("Test");
+ expect(component.reportId).toEqual("Test");
+ });
+
+ it('should test applyFilter method', () => {
+ component.applyFilter("ABC");
+ expect(component.dataSource1.filter).toEqual("abc");
+
+ });
+
+ it('should test close method', () => {
+ component.close();
+ expect(component.showDialog).toEqual(true);
+ expect(component.closable).toEqual(false);
+ })
+}); \ No newline at end of file