From 4d6d26f15e748f5b1127c50b484f8cf7eab2dc14 Mon Sep 17 00:00:00 2001
From: Indrijeet kumar <indriku1@in.ibm.com>
Date: Wed, 4 Mar 2020 12:31:47 +0530
Subject: test cases written in role-functions component

test cases written in role-functions component

Issue-ID: PORTAL-813
Change-Id: I6b46b5fe0f8df01ac3a65409224eead7b6e7ece0
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
---
 .../role-functions.component.spec.ts               | 52 ++++++++++++++++++++--
 1 file changed, 48 insertions(+), 4 deletions(-)

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 b0dc3442..8c958531 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
@@ -4,6 +4,8 @@
  * ===================================================================
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
+ * Modification Copyright © 2020 IBM.
+ * ===================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
  * under the Apache License, Version 2.0 (the "License");
@@ -35,28 +37,70 @@
  *
  * 
  */
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
 
 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 { UserService } from 'src/app/shared/services/user/user.service';
+import { AdminService } from '../admin.service';
+import { MatSelectModule, MatAutocompleteModule } from '@angular/material';
+import { Observable } from 'rxjs';
 
 describe('RoleFunctionsComponent', () => {
   let component: RoleFunctionsComponent;
   let fixture: ComponentFixture<RoleFunctionsComponent>;
+  let userService:UserService;
+  let adminService:AdminService;
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
-      declarations: [ RoleFunctionsComponent ]
+      schemas: [CUSTOM_ELEMENTS_SCHEMA],
+      declarations: [ RoleFunctionsComponent ],
+      imports: [HttpClientTestingModule,
+         RdpModule,
+          FormsModule,
+         // MatSelectModule,
+        ],
+        providers:[MatSelectModule]
     })
     .compileComponents();
-  }));
+  }));  
 
   beforeEach(() => {
+    TestBed.configureTestingModule({
+      providers:[AdminService]
+    })
     fixture = TestBed.createComponent(RoleFunctionsComponent);
     component = fixture.componentInstance;
     fixture.detectChanges();
+    userService=TestBed.get(UserService);
+    adminService=TestBed.get(AdminService);
   });
 
-  it('should create', () => {
+  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 subscribe in getRoleFunctions',()=>{
+  //   it('should test getRoleFunctions method',()=>{
+  //     let spy=spyOn(adminService,'getRoleFunctionList').and.returnValue(Observable.of('you object'));
+  //     component.getRoleFunctions();
+  //     expect(spy).toHaveBeenCalled();
+  //   })
+  // })
+
 });
-- 
cgit 1.2.3-korg