diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay')
7 files changed, 57 insertions, 9 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 cbab9b18..02cfd6b6 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 @@ -38,6 +38,7 @@ 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'; @@ -52,6 +53,7 @@ describe('HeaderComponent', () => { LayoutModule, RouterTestingModule, TranslateModule.forRoot(), + HttpClientModule ], }) .compileComponents(); @@ -66,4 +68,10 @@ describe('HeaderComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should test isToggled function', () => { + console.log(component.isToggled()); + document.getElementById("body").classList.add("push-right"); + expect(component.isToggled()).toBe(true); + }); }); 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 9984ceee..04a691b9 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 @@ -1,25 +1,52 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +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'; import { MenusComponent } from './menus.component'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { AdminService } from '../admin.service'; describe('MenusComponent', () => { let component: MenusComponent; let fixture: ComponentFixture<MenusComponent>; + let modalService: any; + let modalRef: any; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ MenusComponent ] - }) - .compileComponents(); + declarations: [ MenusComponent, InformationModalComponent ], + imports: [ MatTableModule, MatPaginatorModule, MatSortModule, HttpClientModule, NoopAnimationsModule, NgbModule.forRoot() ] + }). + overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent] } });; })); - beforeEach(() => { + beforeEach(async() => { fixture = TestBed.createComponent(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'); }); 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 getDismissReason function', inject([AdminService],(adminservice) => { + component.getMenus(); + expect(adminservice.getFnMenuItems).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 b61e9c56..1907ed83 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,6 +3,7 @@ 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 { MatIconModule } from '@angular/material/icon'; import { ReportListComponent } from './report-list.component'; @@ -18,6 +19,7 @@ describe('AllReportsComponent', () => { MatPaginatorModule, MatSortModule, MatTableModule, + MatIconModule ] }).compileComponents(); })); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/pages.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/pages.component.spec.ts index 7a864aca..f1d4c6ad 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/pages.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/pages.component.spec.ts @@ -1,4 +1,5 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing' import { PagesComponent } from './pages.component'; @@ -8,7 +9,8 @@ describe('PagesComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ PagesComponent ] + declarations: [ PagesComponent ], + imports: [ RouterTestingModule ] }) .compileComponents(); })); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts index 0c8b8b06..dc987eff 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts @@ -1,9 +1,12 @@ import { TestBed } from '@angular/core/testing'; +import { HttpClientModule } from '@angular/common/http'; import { HeaderService } from './header.service'; describe('HeaderService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({ + imports:[HttpClientModule] + })); it('should be created', () => { const service: HeaderService = TestBed.get(HeaderService); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts index 065e6e56..6e8a3ba6 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts @@ -36,11 +36,14 @@ * */ import { TestBed } from '@angular/core/testing'; +import { HttpClientModule } from '@angular/common/http'; import { SidebarService } from './sidebar.service'; describe('SidenavService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({ + imports: [HttpClientModule] + })); it('should be created', () => { const service: SidebarService = TestBed.get(SidebarService); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.spec.ts index 9e7fd1c3..d6d659b9 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.spec.ts @@ -1,9 +1,12 @@ import { TestBed } from '@angular/core/testing'; +import { HttpClientModule } from '@angular/common/http'; import { UserService } from './user.service'; describe('UserService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({ + imports:[HttpClientModule] + })); it('should be created', () => { const service: UserService = TestBed.get(UserService); |