summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts31
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts60
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts19
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts55
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts54
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts57
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts141
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts45
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts38
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts50
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts33
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts45
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts33
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts23
14 files changed, 472 insertions, 212 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 ecfd694d..1253b2be 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
@@ -37,20 +37,21 @@
*
*
*/
-import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
+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 { HeaderComponent } from './header.component';
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;
@@ -66,15 +67,13 @@ describe('HeaderComponent', () => {
LayoutModule,
RouterTestingModule,
TranslateModule.forRoot(),
+ HttpClientModule,
HttpClientTestingModule
],
- providers:[CookieService,HeaderService,MockBackend, BaseRequestOptions, {
- provide: Http,
- useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
- return new Http(backend, defaultOptions);
- },
- deps: [MockBackend, BaseRequestOptions],
- }]
+ providers:[
+ CookieService,
+ HeaderService
+ ]
})
.compileComponents();
}));
@@ -92,6 +91,12 @@ describe('HeaderComponent', () => {
expect(component).toBeTruthy();
});
+ it('testing if condition in ngOnInit method',()=>{
+ component.cookieService.set('show_app_header','false');
+ component.ngOnInit();
+ expect(component.showHeader).toBe(false)
+ })
+
describe('should test ngOnInit',()=>{
it('should validate on ngOnInit',()=>{
let spy=spyOn(headerService, 'getTopMenuItems').and.returnValue(Observable.of('you object'));
@@ -113,4 +118,6 @@ describe('HeaderComponent', () => {
it('should test on onLoggedout method',()=>{
expect(localStorage.getItem('isLoggedin')).toBeFalsy
})
-}); \ No newline at end of file
+
+
+});
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 cc710b5c..7f5a43fe 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
@@ -4,7 +4,7 @@
* ===================================================================
* Copyright © 2019 AT&T Intellectual Property. All rights reserved.
*
- * Modification Copyright © 2019 IBM.
+ * Modification Copyright © 2020 IBM.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -40,46 +40,37 @@
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 { 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';
+import { Observable } from 'rxjs';
describe('SidebarComponent', () => {
let component: SidebarComponent;
let fixture: ComponentFixture<SidebarComponent>;
let sidebarService: SidebarService;
- let spy:any;
-
- let mockSidebarService = {
- navigate: jasmine.createSpy('navigate')
- };
+
+ var stubData1={
+ "data":'{"data":"cachedRegions"}',
+ "data2":'{"data2":"cachedRegions2"}'
+ };
+
beforeEach(async(() => {
+ let sidebarService: SidebarService;
TestBed.configureTestingModule({
imports: [
LayoutModule,
RouterTestingModule,
TranslateModule.forRoot(),
+ HttpClientModule,
HttpClientTestingModule
],
- providers:[CookieService, SidebarService,MockBackend, BaseRequestOptions, {
- provide: Http,
- useFactory: (backend: XHRBackend, defaultOptions: BaseRequestOptions) => {
- return new Http(backend, defaultOptions);
- },
- deps: [MockBackend, BaseRequestOptions],
- }],
+ providers:[CookieService, SidebarService],
})
.compileComponents();
}));
@@ -89,22 +80,25 @@ describe('SidebarComponent', () => {
component = fixture.componentInstance;
fixture.detectChanges();
sidebarService = TestBed.get(SidebarService);
+
});
it('should create', () => {
expect(component).toBeTruthy();
});
+ it('testing if condition in ngOnInit method',()=>{
+ component.cookieService.set('show_app_header','false');
+ component.ngOnInit();
+ expect(component.showHeader).toBe(false)
+ })
+
+
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 validate on ngOnInit',()=>{
+ let spy=spyOn(sidebarService,'getLeftMenu').and.returnValue(Observable.of(stubData1));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
})
})
@@ -134,15 +128,15 @@ describe('SidebarComponent', () => {
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/layout.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts
index 6a2bb7ff..975f72c3 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts
@@ -41,17 +41,17 @@ import { TranslateModule } from '@ngx-translate/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { LayoutComponent } from './layout.component';
import { LayoutModule } from './layout.module';
-import { MatDialog, MatDialogModule } from '@angular/material';
-import { Overlay } from '@angular/cdk/overlay';
+import { MatDialogModule } from '@angular/material';
import { CookieService } from 'ngx-cookie-service';
+import { MockBackend } from '@angular/http/testing';
describe('LayoutComponent', () => {
let component: LayoutComponent;
let fixture: ComponentFixture<LayoutComponent>;
+ let cookieService: CookieService;
beforeEach( async(() => {
TestBed.configureTestingModule({
- providers:[CookieService],
imports: [
MatDialogModule,
HttpClientTestingModule,
@@ -59,6 +59,10 @@ describe('LayoutComponent', () => {
RouterTestingModule,
TranslateModule.forRoot(),
],
+ providers:[
+ CookieService,
+ MockBackend
+ ]
}).compileComponents();
})
);
@@ -67,15 +71,22 @@ describe('LayoutComponent', () => {
fixture = TestBed.createComponent(LayoutComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ cookieService = TestBed.get(CookieService);
});
it('should create', () => {
expect(component).toBeTruthy();
});
+ it('testing if condition in ngOnInit method',()=>{
+ component.cookieService.set('show_app_header','false');
+ component.ngOnInit();
+ expect(component.showHeader).toBe(false)
+ })
+
it('should test receiveCollapsed method',()=>{
component.receiveCollapsed(true);
expect(component.collapedSideBar).toBe(true);
})
-});
+}); \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts
index 7a4bcec0..03d21797 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts
@@ -2,27 +2,74 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CacheAdminComponent } from './cache-admin.component';
import { MatExpansionModule } from '@angular/material';
+import { HttpClientModule } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { AdminService } from '../admin.service';
+import { Observable } from 'rxjs/Observable';
+import 'rxjs/add/observable/of';
+import { CookieService } from 'ngx-cookie-service';
+import { SuccessModalComponent } from 'src/app/modals/success-modal/success-modal.component';
+import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+
+
describe('CacheAdminComponent', () => {
let component: CacheAdminComponent;
let fixture: ComponentFixture<CacheAdminComponent>;
+ let adminService:AdminService;
+
+ var stubData1={"data":'{"data":"cachedRegions"}'};
+ var stubData2={"data":"stubData2"};
beforeEach(async(() => {
+
TestBed.configureTestingModule({
- imports:[MatExpansionModule, HttpClientTestingModule],
- declarations: [ CacheAdminComponent ],
- schemas: [CUSTOM_ELEMENTS_SCHEMA]
+ declarations: [
+ CacheAdminComponent,
+ SuccessModalComponent,
+ ],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ imports:[
+ MatExpansionModule,
+ HttpClientModule,
+ HttpClientTestingModule,
+ NgbModule.forRoot()
+ ],
+ providers:[CookieService,AdminService],
+ })
+ TestBed.overrideModule(BrowserDynamicTestingModule,{
+ set:{
+ entryComponents:[SuccessModalComponent]
+ }
})
.compileComponents();
- }));
+ }));
beforeEach(() => {
fixture = TestBed.createComponent(CacheAdminComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ adminService=TestBed.get(AdminService);
});
it('should create', () => {
expect(component).toBeTruthy();
});
+
+
+ describe('it should test ngOnInit method',()=>{
+ it('should test ngOnInit',()=>{
+ let spy=spyOn(adminService,'getCacheRegions').and.returnValue(Observable.of(stubData1));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
+ })
+ })
+
+ it('it should test showRegionDetails method',()=>{
+ let spy=spyOn(adminService,'getCacheRegionDetails').and.returnValue(Observable.of(stubData2));
+ component.showRegionDetails("string");
+ expect(spy).toHaveBeenCalled();
+ })
+
});
+
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts
index 5627abd0..eb8b63dd 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts
@@ -2,6 +2,7 @@ import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing'
import { MatTableModule } from '@angular/material/table';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
+import { HttpClientModule } from '@angular/common/http';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap';
@@ -11,12 +12,19 @@ import { InformationModalComponent } from 'src/app/modals/information-modal/info
import { AdminService } from '../admin.service';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { MenusService } from './menus.service';
+import { CookieService } from 'ngx-cookie-service';
+import { MockBackend } from '@angular/http/testing';
+import { BaseRequestOptions, Http } from '@angular/http';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
describe('MenusComponent', () => {
let component: MenusComponent;
let fixture: ComponentFixture<MenusComponent>;
let modalService: any;
- let modalRef: any;
+ let adminService:any;
+ var stubData={"data":'{"fnMenuItems":{"tableData":{"element":{"active":1}}}}'};
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -26,11 +34,14 @@ describe('MenusComponent', () => {
imports: [ MatTableModule,
MatPaginatorModule,
MatSortModule,
- HttpClientTestingModule,
+ HttpClientModule,
+ HttpClientTestingModule,
NoopAnimationsModule,
- NgbModule.forRoot() ]
- }).
- overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent] } });;
+ NgbModule.forRoot()
+ ],
+ providers:[MenusService,CookieService]
+ })
+ .compileComponents();
}));
beforeEach(async() => {
@@ -38,24 +49,33 @@ describe('MenusComponent', () => {
component = fixture.componentInstance;
fixture.detectChanges();
modalService = TestBed.get(NgbModal);
- modalRef = modalService.open(InformationModalComponent);
- spyOn(modalService, "open").and.returnValue(modalRef);
- spyOn(modalRef, "result").and.returnValue('Ok');
+ adminService=TestBed.get(AdminService);
});
it('should create', () => {
expect(component).toBeTruthy();
});
- // it('should test getDismissReason function to call NgbModal.open function', () => {
- // component.removeMenuItem({'label': 'abc'});
- // expect(modalService.open).toHaveBeenCalled();
- // });
+ // it('should test getFnMenuItems method inside getMenus',()=>{
+ // let spy=spyOn(adminService,'getFnMenuItems').and.returnValue(Observable.of(stubData))
+ // component.getMenus();
+ // expect(spy).toHaveBeenCalled();
+ // })
+ describe('test getMenus',()=>{
+ it('should test getMenus',()=>{
+ let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object'))
+ component.getParentData();
+ expect(spy).toHaveBeenCalled();
+ })
+ })
-// it('should test getDismissReason function', inject([AdminService],(adminservice) => {
-// let spy = spyOn(adminservice, 'getFnMenuItems');
-// component.getMenus();
-// expect(spy).toHaveBeenCalled();
-// }));
+ describe('testing getFunctionCDselectData',()=>{
+ it('should test getFunctionCDselectData',()=>{
+ let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of(1,1));
+ component.getFunctionCDselectData();
+ expect(spy).toHaveBeenCalled();
+ })
+ })
+
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts
index c327c79a..5d996964 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts
@@ -111,27 +111,54 @@ export class MenusComponent implements OnInit {
});
//rdp table data
- this.columns.push(new Column("id", "Menu ID", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("label", "Label", ColumnTypes.TEXT, true, null));
- this.columns.push(new Column("parentId", "ParentId", ColumnTypes.DROPDOWN, false, this.parentList));
- this.columns.push(new Column("sortOrder", "Sort Order", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("action", "Action", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("functionCd", "Function", ColumnTypes.DROPDOWN, false, this.functionCDselectData));
- this.columns.push(new Column("active", "Active", ColumnTypes.DROPDOWN, false, this.activeStatusOptions));
- this.columns.push(new Column("servlet", "Servlet", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("queryString", " Query String", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("externalUrl", "External URL", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("target", "Target", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("menuSetCode", "Menu Set Code", ColumnTypes.TEXT, false, null));
- this.columns.push(new Column("separator", "Separator", ColumnTypes.DROPDOWN, false, this.separatorStatusOptions));
- this.columns.push(new Column("imageSrc", "Image Source", ColumnTypes.TEXT, false, null));
+ let menuIdColumn = new Column("id", "Menu ID", ColumnTypes.TEXT, true, null);
+ menuIdColumn.isColumnDisabled = true;
+ this.columns.push(menuIdColumn);
+
+ let label = new Column("label", "Label", ColumnTypes.TEXT, true, null);
+ label.setIsColumnMandatory = true;
+ this.columns.push(label);
+
+ let parent = new Column("parentId", "ParentId", ColumnTypes.DROPDOWN, true, this.parentList);
+ parent.setIsColumnMandatory = true;
+ this.columns.push(parent);
+
+ let sortOrder = new Column("sortOrder", "Sort Order", ColumnTypes.TEXT, true, null);
+ sortOrder.setIsColumnMandatory = true;
+ this.columns.push(sortOrder);
+
+ let action = new Column("action", "Action", ColumnTypes.TEXT, true, null);
+ action.setIsColumnMandatory = true;
+ this.columns.push(action);
+
+ let functionCd = new Column("functionCd", "Function", ColumnTypes.DROPDOWN, true, this.functionCDselectData);
+ functionCd.setIsColumnMandatory = true;
+ this.columns.push(functionCd);
+
+ let active = new Column("active", "Active", ColumnTypes.DROPDOWN, true, this.activeStatusOptions);
+ active.setIsColumnMandatory = true;
+ this.columns.push(active);
+
+ this.columns.push(new Column("servlet", "Servlet", ColumnTypes.TEXT, true, null));
+ this.columns.push(new Column("queryString", " Query String", ColumnTypes.TEXT, true, null));
+ this.columns.push(new Column("externalUrl", "External URL", ColumnTypes.TEXT, true, null));
+ this.columns.push(new Column("target", "Target", ColumnTypes.TEXT, true, null));
+
+ let menuSetCode = new Column("menuSetCode", "Menu Set Code", ColumnTypes.TEXT, false, null);
+ menuSetCode.setIsColumnMandatory = true;
+ this.columns.push(menuSetCode);
+
+ let separator = new Column("separator", "Separator", ColumnTypes.DROPDOWN, false, this.separatorStatusOptions);
+ separator.setIsColumnMandatory = true;
+ this.columns.push(separator);
+ this.columns.push(new Column("imageSrc", "Image Source", ColumnTypes.TEXT, true, null));
this.settings = new DataTableSettings()
this.settings.columns = this.columns;
this.settings.isPaginationEnabled = true;
this.settings.paginationsSize = "5";
this.settings.isReadOnly = false;
- this.settings.isTableSearchEnabled = false;
+ this.settings.isTableSearchEnabled = true;
this.settings.applicationService = this.menuService;
this.showSpinner = false;
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts
index 7ddaf632..5c22346e 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts
@@ -46,35 +46,42 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { NgbActiveModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { RouterTestingModule } from '@angular/router/testing';
import { CookieService } from 'ngx-cookie-service';
-import { MockBackend } from '@angular/http/testing';
-import { BaseRequestOptions, Http } from '@angular/http';
import { AdminService } from '../../admin.service';
import 'rxjs/add/operator/toPromise';
import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { MaterialModule } from 'portalsdk-tag-lib/material-module';
import 'rxjs/add/observable/of';
import { Observable } from 'rxjs/Observable';
+import 'rxjs/add/operator/catch';
+import 'rxjs/add/observable/throw';
+import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
describe('NewMenuComponent', () => {
let component: NewMenuComponent;
let fixture: ComponentFixture<NewMenuComponent>;
let adminService:AdminService;
- // let entryComponents:any;
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ NewMenuComponent ],
- imports:[FormsModule, HttpClientTestingModule,RouterTestingModule,NgbModalModule,BrowserAnimationsModule],
- providers:[AdminService,NgbActiveModal,CookieService,MockBackend,BaseRequestOptions,{
- provide:Http,
- useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{
- return new Http(backend,defaultOptions);
- },
- deps:[MockBackend,BaseRequestOptions],
- entryComponents:[ConfirmationModalComponent]
- }],
+ declarations: [ NewMenuComponent,ConfirmationModalComponent ],
+ imports:[
+ FormsModule,
+ HttpClientTestingModule,
+ RouterTestingModule,
+ NgbModalModule,
+ BrowserAnimationsModule
+ ],
+ providers:[
+ AdminService,
+ NgbActiveModal,
+ CookieService
+ ],
+ })
+ TestBed.overrideModule(BrowserDynamicTestingModule,{
+ set:{
+ entryComponents:[ConfirmationModalComponent ]
+ }
})
.compileComponents();
@@ -87,57 +94,55 @@ describe('NewMenuComponent', () => {
adminService=TestBed.get(AdminService);
});
-// // it('should create', () => {
-// // expect(component).toBeTruthy();
-// // });
-
-// it('testing ngOnInit method for if condition',()=>{
-// component.selectedMenu=1;
-// component.ngOnInit();
-// expect(component.menu).toEqual(component.selectedMenu);
-// })
-
-// it('testing ngOnInit method for else condition',()=>{
-// component.selectedMenu=0;
-// component.ngOnInit();
-// expect(component.menu.menuSetCode).toEqual('APP');
-// })
-
-// it('testing sortItems method',()=>{
-// let prop: any;
-// component.sortItems(prop);
-
-// })
-
-// it('testing getParentLabel method',()=>{
-// component.getParentLabel(1,"data");
-// })
-
-// describe('should test getParentData',()=>{
-// it('testing getParentData',()=>{
-// let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object'));
-// component.getParentData();
-// expect(spy).toHaveBeenCalled();
-
-// })
-// })
-
-// describe('should test getLeftMenuItems',()=>{
-// it('testing getLeftMenuItems',()=>{
-// component.getLeftMenuItems();
-// })
-// })
-
-// describe('should test getFunctionCDselectData',()=>{
-// it('testing getFunctionCDselectData',()=>{
-// let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of(1,1));
-// component.getFunctionCDselectData();
-// expect(spy).toHaveBeenCalled();
-// })
-// })
-
-// it('should test updateFnMenu method',()=>{
-// //component.updateFnMenu();
-// })
-
- });
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ it('testing ngOnInit method for if condition',()=>{
+ component.selectedMenu=1;
+ component.ngOnInit();
+ expect(component.menu).toEqual(component.selectedMenu);
+ })
+
+ it('testing ngOnInit method for else condition',()=>{
+ component.selectedMenu=0;
+ component.ngOnInit();
+ expect(component.menu.menuSetCode).toEqual('APP');
+ })
+
+ it('testing sortItems method',()=>{
+ let prop: any;
+ component.sortItems(prop);
+
+ })
+
+ it('testing getParentLabel method',()=>{
+ component.getParentLabel(1,"data");
+ })
+
+
+ it('should test getParentData method1 ',()=>{
+ const children="children";
+ let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object'));
+ component.getParentData();
+ expect(spy).toHaveBeenCalled();
+ })
+
+ describe('should test getLeftMenuItems',()=>{
+ it('testing getLeftMenuItems',()=>{
+ component.getLeftMenuItems();
+ })
+ })
+
+ it('testing getFunctionCDselectData method1',()=>{
+ let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of('your object'));
+ component.getFunctionCDselectData();
+ expect(spy).toHaveBeenCalled();
+ })
+
+ it('should test updateFnMenu method',()=>{
+ component.menu.label!=null;
+ component.updateFnMenu();
+ })
+
+});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts
index e761ada5..9cb908dd 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts
@@ -43,11 +43,12 @@ import { RoleFunctionsComponent } from './role-functions.component';
import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RdpModule } from 'portalsdk-tag-lib';
-import { FormsModule, ReactiveFormsModule } from '@angular/forms';
+import { FormsModule} from '@angular/forms';
import { UserService } from 'src/app/shared/services/user/user.service';
import { AdminService } from '../admin.service';
-import { MatSelectModule, MatAutocompleteModule } from '@angular/material';
+import { MatSelectModule} from '@angular/material';
import { Observable } from 'rxjs';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
describe('RoleFunctionsComponent', () => {
let component: RoleFunctionsComponent;
@@ -59,13 +60,12 @@ describe('RoleFunctionsComponent', () => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ RoleFunctionsComponent ],
- imports: [HttpClientTestingModule,
+ imports: [HttpClientTestingModule,BrowserAnimationsModule,
RdpModule,
FormsModule,
- // MatSelectModule,
],
providers:[MatSelectModule]
- })
+ })
.compileComponents();
}));
@@ -80,27 +80,20 @@ describe('RoleFunctionsComponent', () => {
adminService=TestBed.get(AdminService);
});
-// it('should create', () => {
-// expect(component).toBeTruthy();
-// });
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
-// describe('test for subscribe in ngOnInit',()=>{
-// it('should test ngOnInit method',()=>{
-// let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('you object'));
-// component.ngOnInit();
-// expect(spy).toHaveBeenCalled();
-// })
-// })
-// it('Admin service injection check', inject([AdminService],(injectService:AdminService) =>{
-// expect(injectService).toBe(adminService);
-// }));
+ describe('test for subscribe in ngOnInit',()=>{
+ it('should test ngOnInit method',()=>{
+ let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('you object'));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
+ })
+ })
+ it('Admin service injection check', inject([AdminService],(injectService:AdminService) =>{
+ expect(injectService).toBe(adminService);
+ }));
-// // describe('test subscribe in getRoleFunctions',()=>{
-// // it('should test getRoleFunctions method',()=>{
-// // let spy=spyOn(adminService,'getRoleFunctionList').and.returnValue(Observable.of('you object'));
-// // component.getRoleFunctions();
-// // expect(spy).toHaveBeenCalled();
-// // })
-// // })
- }); \ No newline at end of file
+});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts
index 8af2689a..dcd637fc 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts
@@ -45,16 +45,34 @@ import { RolesComponent } from './roles.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { MatTableModule } from '@angular/material';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { UserService } from 'src/app/shared/services/user/user.service';
+import { Observable } from 'rxjs';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
+import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
describe('RolesComponent', () => {
let component: RolesComponent;
let fixture: ComponentFixture<RolesComponent>;
+ let userService: UserService;
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
- declarations: [ RolesComponent ],
- imports:[MatTableModule,HttpClientTestingModule]
+ declarations: [
+ RolesComponent,
+ InformationModalComponent,
+ ],
+ imports:[
+ MatTableModule,
+ HttpClientTestingModule,
+ NgbModule.forRoot()
+ ]
+ })
+ TestBed.overrideModule(BrowserDynamicTestingModule,{
+ set:{
+ entryComponents:[InformationModalComponent]
+ }
})
.compileComponents();
}));
@@ -63,9 +81,25 @@ describe('RolesComponent', () => {
fixture = TestBed.createComponent(RolesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ userService=TestBed.get(UserService);
});
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('should test subscribe inside ngOnInit method',()=>{
+ let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('your data'))
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
+ })
+
+ it('should test delRoleConfirmPopUp method',()=>{
+ component.delRoleConfirmPopUp('dummyargument');
+
+ })
+
+ // it('should test openAdoleModaldNewR method',()=>{
+ // component.openAdoleModaldNewR('dummydata2')
+ // })
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts
index c922b359..a1906c85 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts
@@ -5,19 +5,37 @@ import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
import {MatDatepickerModule} from '@angular/material/datepicker';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
+import { RunService } from '../run.service';
+import { Observable } from 'rxjs/Observable';
+import 'rxjs/add/observable/of';
+import { of } from 'rxjs';
describe('RunReportFormFieldsComponent', () => {
let component: RunReportFormFieldsComponent;
let fixture: ComponentFixture<RunReportFormFieldsComponent>;
let formfield =[{"validationType":1},{},{}] ;
+ let runService: RunService;
+ let environment = [
+ {
+ baseUrl: 'just for testing'
+ }
+ ]
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [FormsModule, MatDatepickerModule, HttpClientTestingModule, RouterTestingModule],
- declarations: [ RunReportFormFieldsComponent ]
+ declarations: [ RunReportFormFieldsComponent ],
+ providers: [RunService]
})
.compileComponents();
+ runService = TestBed.get(RunService);
+ // spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment));
+ // spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment));
+ spyOn(runService, 'getDefinitionPageDetails').and.returnValue(Observable.of(environment));
+ spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment));
+ // spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment));
+ spyOn(runService, 'getFormFieldGroupsData').and.returnValue(Observable.of(environment));
}));
beforeEach(() => {
@@ -31,12 +49,6 @@ describe('RunReportFormFieldsComponent', () => {
expect(component).toBeTruthy();
});
- it('should test ngOnInit method', () => {
- component.ngOnInit();
- // expect(component.showSpinner).toEqual(true);
- // expect(component.navigateToRun).toEqual(false);
- });
-
it('should test convertDate method', () => {
component.convertDate("test");
});
@@ -98,16 +110,28 @@ describe('RunReportFormFieldsComponent', () => {
component.formFieldList != undefined;
component.oldGroupSelectValue = "test";
component.groupSelectValue = "testing";
+ // component.toggleFormFieldRenderArr.length = 1;
+ spyOn(component, 'ngDoCheck').and.callThrough();
component.ngDoCheck();
-
+ expect(component.ngDoCheck).toHaveBeenCalled();
expect(component.oldGroupSelectValue).toBe(component.groupSelectValue);
});
- it('should test fetchAndPopulateFormFields method', () => {
- component.fetchAndPopulateFormFields(1, "test");
- })
-
it('should test generateQueryString method',() => {
component.generateQueryString();
- })
+ })
+
+ it('should test ngOnInit method', () => {
+ spyOn(component, 'ngOnInit').and.callThrough();
+ component.ngOnInit();
+ expect(component.ngOnInit).toHaveBeenCalled();
+ });
+
+// it('should test fetchAndPopulateFormFields method', () => {
+// spyOn(component, 'fetchAndPopulateFormFields').and.callThrough();
+// component.formFieldGroupObjList = null;
+// component.fetchAndPopulateFormFields(1, "test");
+// expect(component.fetchAndPopulateFormFields).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/run/run-report/run-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-report.component.spec.ts
index 509aa82e..a41b11cd 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-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-report.component.spec.ts
@@ -12,6 +12,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { RunService } from '../run.service';
import 'rxjs/add/observable/empty';
import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs';
describe('RunReportComponent', () => {
let component: RunReportComponent;
@@ -25,6 +26,12 @@ describe('RunReportComponent', () => {
let dashboard;
let dashboard2;
let responseformfield = 1;
+ let environment = [
+ {
+ baseUrl: 'just a link'
+ }
+ ]
+
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -42,6 +49,9 @@ describe('RunReportComponent', () => {
providers: [RunService]
}).compileComponents();
runService = TestBed.get(RunService);
+ //spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment));
+ //spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment));
+ spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment));
}));
beforeEach(() => {
@@ -125,7 +135,9 @@ describe('RunReportComponent', () => {
});
it('should test downloadReportExcel method', () => {
+ spyOn(component, 'downloadReportExcel').and.callThrough();
component.downloadReportExcel();
+ expect(component.downloadReportExcel).toHaveBeenCalled();
});
it('should test applyFilter method', () => {
@@ -150,5 +162,26 @@ describe('RunReportComponent', () => {
expect(component.NEWdisplayedColumns).toEqual(new Array());
expect(component.isReady).toEqual(false);
});
+
+ it('should test initialProcess method', () => {
+ component.DashboardReportObj.length = 1;
+ component.initialProcesses();
+ });
+
+ // it('should test postFetchingReportDataFn method', () => {
+ // let response: any;
+ // component.postFetchingReportDataFn(response);
+ // })
+
+ // it('should test ngOnChanges subscribe method', () => {
+ // spyOn(component, 'ngOnChanges').and.callThrough();
+ // component.ngOnChanges(change);
+ // expect(component.ngOnChanges).toHaveBeenCalled();
+ // })
+
+ // it('should test postFetchingReportDataFn method', () => {
+ // let obj: any;
+ // component.postFetchingReportDataFn(obj);
+ // })
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
index 3c3efb92..417b3a18 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
@@ -5,18 +5,42 @@ import { FormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { componentRefresh } from '@angular/core/src/render3/instructions';
+import { SecurityService } from './security.service';
+import { Observable } from 'rxjs/Observable';
+import 'rxjs/add/observable/of';
describe('SecurityComponent', () => {
let component: SecurityComponent;
let fixture: ComponentFixture<SecurityComponent>;
+ let service : SecurityService;
+ let environment =[
+ {
+ baseUrl: 'just for testing'
+ }
+ ]
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ SecurityComponent ],
- imports: [FormsModule, HttpClientTestingModule]
+ imports: [FormsModule, HttpClientTestingModule],
+ providers: [SecurityService]
})
.compileComponents();
+ service = TestBed.get(SecurityService);
+ spyOn(service, 'getReportOwnerList').and.returnValue(Observable.of(environment));
+ spyOn(service, 'getReportSecurityInfo').and.returnValue(Observable.of(environment));
+ spyOn(service, 'getReportUserList').and.returnValue(Observable.of(environment));
+ spyOn(service, 'getReportSecurityRoles').and.returnValue(Observable.of(environment));
+ spyOn(service, 'getReportRoleList').and.returnValue(Observable.of(environment));
+ spyOn(service, 'addReportUser').and.returnValue(Observable.of(environment));
+ spyOn(service, 'removeReportUser').and.returnValue(Observable.of(environment));
+ spyOn(service, 'addUserEditAccess').and.returnValue(Observable.of(environment));
+ spyOn(service, 'addReportRole').and.returnValue(Observable.of(environment));
+ spyOn(service, 'removeReportRole').and.returnValue(Observable.of(environment));
+ spyOn(service, 'addRoleEditAccess').and.returnValue(Observable.of(environment));
+ spyOn(service, 'saveSecurityTabInfo').and.returnValue(Observable.of(environment));
+
}));
beforeEach(() => {
@@ -31,15 +55,19 @@ describe('SecurityComponent', () => {
it('should test ngOnInit method', () => {
component.reportType = "Dashboard";
- component.ngOnInit();
- expect(component.showSpinner).toEqual(true);
+ component.ngOnInit();
+ // expect(component.showSpinner).toEqual(true);
expect(component.stepNo).toEqual('2');
-
component.reportType = "test";
+
component.ngOnInit();
expect(component.stepNo).toEqual('6');
- });
+ spyOn(component, 'ngOnInit').and.callThrough();
+ component.ngOnInit();
+ expect(component.ngOnInit).toHaveBeenCalled();
+ });
+
it('should test addUserEditAccess method', () =>{
let reportUserId = 'test';
let index = 1;
@@ -63,7 +91,9 @@ describe('SecurityComponent', () => {
});
it("should test addReportUser method", () => {
+ spyOn(component, 'addReportUser').and.callThrough();
component.addReportUser();
+ expect(component.addReportUser).toHaveBeenCalled();
});
it("should test removeReportUser method", () => {
@@ -79,7 +109,10 @@ describe('SecurityComponent', () => {
});
it("should test saveSecurityTabData method", () => {
- component.saveSecurityTabData();
+ spyOn(component, 'saveSecurityTabData').and.callThrough();
+ component.saveSecurityTabData();
+ expect(component.saveSecurityTabData).toHaveBeenCalled();
});
});
+
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts
index c894bff6..52082c9f 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts
@@ -8,15 +8,20 @@ import { RouterTestingModule } from '@angular/router/testing';
import { SqlService } from './sql.service';
import 'rxjs/add/observable/of';
import { Observable } from 'rxjs/Observable';
-import { element } from '@angular/core/src/render3';
-import { environment } from 'src/environments/environment';
+
describe('SQLComponentComponent', () => {
let sqlService: SqlService;
let component: SQLComponent;
let fixture: ComponentFixture<SQLComponent>;
const reportId = "test";
- const finalGetObj = {"query":"dummyQuery"}
+ const finalGetObj = {"query":"dummyQuery"};
+ let elements = [];
+ let environment = [
+ {
+ "baseUrl": 'just for test'
+ }
+ ]
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -27,15 +32,17 @@ describe('SQLComponentComponent', () => {
})
.compileComponents();
sqlService = TestBed.get(SqlService);
+ let response : any;
+ spyOn(sqlService, 'getSQLTabData').and.returnValue(Observable.of(environment));
+ spyOn(sqlService, 'postSQLValidateAndSave').and.returnValue(Observable.of(environment));
}));
beforeEach(() => {
- fixture = TestBed.createComponent(SQLComponent);
+ fixture = TestBed.createComponent(SQLComponent);
component = fixture.componentInstance;
component.reportId1 = reportId;
component.finalGetObj = finalGetObj;
- sqlService = TestBed.get(SqlService);
fixture.detectChanges();
});
@@ -44,6 +51,12 @@ describe('SQLComponentComponent', () => {
expect(component).toBeTruthy();
});
+ it('should test ngOninit subscribe method', () => {
+ spyOn(component, 'ngOnInit').and.callThrough();
+ component.ngOnInit();
+ expect(component.ngOnInit).toHaveBeenCalled();
+ });
+
it('should test ngOnInit method', () => {
component.ngOnInit();
expect(component.showSaveSQLDialog).toEqual(false);
@@ -69,10 +82,6 @@ describe('SQLComponentComponent', () => {
expect(component.SQLclosable).toEqual(true);
});
- it('should test validate method', () => {
- component.validate();
- });
-
it('should test closeSaveModal method', () => {
component.closeSaveModal();
expect(component.showSaveSQLDialog).toEqual(component.showSaveSQLDialog);
@@ -104,4 +113,10 @@ describe('SQLComponentComponent', () => {
expect(component.GetValidateResponseString()).toEqual("test");
});
+// it('should test validate method', () => {
+// spyOn(component, 'validate').and.callThrough();
+// component.validate();
+// expect(component.validate).toHaveBeenCalled();
+// });
+
});
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 2c01ff14..78113e42 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
@@ -3,17 +3,27 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
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';
+import { HttpClient } from '@angular/common/http';
+import { Observable } from 'rxjs';
+import 'rxjs/add/observable/empty';
+import 'rxjs/add/observable/of';
+import { environment } from 'src/environments/environment';
+import { ReportListService } from './report-list.service';
describe('ReportListComponent', () => {
let component: ReportListComponent;
let fixture: ComponentFixture<ReportListComponent>;
+ let http: HttpClient;
+ let reportService : ReportListService;
+ let environment = [
+ { baseUrl : 'just for test' }
+ ]
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -25,9 +35,14 @@ describe('ReportListComponent', () => {
MatSortModule,
MatTableModule,
HttpClientTestingModule,
- RouterTestingModule
- ]
+ RouterTestingModule,
+ ],
+ providers: [HttpClient, ReportListService]
}).compileComponents();
+
+ reportService = TestBed.get(ReportListService);
+ http = TestBed.get(HttpClient);
+ spyOn(reportService, 'deleteReport').and.returnValue(Observable.of(environment));
}));
beforeEach(() => {
@@ -96,7 +111,9 @@ describe('ReportListComponent', () => {
});
it('should test deleteReport method', () => {
+ spyOn(component, 'deleteReport').and.callThrough();
component.deleteReport();
+ expect(component.deleteReport).toHaveBeenCalled();
});
it('should test openReportSchedule method', () => {