test cases written in new-role-function comp 47/106047/1
authorIndrijeet kumar <indriku1@in.ibm.com>
Wed, 15 Apr 2020 19:50:16 +0000 (01:20 +0530)
committerIndrijeet kumar <indriku1@in.ibm.com>
Wed, 15 Apr 2020 19:51:29 +0000 (01:21 +0530)
test cases written in new-role-function component

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

index ecc0947..7ef63ba 100644 (file)
@@ -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");
@@ -41,7 +43,12 @@ import { NewRoleFunctionComponent } from './new-role-function.component';
 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
 import { FormsModule } from '@angular/forms';
 import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
+import {MatRadioModule } from '@angular/material';
+import { RouterTestingModule } from '@angular/router/testing';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
+import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
 
 describe('NewRoleFunctionComponent', () => {
   let component: NewRoleFunctionComponent;
@@ -50,10 +57,25 @@ describe('NewRoleFunctionComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       schemas:[CUSTOM_ELEMENTS_SCHEMA],
-      declarations: [ NewRoleFunctionComponent ],
-      imports:[FormsModule,HttpClientTestingModule],
+      declarations: [ 
+        NewRoleFunctionComponent,
+        ConfirmationModalComponent,
+        InformationModalComponent
+      ],
+      imports:[
+        FormsModule,
+        HttpClientTestingModule,
+        MatRadioModule,
+        RouterTestingModule,
+        NgbModule.forRoot()
+      ],
       providers:[NgbActiveModal]
     })
+    TestBed.overrideModule(BrowserDynamicTestingModule,{
+      set:{
+        entryComponents:[ConfirmationModalComponent,InformationModalComponent]
+      }
+    })
     .compileComponents();
   }));
 
@@ -63,7 +85,19 @@ describe('NewRoleFunctionComponent', () => {
     fixture.detectChanges();
   });
 
-  // it('should create', () => {
-  //   expect(component).toBeTruthy();
-  // });
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+
+  it('should test ngOnInit method',()=>{
+    component.ngOnInit();
+  })
+
+  it('should test saveRoleFunction method',()=>{
+    component.saveRoleFunction();
+  })
+
+  it('should test openConfirmationModal method',()=>{
+    component.openConfirmationModal("indrijeet","kumar")
+  })
 });