1 import { ComponentFixture, TestBed } from '@angular/core/testing';
\r
2 import { FormsModule } from '@angular/forms';
\r
4 import { listLocales } from 'ngx-bootstrap/chronos';
\r
5 import { BsLocaleService } from 'ngx-bootstrap/datepicker';
\r
7 import { configureTestBed } from '../../../../testing/unit-test-helper';
\r
8 import { LanguageSelectorComponent } from './language-selector.component';
\r
10 describe('LanguageSelectorComponent', () => {
\r
11 let component: LanguageSelectorComponent;
\r
12 let fixture: ComponentFixture<LanguageSelectorComponent>;
\r
15 declarations: [LanguageSelectorComponent],
\r
16 providers: [BsLocaleService],
\r
17 imports: [FormsModule]
\r
21 fixture = TestBed.createComponent(LanguageSelectorComponent);
\r
22 component = fixture.componentInstance;
\r
23 fixture.detectChanges();
\r
24 spyOn(component, 'reloadWindow').and.callFake(() => component.ngOnInit());
\r
27 it('should create', () => {
\r
28 expect(component).toBeTruthy();
\r
31 it('should read current language', () => {
\r
32 expect(component.selectedLanguage).toBe('en-US');
\r
33 expect(listLocales()).toEqual([]);
\r
36 const expectLanguageChange = (lang) => {
\r
37 component.changeLanguage(lang);
\r
38 expect(component.selectedLanguage).toBe(lang);
\r
39 expect(listLocales().includes(lang.slice(0, 2))).toBe(true);
\r
42 it('should change to cs', () => {
\r
43 expectLanguageChange('cs');
\r
46 it('should change to de-DE', () => {
\r
47 expectLanguageChange('de-DE');
\r
50 it('should change to es-ES', () => {
\r
51 expectLanguageChange('es-ES');
\r
54 it('should change to fr-FR', () => {
\r
55 expectLanguageChange('fr-FR');
\r
58 it('should change to id-ID', () => {
\r
59 expectLanguageChange('id-ID');
\r
62 it('should change to it-IT', () => {
\r
63 expectLanguageChange('it-IT');
\r
66 it('should change to ja-JP', () => {
\r
67 expectLanguageChange('ja-JP');
\r
70 it('should change to pl-PL', () => {
\r
71 expectLanguageChange('pl-PL');
\r
74 it('should change to pt-BR', () => {
\r
75 expectLanguageChange('pt-BR');
\r
78 it('should change to zh-CN', () => {
\r
79 expectLanguageChange('zh-CN');
\r
82 it('should change to zh-TW', () => {
\r
83 expectLanguageChange('zh-TW');
\r