Created
April 17, 2020 00:53
-
-
Save kutanov/cc2a0a1005e302a3403717263cb894e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TestBed, async } from '@angular/core/testing'; | |
import { RouterTestingModule } from '@angular/router/testing'; | |
import { AppComponent } from './app.component'; | |
import { getTranslocoModule } from './transloco-testing.module'; | |
describe('AppComponent', () => { | |
beforeEach(async(() => { | |
TestBed.configureTestingModule({ | |
imports: [ | |
getTranslocoModule(), | |
RouterTestingModule, | |
], | |
declarations: [ | |
AppComponent | |
], | |
providers: [] | |
}).compileComponents(); | |
})); | |
it('should create the app', () => { | |
const fixture = TestBed.createComponent(AppComponent); | |
const app = fixture.componentInstance; | |
expect(app).toBeTruthy(); | |
}); | |
it('should render title', () => { | |
const fixture = TestBed.createComponent(AppComponent); | |
fixture.detectChanges(); | |
const compiled = fixture.nativeElement; | |
console.log(compiled); | |
expect(compiled.querySelector('h1').textContent).toContain('Русский заголовок'); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
TranslocoConfig, | |
TranslocoTestingModule | |
} from '@ngneat/transloco'; | |
import en from '../assets/i18n/en.json'; | |
import ru from '../assets/i18n/ru.json'; | |
export function getTranslocoModule(config: Partial<TranslocoConfig> = {}) { | |
return TranslocoTestingModule.withLangs({ en: en, ru: ru }, { availableLangs: ['en', 'ru'], defaultLang: 'ru' }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment