AMBARI-21313 Log Search UI: implement service for string constants (additional patch). (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8aa761f9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8aa761f9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8aa761f9 Branch: refs/heads/branch-feature-logsearch-ui Commit: 8aa761f9661fd07a3b75ca6b53a8a5fa9cbe4d51 Parents: 72c7400 Author: ababiichuk <ababiic...@hortonworks.com> Authored: Fri May 19 18:08:08 2017 +0300 Committer: ababiichuk <ababiic...@hortonworks.com> Committed: Thu Jun 22 15:24:50 2017 +0300 ---------------------------------------------------------------------- .../src/app/app.component.spec.ts | 20 ++++++++++++-------- .../app/login-form/login-form.component.spec.ts | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8aa761f9/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.spec.ts index f6d229f..dfe6fbf 100644 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.spec.ts @@ -18,10 +18,17 @@ import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; +import {Http} from '@angular/http'; +import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; +import {TranslateHttpLoader} from '@ngx-translate/http-loader'; import {HttpClientService} from './http-client.service'; import {AppComponent} from './app.component'; +export function HttpLoaderFactory(http: Http) { + return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); +} + describe('AppComponent', () => { beforeEach(async(() => { const httpClient = { @@ -29,6 +36,11 @@ describe('AppComponent', () => { }; TestBed.configureTestingModule({ declarations: [AppComponent], + imports: [TranslateModule.forRoot({ + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [Http] + })], providers: [ { provide: HttpClientService, @@ -44,12 +56,4 @@ describe('AppComponent', () => { const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); })); - - it('should render title in a h1 tag', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain(app.title); - })); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/8aa761f9/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts index 0a13c1e..b58e834 100644 --- a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.spec.ts @@ -18,11 +18,17 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormsModule} from '@angular/forms'; -import {HttpModule} from '@angular/http'; +import {HttpModule, Http} from '@angular/http'; +import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; +import {TranslateHttpLoader} from '@ngx-translate/http-loader'; import {HttpClientService} from '../http-client.service'; import {LoginFormComponent} from './login-form.component'; +export function HttpLoaderFactory(http: Http) { + return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); +} + describe('LoginFormComponent', () => { let component: LoginFormComponent; let fixture: ComponentFixture<LoginFormComponent>; @@ -49,7 +55,15 @@ describe('LoginFormComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [LoginFormComponent], - imports: [HttpModule, FormsModule], + imports: [ + HttpModule, + FormsModule, + TranslateModule.forRoot({ + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [Http] + }) + ], providers: [ { provide: HttpClientService,