X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-FE-common%2Fsrc%2Fapp%2Fpages%2Fusers%2Fusers.component.spec.ts;h=10414842ec1141de76920496726968663d3f91fb;hb=4c6f6a443cb2e6effa995e77d56689c1c2dab4ad;hp=60d024bab36a228623caf3d4ccf92e5efbfb5e10;hpb=a03dfa273ef6e196bf65acc54b9357d35eb0ed5e;p=portal.git diff --git a/portal-FE-common/src/app/pages/users/users.component.spec.ts b/portal-FE-common/src/app/pages/users/users.component.spec.ts index 60d024ba..10414842 100644 --- a/portal-FE-common/src/app/pages/users/users.component.spec.ts +++ b/portal-FE-common/src/app/pages/users/users.component.spec.ts @@ -38,6 +38,16 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UsersComponent } from './users.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { NewUserModalComponent } from './new-user-modal/new-user-modal.component'; +import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { BulkUserComponent } from './bulk-user/bulk-user.component'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { Component, Input } from '@angular/core'; describe('UsersComponent', () => { let component: UsersComponent; @@ -45,8 +55,9 @@ describe('UsersComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ UsersComponent ] - }) + declarations: [ UsersComponent, NewUserModalComponent,BulkUserComponent,ConfirmationModalComponent,AppSearchUsersStubComponent,AppUsersdetailsFormStubComponent], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule,NgbModule.forRoot()] + }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [NewUserModalComponent,BulkUserComponent,ConfirmationModalComponent] } }) .compileComponents(); })); @@ -59,4 +70,55 @@ describe('UsersComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('openAddNewUserModal should return stubbed value', () => { + spyOn(component, 'openAddNewUserModal').and.callThrough(); + component.openAddNewUserModal(); + expect(component.openAddNewUserModal).toHaveBeenCalledWith(); + }); + it('openExistingUserModal should return stubbed value', () => { + spyOn(component, 'openExistingUserModal').and.callThrough(); + let user ={"firstName":"FirstTestName","lastName":"LastTestName","orgUserId":""}; + component.openExistingUserModal(user); + expect(component.openExistingUserModal).toHaveBeenCalledWith(user); + }); + + it('openBulkUserUploadModal should return stubbed value', () => { + spyOn(component, 'openBulkUserUploadModal').and.callThrough(); + component.openBulkUserUploadModal(); + expect(component.openBulkUserUploadModal).toHaveBeenCalledWith(); + }); + it('applyDropdownFilter should return stubbed value', () => { + spyOn(component, 'applyDropdownFilter').and.callThrough(); + let _appValue= {"value":"select-application"}; + component.applyDropdownFilter(_appValue); + expect(component.applyDropdownFilter).toHaveBeenCalledWith(_appValue); + _appValue= {"value":"Test"}; + component.applyDropdownFilter(_appValue); + expect(component.applyDropdownFilter).toHaveBeenCalledWith(_appValue); + }); + it('applyFilter should return stubbed value', () => { + spyOn(component, 'applyFilter').and.callThrough(); + component.applyFilter("Test"); + expect(component.applyFilter).toHaveBeenCalledWith("Test"); + }); + it('getAdminApps should return stubbed value', () => { + spyOn(component, 'getAdminApps').and.callThrough(); + component.getAdminApps(); + expect(component.getAdminApps).toHaveBeenCalledWith(); + }); }); + +@Component({selector: 'app-search-users', template: ''}) +class AppSearchUsersStubComponent { +@Input() searchTitle:any; +@Input() isSystemUser:boolean; +@Input() placeHolder:any; + + +} +@Component({selector: 'app-user-details-form', template: ''}) +class AppUsersdetailsFormStubComponent { + +} +