summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunder Tattavarada <statta@research.att.com>2020-07-07 17:09:02 +0000
committerGerrit Code Review <gerrit@onap.org>2020-07-07 17:09:02 +0000
commitaa0aebe9769bb7b2c19d0bbe6a85c8b37abf17c3 (patch)
treec53a4556244971365108c78cc443c4dab6ed4bee
parentc8b1e441251223784574980a179dfb22217feecf (diff)
parent766cfb15029ca52efec42c44f3704a1376ebe7fb (diff)
Merge "some test cases in new-role component"
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts73
1 files changed, 65 insertions, 8 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts
index 4b496f1b..4eca8263 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts
@@ -43,21 +43,46 @@ 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';
+import { AdminService } from '../../admin.service';
+import { Observable } from 'rxjs';
+import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
describe('NewRoleComponent', () => {
let component: NewRoleComponent;
let fixture: ComponentFixture<NewRoleComponent>;
let role1 = "";
+ let adminService:AdminService;
+ var _element={
+ "selected":false,
+ "code":"code",
+ "type":"type",
+ "action":"action"
+ };
beforeEach(async(() => {
TestBed.configureTestingModule({
- providers: [NgbActiveModal],
+ providers: [NgbActiveModal,AdminService],
schemas: [CUSTOM_ELEMENTS_SCHEMA] ,
- declarations: [ NewRoleComponent ],
- imports: [FormsModule, MatTableModule, HttpClientTestingModule]
+ declarations: [
+ NewRoleComponent,
+ ConfirmationModalComponent,
+ InformationModalComponent
+ ],
+ imports: [
+ FormsModule,
+ MatTableModule,
+ HttpClientTestingModule,
+ NgbModule.forRoot()
+ ]
+ })
+ TestBed.overrideModule(BrowserDynamicTestingModule,{
+ set:{
+ entryComponents:[ConfirmationModalComponent,InformationModalComponent]
+ }
})
.compileComponents();
}));
@@ -67,9 +92,41 @@ describe('NewRoleComponent', () => {
component = fixture.componentInstance;
component.role = role1;
fixture.detectChanges();
+ adminService=TestBed.get(AdminService);
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
});
- // it('should create', () => {
- // expect(component).toBeTruthy();
- // });
+ it('should test delRoleFunctionConfirmPopUp method',()=>{
+ component.delRoleFunctionConfirmPopUp("abc","def");
+ })
+
+ it('should test else condition in saveChanges method',()=>{
+ spyOn(adminService,'saveRole').and.returnValue(Observable.of('your object'));
+ component.saveChanges()
+ })
+
+ it('should test toggleRoleFunction method',()=>{
+ component.finalSelectedRoleFunctions="Indrijeet kuma";
+ component.ociavailableRoleFunctions="i";
+ component.finalSelectedRoleFunctions="k";
+ component.toggleRoleFunction(_element)
+ })
+
+ 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.availableRoles={"name":["currentRoleName"]};
+ component.isRoleAlreadyExist("currentRoleName")
+ })
+
+ it('it should test openConfirmationModal method',()=>{
+ component.openConfirmationModal("test","value");
+ })
}); \ No newline at end of file