From f7428eb4b2278d1f8b8922b3d75f788e05ded278 Mon Sep 17 00:00:00 2001 From: Rupinder Date: Fri, 24 Jan 2020 14:37:20 +0530 Subject: Added test case for role-function component Written 2 test cases for role-function component Issue-ID: PORTAL-808 Change-Id: I57af282383158a27e6127eda3356703f2d2fade5 Signed-off-by: Rupinder --- .../role-functions.component.spec.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'ecomp-sdk/epsdk-app-overlay') 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 24396996..a19fd52a 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 @@ -3,15 +3,19 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RoleFunctionsComponent } from './role-functions.component'; import { AdminService } from '../admin.service'; import { inject } from '@angular/core/testing'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; describe('RoleFunctionsComponent', () => { let component: RoleFunctionsComponent; let fixture: ComponentFixture; + let modalService: any; + let item: any; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RoleFunctionsComponent ] - }) + declarations: [ RoleFunctionsComponent ], + imports: [NgbModal] + }) .compileComponents(); })); @@ -19,14 +23,26 @@ describe('RoleFunctionsComponent', () => { fixture = TestBed.createComponent(RoleFunctionsComponent); component = fixture.componentInstance; fixture.detectChanges(); + modalService = TestBed.get(NgbModal); }); it('should create', () => { expect(component).toBeTruthy(); }); -it('should test getDismissReason function', inject([AdminService],(adminservice) => { + it('should test getDismissReason function', inject([AdminService],(adminservice) => { component.getRoleFunctions(); expect(adminservice.getRoleFunctionsList).toHaveBeenCalled(); })); + + it('should test getDismissReason function to call ngModal.open function', () => { + component.delRoleFunction({'label': 'abc'}); + expect(modalService.open).toHaveBeenCalled(); + }); + + it('should test delRoleFunction function', () => { + component.delRoleFunction(item); + expect(component.delRoleFunction).toHaveBeenCalled(); +}) + }); -- cgit 1.2.3-korg