summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main
diff options
context:
space:
mode:
authorRupinder <rupinsi1@in.ibm.com>2020-03-04 18:48:53 +0530
committerRupinder <rupinsi1@in.ibm.com>2020-03-04 18:49:58 +0530
commitba569c5c747d1198cb336df38d191971e93eeb9b (patch)
treeecac9dfa4417678060fb2de856d2a660b5587cc1 /ecomp-sdk/epsdk-app-overlay/src/main
parentd1cb62e4628dcc6a445b48de9f618e50e25475f4 (diff)
added test case for sql component
Written more test case for sql component Issue-ID: PORTAL-834 Change-Id: I8c6d311b7c651fc939ce97aee7a8d3bf5d2ac7a5 Signed-off-by: Rupinder<rupinsi1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts59
1 files changed, 15 insertions, 44 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts
index 795afc25..c894bff6 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts
@@ -6,8 +6,10 @@ import { FormsModule } from '@angular/forms';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { SqlService } from './sql.service';
-import { Observable, of } from 'rxjs';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
import { element } from '@angular/core/src/render3';
+import { environment } from 'src/environments/environment';
describe('SQLComponentComponent', () => {
let sqlService: SqlService;
@@ -43,45 +45,23 @@ describe('SQLComponentComponent', () => {
});
it('should test ngOnInit method', () => {
-
- fixture.detectChanges();
component.ngOnInit();
expect(component.showSaveSQLDialog).toEqual(false);
expect(component.SQLPostResponse).toEqual(true);
expect(component.ValidatePostResponse).toEqual({});
-
- (done: DoneFn)=> {
- sqlService.getSQLTabData("test").subscribe(value => {
- expect(component.showSpinner).toEqual(true);
- expect(component.finalGetObj).toEqual(value);
- expect(component.sqlText).toEqual(component.finalGetObj.query);
- expect(component.showSpinner).toEqual(false);
- done();
- })
- }
-
});
- it('should test ngOnChanges method', () => {
+ it('should test ngOnChanges methods', () => {
fixture.detectChanges();
component.ngOnChanges();
expect(component.showSaveSQLDialog).toEqual(false);
expect(component.SQLPostResponse).toEqual(true);
expect(component.ValidatePostResponse).toEqual({});
-
- sqlService.getSQLTabData("test").subscribe((response) => {
- expect(component.showSpinner).toBe(true);
- expect(component.finalGetObj).toBe(response);
- expect(component.sqlText).toEqual(component.finalGetObj.query);
- expect(component.showSpinner).toEqual(false);
-
- });
-
});
- it('should test saveSQL method', () => {
- component.SQLPostResponse === true;
+ it('should test saveSQL methods if condition', () => {
+ component.SQLPostResponse = true;
component.saveSQL();
expect(component.SQLstatus).toEqual("Success!");
expect(component.SQLmessage).toEqual("Your change has been saved! Definition is updated.");
@@ -90,21 +70,7 @@ describe('SQLComponentComponent', () => {
});
it('should test validate method', () => {
-
- component.validate();
-
- sqlService.postSQLValidateAndSave("test").subscribe((Response) => {
- expect(component.showSpinner).toEqual(true);
- expect(component.ValidateResponseString).toEqual(Response["data"]["elements"]);
- expect(component.ValidatePostResponse).toEqual(JSON.parse(Response["data"]["elements"]));
-
- component.ValidatePostResponse["query"] !== undefined;
-
- expect(component.showModal).toEqual(true);
- expect(component.Validatestatus).toEqual("SQL Test Run - Executed!");
- expect(component.showValidateSQLDialog).toEqual(component.showValidateSQLDialog);
- expect(component.Validateclosable).toEqual(true);
- })
+ component.validate();
});
it('should test closeSaveModal method', () => {
@@ -114,13 +80,18 @@ describe('SQLComponentComponent', () => {
});
it('should test closeValidateModal method', () => {
- component.reportMode === "Create";
- component.Validatestatus == "SQL Test Run - Failed!";
-
+ component.reportMode = "Create";
+ component.Validatestatus = "SQL Test Run - Failed!";
component.closeValidateModal();
expect(component.sqlText).toEqual(component.sqlText);
expect(component.showValidateSQLDialog).toEqual(component.showValidateSQLDialog);
expect(component.Validateclosable).toEqual(false);
+
+ component.reportMode = "Create";
+ component.Validatestatus = "SQL Test Run - Passed!";
+ component.closeValidateModal();
+ expect(component.showValidateSQLDialog).toEqual(component.showValidateSQLDialog);
+ expect(component.Validateclosable).toEqual(false);
});
it('should test SetValidateResponseString method', () => {