From f2e1efeb586011b9a0d9d3cfe10858b9d07ac229 Mon Sep 17 00:00:00 2001 From: Rupinder Date: Thu, 26 Mar 2020 21:47:38 +0530 Subject: added some test cases for sql comp Added more test cases for sql.component.spec.ts Issue-ID: PORTAL-834 Change-Id: I4ff8536131db78c379286898e5dadb5240846b75 Signed-off-by: Rupinder --- .../Report_List/Report/sql/sql.component.spec.ts | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'ecomp-sdk/epsdk-app-overlay') 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 c894bff6..52082c9f 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 @@ -8,15 +8,20 @@ import { RouterTestingModule } from '@angular/router/testing'; import { SqlService } from './sql.service'; 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; let component: SQLComponent; let fixture: ComponentFixture; const reportId = "test"; - const finalGetObj = {"query":"dummyQuery"} + const finalGetObj = {"query":"dummyQuery"}; + let elements = []; + let environment = [ + { + "baseUrl": 'just for test' + } + ] beforeEach(async(() => { TestBed.configureTestingModule({ @@ -27,15 +32,17 @@ 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(() => { - fixture = TestBed.createComponent(SQLComponent); + fixture = TestBed.createComponent(SQLComponent); component = fixture.componentInstance; component.reportId1 = reportId; component.finalGetObj = finalGetObj; - sqlService = TestBed.get(SqlService); fixture.detectChanges(); }); @@ -44,6 +51,12 @@ describe('SQLComponentComponent', () => { expect(component).toBeTruthy(); }); + it('should test ngOninit subscribe method', () => { + spyOn(component, 'ngOnInit').and.callThrough(); + component.ngOnInit(); + expect(component.ngOnInit).toHaveBeenCalled(); + }); + it('should test ngOnInit method', () => { component.ngOnInit(); expect(component.showSaveSQLDialog).toEqual(false); @@ -69,10 +82,6 @@ describe('SQLComponentComponent', () => { expect(component.SQLclosable).toEqual(true); }); - it('should test validate method', () => { - component.validate(); - }); - it('should test closeSaveModal method', () => { component.closeSaveModal(); expect(component.showSaveSQLDialog).toEqual(component.showSaveSQLDialog); @@ -104,4 +113,10 @@ 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