diff options
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts index b0dc3442..8c958531 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.spec.ts @@ -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"); @@ -35,28 +37,70 @@ * * */ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing'; import { RoleFunctionsComponent } from './role-functions.component'; +import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RdpModule } from 'portalsdk-tag-lib'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { UserService } from 'src/app/shared/services/user/user.service'; +import { AdminService } from '../admin.service'; +import { MatSelectModule, MatAutocompleteModule } from '@angular/material'; +import { Observable } from 'rxjs'; describe('RoleFunctionsComponent', () => { let component: RoleFunctionsComponent; let fixture: ComponentFixture<RoleFunctionsComponent>; + let userService:UserService; + let adminService:AdminService; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RoleFunctionsComponent ] + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [ RoleFunctionsComponent ], + imports: [HttpClientTestingModule, + RdpModule, + FormsModule, + // MatSelectModule, + ], + providers:[MatSelectModule] }) .compileComponents(); - })); + })); beforeEach(() => { + TestBed.configureTestingModule({ + providers:[AdminService] + }) fixture = TestBed.createComponent(RoleFunctionsComponent); component = fixture.componentInstance; fixture.detectChanges(); + userService=TestBed.get(UserService); + adminService=TestBed.get(AdminService); }); - it('should create', () => { + it('should create', () => { expect(component).toBeTruthy(); }); + + describe('test for subscribe in ngOnInit',()=>{ + it('should test ngOnInit method',()=>{ + let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('you object')); + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + }) + }) + it('Admin service injection check', inject([AdminService],(injectService:AdminService) =>{ + expect(injectService).toBe(adminService); + })); + + // describe('test subscribe in getRoleFunctions',()=>{ + // it('should test getRoleFunctions method',()=>{ + // let spy=spyOn(adminService,'getRoleFunctionList').and.returnValue(Observable.of('you object')); + // component.getRoleFunctions(); + // expect(spy).toHaveBeenCalled(); + // }) + // }) + }); |