From 58dab1bc661b4f99b4530a0d8d9fe6980f8ff3d8 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Wed, 29 Apr 2020 00:52:21 +0530 Subject: some test cases in sql component some test cases in sql component Issue-ID: PORTAL-813 Change-Id: I921f391346af0d02a707b2b87ae3b11424a02881 Signed-off-by: Indrijeet Kumar --- .../Report_List/Report/sql/sql.component.spec.ts | 30 +++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'ecomp-sdk') 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 52082c9f..68085b1e 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 @@ -16,7 +16,6 @@ describe('SQLComponentComponent', () => { let fixture: ComponentFixture; const reportId = "test"; const finalGetObj = {"query":"dummyQuery"}; - let elements = []; let environment = [ { "baseUrl": 'just for test' @@ -32,9 +31,7 @@ describe('SQLComponentComponent', () => { }) .compileComponents(); sqlService = TestBed.get(SqlService); - let response : any; spyOn(sqlService, 'getSQLTabData').and.returnValue(Observable.of(environment)); - spyOn(sqlService, 'postSQLValidateAndSave').and.returnValue(Observable.of(environment)); })); beforeEach(() => { @@ -82,6 +79,27 @@ describe('SQLComponentComponent', () => { expect(component.SQLclosable).toEqual(true); }); + it('should test saveSQL method else condition',()=>{ + component.SQLPostResponse = false; + component.saveSQL(); + }) + + it('should test validate method',()=>{ + component.sqlText="sqlText"; + var response={"data":{"elements":'{"elements":""}'}} + let spy=spyOn(sqlService,'postSQLValidateAndSave').and.returnValue(Observable.of(response)) + component.validate(); + expect(spy).toHaveBeenCalled(); + }) + + it('should test validate method',()=>{ + component.sqlText="sqlText"; + var response={"data":{"elements":'{"query":"query"}'}} + let spy=spyOn(sqlService,'postSQLValidateAndSave').and.returnValue(Observable.of(response)) + component.validate(); + expect(spy).toHaveBeenCalled(); + }) + it('should test closeSaveModal method', () => { component.closeSaveModal(); expect(component.showSaveSQLDialog).toEqual(component.showSaveSQLDialog); @@ -113,10 +131,4 @@ describe('SQLComponentComponent', () => { expect(component.GetValidateResponseString()).toEqual("test"); }); -// it('should test validate method', () => { -// spyOn(component, 'validate').and.callThrough(); -// component.validate(); -// expect(component.validate).toHaveBeenCalled(); -// }); - }); -- cgit 1.2.3-korg