summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts6
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts41
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts39
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.html2
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts9
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/dashboard-report.service.spec.ts27
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts75
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.component.spec.ts12
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts16
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts68
10 files changed, 254 insertions, 41 deletions
diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts
index c4742cb8..83f67d5b 100644
--- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright © 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");
@@ -48,6 +50,7 @@ import {
} from '@angular/material';
import { WelcomeDashboardComponent } from './welcome-dashboard.component';
+import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
describe('WelcomeDashboardComponent', () => {
let component: WelcomeDashboardComponent;
@@ -55,6 +58,7 @@ describe('WelcomeDashboardComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
+ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
declarations: [WelcomeDashboardComponent],
imports: [
NoopAnimationsModule,
@@ -77,4 +81,4 @@ describe('WelcomeDashboardComponent', () => {
it('should compile', () => {
expect(component).toBeTruthy();
});
-});
+}); \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts
index 5cd70a7c..b9d63853 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts
@@ -1,6 +1,8 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
+import { FormsModule } from '@angular/forms';
import { DashboardReportGridComponent } from './dashboard-report-grid.component';
+import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('DashboardReportGridComponent', () => {
let component: DashboardReportGridComponent;
@@ -8,10 +10,12 @@ describe('DashboardReportGridComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ DashboardReportGridComponent ]
+ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
+ declarations: [ DashboardReportGridComponent ],
+ imports: [FormsModule, HttpClientTestingModule]
})
.compileComponents();
- }));
+ }));
beforeEach(() => {
fixture = TestBed.createComponent(DashboardReportGridComponent);
@@ -22,4 +26,33 @@ describe('DashboardReportGridComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
-});
+
+ it('should test ngOnInit method', () => {
+ component.ngOnInit();
+ expect(component.showSpinner).toEqual(true);
+ expect(component.options.outerMargin).toEqual(true);
+ expect(component.options.outerMarginTop).toEqual(10);
+ expect(component.options.outerMarginRight).toEqual(10);
+ expect(component.options.outerMarginBottom).toEqual(700);
+ expect(component.options.outerMarginLeft).toEqual(10);
+ expect(component.options.scrollSensitivity).toEqual(10);
+ expect(component.options.scrollSpeed).toEqual(20);
+ expect(component.options.emptyCellDragMaxCols).toEqual(null);
+ expect(component.options.emptyCellDragMaxRows).toEqual(null);
+ expect(component.options.enableOccupiedCellDrop).toEqual(true);
+ expect(component.options.ignoreMarginInRow).toEqual(false);
+ expect(component.options.draggable.enabled).toEqual(true);
+ expect(component.options.resizable.enabled).toEqual(true);
+ expect(component.options.swap).toEqual(false);
+ expect(component.options.pushItems).toEqual(true);
+ expect(component.options.disablePushOnDrag).toEqual(false);
+ expect(component.options.disablePushOnResize).toEqual(false);
+ expect(component.options.pushResizeItems).toEqual(true);
+ expect(component.options.disableWindowResize).toEqual(true);
+ expect(component.options.disableWarnings).toEqual(false);
+ expect(component.options.scrollToNewItems).toEqual(true);
+ expect(component.options.enableEmptyCellDrop).toEqual(true);
+ expect(component.options.minCols).toEqual(2);
+ expect(component.options.minRows).toEqual(2);
+ })
+}); \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts
index a273f9e0..d693ebc0 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts
@@ -1,6 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
+import {FormsModule} from '@angular/forms';
import { RunReportFormFieldsComponent } from './run-report-form-fields.component';
+import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
+import {MatDatepickerModule} from '@angular/material/datepicker';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { RouterTestingModule } from '@angular/router/testing';
describe('RunReportFormFieldsComponent', () => {
let component: RunReportFormFieldsComponent;
@@ -8,6 +12,8 @@ describe('RunReportFormFieldsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ imports: [FormsModule, MatDatepickerModule, HttpClientTestingModule, RouterTestingModule],
declarations: [ RunReportFormFieldsComponent ]
})
.compileComponents();
@@ -22,4 +28,33 @@ describe('RunReportFormFieldsComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
-});
+
+ it('should test ngOnInit method', () => {
+ component.ngOnInit();
+ expect(component.showSpinner).toEqual(true);
+ expect(component.navigateToRun).toEqual(false);
+ });
+
+ it('should test getQueryString method', () => {
+ component.directCallQueryParams !== '';
+ component.getQueryString();
+ expect(component.getQueryString()).toEqual(component.directCallQueryParams);
+ component.directCallQueryParams == '';
+ component.getQueryString();
+ expect(component.getQueryString()).toEqual(component.queryString);
+ });
+
+ it('should test showError method', () => {
+ component.showError('test');
+ expect(component.errorMessage).toEqual('test'['errormessage']);
+ expect(component.stackTrace).toEqual('test'['stacktrace']);
+ expect(component.error).toEqual(true);
+ expect(component.showSpinner).toEqual(false);
+ });
+
+ it('should test showLabelFn method', () => {
+ component.showLabelFn();
+ expect(component.showLabel).toEqual(component.showLabel);
+ });
+
+}); \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.html
index 76183db3..71520ef7 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.html
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.html
@@ -15,7 +15,7 @@
</table>
<mat-paginator #paginator
- [length]="dataSource?.data.length"
+ [length]="dataSource?.data?.length"
[pageIndex]="0"
[pageSize]="15"
[pageSizeOptions]="[15, 25, 50, 100, 250]">
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts
index 3aa780fe..44765d49 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts
@@ -5,8 +5,11 @@ import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { RunReportResultSetComponent } from './run-report-result-set.component';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { HttpClient } from '@angular/common/http';
+import { RouterTestingModule } from '@angular/router/testing';
-describe('RunReportFinalTableComponent', () => {
+describe('RunReportResultSetComponent', () => {
let component: RunReportResultSetComponent;
let fixture: ComponentFixture<RunReportResultSetComponent>;
@@ -18,7 +21,9 @@ describe('RunReportFinalTableComponent', () => {
MatPaginatorModule,
MatSortModule,
MatTableModule,
- ]
+ HttpClientTestingModule,
+ RouterTestingModule
+ ],
}).compileComponents();
}));
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/dashboard-report.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/dashboard-report.service.spec.ts
index 5c6fc2cb..1c96f7ed 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/dashboard-report.service.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/dashboard-report.service.spec.ts
@@ -1,12 +1,37 @@
import { TestBed } from '@angular/core/testing';
import { DashboardReportService } from './dashboard-report.service';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { HttpClient } from '@angular/common/http';
+import { environment } from 'src/environments/environment';
describe('DashboardReportService', () => {
- beforeEach(() => TestBed.configureTestingModule({}));
+
+ let service: DashboardReportService;
+
+ beforeEach(() => {TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [HttpClient, HttpClientTestingModule, DashboardReportService]
+ });
+ service = TestBed.get(DashboardReportService);
+
+});
it('should be created', () => {
const service: DashboardReportService = TestBed.get(DashboardReportService);
expect(service).toBeTruthy();
});
+
+ it('should getReportData', () => {
+ service.getReportData("test").subscribe((res) => {
+ expect(res).toBe(environment);
+ });
+ });
+
+ it('should getReportDataWithFormFields', () => {
+ service.getReportDataWithFormFields("just", "test").subscribe((res) => {
+ expect(res).toBe(environment);
+ });
+ });
+
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts
index 38e7b3ba..96dcdbaa 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts
@@ -1,16 +1,26 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
+import { MatTableModule } from '@angular/material';
import { RunDashboardReportComponent } from './run-dashboard-report.component';
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { RouterModule } from '@angular/router';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { RouterTestingModule } from '@angular/router/testing';
+import { DashboardReportService } from './dashboard-report.service';
describe('RunDashboardReportComponent', () => {
let component: RunDashboardReportComponent;
let fixture: ComponentFixture<RunDashboardReportComponent>;
+ let dashboardService : DashboardReportService;
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ RunDashboardReportComponent ]
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ declarations: [ RunDashboardReportComponent ],
+ imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule],
+ providers: [DashboardReportService]
})
.compileComponents();
+ dashboardService = TestBed.get(DashboardReportService);
}));
beforeEach(() => {
@@ -19,7 +29,64 @@ describe('RunDashboardReportComponent', () => {
fixture.detectChanges();
});
- it('should create', () => {
+ it('should create', () => {
expect(component).toBeTruthy();
+ fixture.detectChanges();
+ });
+
+ it('should test ngOnInit method', () => {
+ component.queryString = "test";
+ component.ngOnInit();
+ expect(component.initialQueryString).toEqual("test");
+ expect(component.initCounter).toEqual(component.initCounter++);
+ spyOn(component, 'initialProcesses');
+ component.initialProcesses();
+ expect(component.initialProcesses).toHaveBeenCalled();
+ });
+
+ it('should test initialProcess method', () => {
+ component.initialProcesses();
+ expect(component.dataSource.paginator).toEqual(component.paginator);
+ });
+
+ it('should test ngOnChanges method', () => {
+ component.initialQueryString !== component.queryString;
+ component.initCounter > 0;
+ component.runButtonHitCounter !== component.hitCnt;
+
+ component.ngOnChanges();
+ expect(component.initialQueryString).toEqual(component.queryString);
+ expect(component.runButtonHitCounter).toEqual(component.hitCnt);
+
+ spyOn(component, 'initialProcesses');
+ spyOn(component, 'afterViewInitProcesses');
+ component.initialProcesses();
+ component.afterViewInitProcesses();
+ expect(component.initialProcesses).toHaveBeenCalled();
+ expect(component.afterViewInitProcesses).toHaveBeenCalled();
+
+ });
+
+ it('should test afterViewInitProcesses method', () => {
+ component.afterViewInitProcesses();
+ expect(component.displayedColumnsArr).toEqual(new Array());
+ expect(component.displayedRowObj).toEqual(new Array());
+ expect(component.displayedColumns).toEqual(new Array());
+ expect(component.formFieldList).toEqual(new Array());
+ expect(component.showSpinner).toEqual(true);
+ expect(component.isReady).toEqual(false);
+ expect(component.NEWdisplayedColumns).toEqual(new Array());
+
+ dashboardService.getReportDataWithFormFields("dummy", "test").subscribe((Response) => {
+ expect(component.formFieldPresent).toEqual(false);
+ expect(component.responseFormFieldListLength).toEqual(0);
+ expect(component.reportName).toEqual(Response["reportName"]);
+ });
+ });
+
+ it('should test applyFilter method', () => {
+ component.applyFilter("testing");
+ expect(component.dataSource.filter).toEqual("testing".trim().toLowerCase());
});
-});
+
+}); \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.component.spec.ts
index e9439dda..82eda851 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.component.spec.ts
@@ -1,6 +1,8 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RunComponent } from './run.component';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { RouterTestingModule } from '@angular/router/testing';
describe('RunComponent', () => {
let component: RunComponent;
@@ -8,7 +10,8 @@ describe('RunComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ RunComponent ]
+ declarations: [ RunComponent ],
+ imports: [HttpClientTestingModule, RouterTestingModule]
})
.compileComponents();
}));
@@ -22,4 +25,11 @@ describe('RunComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('should test ngOnInit method', () => {
+ component.ngOnInit();
+ component.reportType !== "Dashboard";
+ expect(component.stepNo).toEqual("8");
+ });
+
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
index b7f186b9..5afbea4b 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
@@ -1,6 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SecurityComponent } from './security.component';
+import { FormsModule } from '@angular/forms';
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { componentRefresh } from '@angular/core/src/render3/instructions';
describe('SecurityComponent', () => {
let component: SecurityComponent;
@@ -8,7 +12,9 @@ describe('SecurityComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ SecurityComponent ]
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ declarations: [ SecurityComponent ],
+ imports: [FormsModule, HttpClientTestingModule]
})
.compileComponents();
}));
@@ -22,4 +28,12 @@ describe('SecurityComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('should test ngOnInit method', () => {
+ component.reportType === "Dashboard";
+ component.ngOnInit();
+ expect(component.showSpinner).toEqual(true);
+ expect(component.stepNo).toEqual('6');
+ });
+
});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts
index 094e52b2..2140e0ae 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts
@@ -1,9 +1,12 @@
+
/*
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
* Copyright © 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");
@@ -14,50 +17,67 @@
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
* limitations under the License.
*
* ============LICENSE_END============================================
*
*
*/
-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
import { SearchComponent } from './search.component';
-
+import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
+import { MatTableModule, MatTableDataSource, MatMenuModule, MatSortModule, MatPaginatorModule } from '@angular/material';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { RouterTestingModule } from '@angular/router/testing';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
+import { NgbModalBackdrop } from '@ng-bootstrap/ng-bootstrap/modal/modal-backdrop';
+import { NgModel } from '@angular/forms';
describe('SearchComponent', () => {
let component: SearchComponent;
let fixture: ComponentFixture<SearchComponent>;
-
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ SearchComponent ]
+ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
+ declarations: [ SearchComponent , ConfirmationModalComponent],
+ imports: [NoopAnimationsModule,
+ MatPaginatorModule,
+ MatSortModule,
+ MatTableModule,
+ MatMenuModule,
+ HttpClientTestingModule,
+ RouterTestingModule,
+ ]
})
.compileComponents();
- }));
-
+ }));
beforeEach(() => {
fixture = TestBed.createComponent(SearchComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
-
it('should create', () => {
expect(component).toBeTruthy();
});
-});
+ it('should test getUsers method', () => {
+ component.getUsers();
+ expect(component.showSpinner).toEqual(true);
+ let response;
+ component.response.subscribe(data => {
+ expect(response).toEqual(data);
+ expect(component.result).toEqual(JSON.parse(response.data));
+ expect(component.profileList).toEqual(JSON.parse(component.result.profileList));
+ expect(component.dataSource).toEqual(new MatTableDataSource(component.profileList));
+ expect(component.dataSource.paginator).toEqual(component.paginator);
+ expect(component.dataSource.sort).toEqual(component.sort);
+ expect(component.showSpinner).toEqual(false);
+ });
+ });
+ // it('should test applyFilter method', () => {
+ // let filterValue = "test"
+ // component.applyFilter(filterValue);
+ // expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase());
+ // });
+}); \ No newline at end of file