From 30c6c5b9769e20a06b744c8abcdaebeda5a6a676 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Thu, 2 Aug 2018 14:35:40 +0530 Subject: abousUs Component : Fixed test case Test case in aboutus component spec file failed with below error, Error: this.http.get is not a function Fixed this error Issue-ID: APPC-1064 Change-Id: I59426d9a96ab67a7fbef6c540be26b7204a7ee7f Signed-off-by: Arundathi Patil --- src/app/about-us/aboutus.component.spec.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/app/about-us/aboutus.component.spec.ts b/src/app/about-us/aboutus.component.spec.ts index 94eec94..f9bc0cd 100644 --- a/src/app/about-us/aboutus.component.spec.ts +++ b/src/app/about-us/aboutus.component.spec.ts @@ -39,12 +39,19 @@ class MockService { doStuff() { return this; } + get() { + return Observable.of(new Response( + new ResponseOptions({ + body: "some data" + } + ))); + } } describe('ContacUsComponent', () => { let component: AboutUsComponent; let fixture: ComponentFixture; - + beforeEach(async(() => { let http = new MockService(); @@ -53,12 +60,12 @@ describe('ContacUsComponent', () => { imports: [HttpModule, NgbModule.forRoot(), SimpleNotificationsModule.forRoot()], providers: [NgbModule, DialogService, { provide: Http, useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => { - return new Http(backend, defaultOptions); + return new Http(backend, defaultOptions); }, deps: [MockBackend, BaseRequestOptions] }, - { provide: MockBackend, useClass: MockBackend }, - { provide: BaseRequestOptions, useClass: BaseRequestOptions }, - {provide: Http, useValue: http}] + { provide: MockBackend, useClass: MockBackend }, + { provide: BaseRequestOptions, useClass: BaseRequestOptions }, + { provide: Http, useValue: http }] }).compileComponents(); })); @@ -72,9 +79,12 @@ describe('ContacUsComponent', () => { expect(component).toBeTruthy(); }); - it('should open modal', inject([NgbModule],(ngbModule: NgbModule) => { + it('should open modal', inject([NgbModule, Http], (ngbModule: NgbModule, http: Http) => { let content = 'test'; - component.open(content); + // component.open(content); + component.versionLogFile().subscribe((data) => { + expect(data).toBe('some Data'); + }); })); it('should download log file', () => { -- cgit 1.2.3-korg