test cases written in roles component 02/104902/1
authorIndrijeet kumar <indriku1@in.ibm.com>
Wed, 1 Apr 2020 17:01:02 +0000 (22:31 +0530)
committerIndrijeet kumar <indriku1@in.ibm.com>
Wed, 1 Apr 2020 17:01:10 +0000 (22:31 +0530)
test cases written in roles component

Issue-ID: PORTAL-813
Change-Id: Ib8ca9b5b48538ef4d1fb6ca81bb83b8444198694
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts

index 8af2689..dcd637f 100644 (file)
@@ -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')
+  // })
 });