]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.spec.ts
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / components / language-selector / language-selector.component.spec.ts
1 import { ComponentFixture, TestBed } from '@angular/core/testing';
2 import { FormsModule } from '@angular/forms';
3
4 import { listLocales } from 'ngx-bootstrap/chronos';
5 import { BsLocaleService } from 'ngx-bootstrap/datepicker';
6
7 import { configureTestBed } from '../../../../testing/unit-test-helper';
8 import { LanguageSelectorComponent } from './language-selector.component';
9
10 describe('LanguageSelectorComponent', () => {
11 let component: LanguageSelectorComponent;
12 let fixture: ComponentFixture<LanguageSelectorComponent>;
13
14 configureTestBed({
15 declarations: [LanguageSelectorComponent],
16 providers: [BsLocaleService],
17 imports: [FormsModule]
18 });
19
20 beforeEach(() => {
21 fixture = TestBed.createComponent(LanguageSelectorComponent);
22 component = fixture.componentInstance;
23 fixture.detectChanges();
24 spyOn(window.location, 'reload').and.callFake(() => component.ngOnInit());
25 });
26
27 it('should create', () => {
28 expect(component).toBeTruthy();
29 });
30
31 it('should read current language', () => {
32 expect(component.selectedLanguage).toBe('en-US');
33 expect(listLocales()).toEqual([]);
34 });
35
36 const expectLanguageChange = (lang) => {
37 component.changeLanguage(lang);
38 expect(component.selectedLanguage).toBe(lang);
39 expect(listLocales().includes(lang.slice(0, 2))).toBe(true);
40 };
41
42 it('should change to cs', () => {
43 expectLanguageChange('cs');
44 });
45
46 it('should change to de-DE', () => {
47 expectLanguageChange('de-DE');
48 });
49
50 it('should change to es-ES', () => {
51 expectLanguageChange('es-ES');
52 });
53
54 it('should change to fr-FR', () => {
55 expectLanguageChange('fr-FR');
56 });
57
58 it('should change to id-ID', () => {
59 expectLanguageChange('id-ID');
60 });
61
62 it('should change to it-IT', () => {
63 expectLanguageChange('it-IT');
64 });
65
66 it('should change to ja-JP', () => {
67 expectLanguageChange('ja-JP');
68 });
69
70 it('should change to ko-KR', () => {
71 expectLanguageChange('ko-KR');
72 });
73
74 it('should change to pl-PL', () => {
75 expectLanguageChange('pl-PL');
76 });
77
78 it('should change to pt-BR', () => {
79 expectLanguageChange('pt-BR');
80 });
81
82 it('should change to zh-CN', () => {
83 expectLanguageChange('zh-CN');
84 });
85
86 it('should change to zh-TW', () => {
87 expectLanguageChange('zh-TW');
88 });
89 });