Skip to content

Instantly share code, notes, and snippets.

@kutanov
Created April 17, 2020 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kutanov/cc2a0a1005e302a3403717263cb894e8 to your computer and use it in GitHub Desktop.
Save kutanov/cc2a0a1005e302a3403717263cb894e8 to your computer and use it in GitHub Desktop.
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('Русский заголовок');
});
});
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