some test cases written in new-role component 59/106059/1
authorIndrijeet kumar <indriku1@in.ibm.com>
Wed, 15 Apr 2020 22:21:01 +0000 (03:51 +0530)
committerIndrijeet kumar <indriku1@in.ibm.com>
Wed, 15 Apr 2020 22:21:12 +0000 (03:51 +0530)
some test cases written in new-role component

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

index 4b496f1..8a30f2a 100644 (file)
@@ -43,9 +43,10 @@ import {FormsModule} from '@angular/forms';
 import { NewRoleComponent } from './new-role.component';
 import { MatTableModule } from '@angular/material'  
 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
-import { HttpClient, HttpClientModule } from '@angular/common/http';
 import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
 
 describe('NewRoleComponent', () => {
   let component: NewRoleComponent;
@@ -56,8 +57,21 @@ describe('NewRoleComponent', () => {
     TestBed.configureTestingModule({
       providers: [NgbActiveModal],
       schemas: [CUSTOM_ELEMENTS_SCHEMA] ,
-      declarations: [ NewRoleComponent ],
-      imports: [FormsModule, MatTableModule, HttpClientTestingModule]
+      declarations: [ 
+        NewRoleComponent,
+        ConfirmationModalComponent
+       ],
+      imports: [
+        FormsModule,
+         MatTableModule, 
+         HttpClientTestingModule,
+         NgbModule.forRoot()
+        ]
+    })
+    TestBed.overrideModule(BrowserDynamicTestingModule,{
+      set:{
+        entryComponents:[ConfirmationModalComponent]
+      }
     })
     .compileComponents();
   }));
@@ -69,7 +83,26 @@ describe('NewRoleComponent', () => {
     fixture.detectChanges();
   });
 
-  // it('should create', () => {
-  //   expect(component).toBeTruthy();
-  // });
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+
+  it('should test toggleRoleFunction method',()=>{
+    component.ociavailableRoleFunctions=1;
+    component.toggleRoleFunction("toggleRoleFunction")
+  })
+
+  it('should test populateTableData method',()=>{
+    component.populateTableData("populateTableData");
+    expect(component.roleFunctionDataSource.sort).toEqual(component.sort);
+    expect(component.roleFunctionDataSource.paginator).toEqual(component.paginator)
+  })
+
+  it('should test isRoleAlreadyExist method',()=>{
+    component.isRoleAlreadyExist("currentRoleName")
+  })
+
+  it('it should test openConfirmationModal method',()=>{
+    component.openConfirmationModal("indrijeet","kumar");
+  })
 });
\ No newline at end of file