some test cases in roles component 47/106647/4
authorIndrijeet kumar <indriku1@in.ibm.com>
Sun, 26 Apr 2020 21:03:57 +0000 (02:33 +0530)
committerIndrijeet Kumar <indriku1@in.ibm.com>
Sun, 26 Apr 2020 23:03:03 +0000 (23:03 +0000)
some test cases in roles component

Issue-ID: PORTAL-813
Change-Id: Id57c0e7b8de25ffd1a2bb99562877e53bbf688cf
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 92d9613..11daaf8 100644 (file)
@@ -51,11 +51,18 @@ import { NgbModule, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
 import { NewRoleComponent } from './new-role/new-role.component';
+import { DataSource } from '@angular/cdk/table';
+import { AdminService } from '../admin.service';
+import { FormsModule } from '@angular/forms';
+import { HttpClientModule } from '@angular/common/http';
+import { HttpModule } from '@angular/http';
 
 describe('RolesComponent', () => {
   let component: RolesComponent;
   let fixture: ComponentFixture<RolesComponent>;
   let userService: UserService;
+  let adminService:AdminService;
+ // var stubData={"result":{"data":'{"data"}',"role":'{"role"}'}};
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
@@ -63,16 +70,26 @@ describe('RolesComponent', () => {
       declarations: [
          RolesComponent,
          InformationModalComponent,
+         NewRoleComponent
+        ],
+        providers:[
+          UserService,
+          DataSource,
+          AdminService,
+          HttpClientModule
         ],
       imports:[
         MatTableModule,
+        FormsModule,
+        HttpModule,
+        HttpClientModule,
         HttpClientTestingModule,
-        NgbModule.forRoot()
+        NgbModule.forRoot(),
       ]
     })
     TestBed.overrideModule(BrowserDynamicTestingModule,{
       set:{
-        entryComponents:[InformationModalComponent]
+        entryComponents:[InformationModalComponent, NewRoleComponent]
       }
     })
     .compileComponents();
@@ -83,6 +100,7 @@ describe('RolesComponent', () => {
     component = fixture.componentInstance;
     fixture.detectChanges();
     userService=TestBed.get(UserService);
+    adminService=TestBed.get(AdminService);
   });
 
   it('should create', () => {
@@ -95,15 +113,15 @@ describe('RolesComponent', () => {
    expect(spy).toHaveBeenCalled();
   })
 
+  it('should test getRole method',()=>{
+    component.getRole("value");
+  })
+
   it('should test delRoleConfirmPopUp method',()=>{
     component.delRoleConfirmPopUp('dummyargument');
     
   })
 
-  // it('should test openAdoleModaldNewR method',()=>{
-  //   component.openAdoleModaldNewR('dummydata2')
-  // })
-
   it('should test openAdoleModaldNewR method',()=>{
     component.toggleRole("")
   })
@@ -114,9 +132,9 @@ describe('RolesComponent', () => {
     component['getDismissReason']("");
   })
 
-  // it('should test applyFilter method',()=>{
-  //   component.applyFilter("filterValue T");
-  //   expect(component.dataSource.filter).toEqual("filtervalue");
-  // })
-  
+it('should test openAddNewRoleModal method',()=>{
+  component.openAddNewRoleModal("openAddNewRoleModal");
+  component.openAddNewRoleModal('undefined');
+})
+
 });