2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
40 import { UsersComponent } from './users.component';
41 import { HttpClientTestingModule } from '@angular/common/http/testing';
42 import { FormsModule } from '@angular/forms';
43 import { NgMaterialModule } from 'src/app/ng-material-module';
44 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
45 import { NewUserModalComponent } from './new-user-modal/new-user-modal.component';
46 import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
47 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
48 import { BulkUserComponent } from './bulk-user/bulk-user.component';
49 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
50 import { Component, Input } from '@angular/core';
52 describe('UsersComponent', () => {
53 let component: UsersComponent;
54 let fixture: ComponentFixture<UsersComponent>;
56 beforeEach(async(() => {
57 TestBed.configureTestingModule({
58 declarations: [ UsersComponent, NewUserModalComponent,BulkUserComponent,ConfirmationModalComponent,AppSearchUsersStubComponent,AppUsersdetailsFormStubComponent],
59 imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule,NgbModule.forRoot()]
60 }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [NewUserModalComponent,BulkUserComponent,ConfirmationModalComponent] } })
65 fixture = TestBed.createComponent(UsersComponent);
66 component = fixture.componentInstance;
67 fixture.detectChanges();
70 it('should create', () => {
71 expect(component).toBeTruthy();
74 it('openAddNewUserModal should return stubbed value', () => {
75 spyOn(component, 'openAddNewUserModal').and.callThrough();
76 component.openAddNewUserModal();
77 expect(component.openAddNewUserModal).toHaveBeenCalledWith();
79 it('openExistingUserModal should return stubbed value', () => {
80 spyOn(component, 'openExistingUserModal').and.callThrough();
81 let user ={"firstName":"FirstTestName","lastName":"LastTestName","orgUserId":""};
82 component.openExistingUserModal(user);
83 expect(component.openExistingUserModal).toHaveBeenCalledWith(user);
86 it('openBulkUserUploadModal should return stubbed value', () => {
87 spyOn(component, 'openBulkUserUploadModal').and.callThrough();
88 component.openBulkUserUploadModal();
89 expect(component.openBulkUserUploadModal).toHaveBeenCalledWith();
91 it('applyDropdownFilter should return stubbed value', () => {
92 spyOn(component, 'applyDropdownFilter').and.callThrough();
93 let _appValue= {"value":"select-application"};
94 component.applyDropdownFilter(_appValue);
95 expect(component.applyDropdownFilter).toHaveBeenCalledWith(_appValue);
96 _appValue= {"value":"Test"};
97 component.applyDropdownFilter(_appValue);
98 expect(component.applyDropdownFilter).toHaveBeenCalledWith(_appValue);
100 it('applyFilter should return stubbed value', () => {
101 spyOn(component, 'applyFilter').and.callThrough();
102 component.applyFilter("Test");
103 expect(component.applyFilter).toHaveBeenCalledWith("Test");
105 it('getAdminApps should return stubbed value', () => {
106 spyOn(component, 'getAdminApps').and.callThrough();
107 component.getAdminApps();
108 expect(component.getAdminApps).toHaveBeenCalledWith();
112 @Component({selector: 'app-search-users', template: ''})
113 class AppSearchUsersStubComponent {
114 @Input() searchTitle:any;
115 @Input() isSystemUser:boolean;
116 @Input() placeHolder:any;
120 @Component({selector: 'app-user-details-form', template: ''})
121 class AppUsersdetailsFormStubComponent {