Added test case for role-function component 41/100741/1
authorRupinder <rupinsi1@in.ibm.com>
Fri, 24 Jan 2020 09:07:20 +0000 (14:37 +0530)
committerRupinder <rupinsi1@in.ibm.com>
Fri, 24 Jan 2020 09:07:32 +0000 (14:37 +0530)
Written 2 test cases for role-function component

Issue-ID: PORTAL-808
Change-Id: I57af282383158a27e6127eda3356703f2d2fade5
Signed-off-by: Rupinder <rupinsi1@in.ibm.com>
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts

index 2439699..a19fd52 100644 (file)
@@ -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<RoleFunctionsComponent>;
+  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();
+})
+
 });