File tree Expand file tree Collapse file tree
src/app/shared/lang-switch Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,4 +10,29 @@ describe('Header', () => {
1010 // Analyze <ds-header> for accessibility
1111 testA11y ( 'ds-header' ) ;
1212 } ) ;
13+
14+ it ( 'should allow for changing language to German (for example)' , ( ) => {
15+ cy . visit ( '/' ) ;
16+
17+ // Click the language switcher (globe) in header
18+ cy . get ( 'a[data-test="lang-switch"]' ) . click ( ) ;
19+ // Click on the "Deusch" language in dropdown
20+ cy . get ( '#language-menu-list li' ) . contains ( 'Deutsch' ) . click ( ) ;
21+
22+ // HTML "lang" attribute should switch to "de"
23+ cy . get ( 'html' ) . invoke ( 'attr' , 'lang' ) . should ( 'eq' , 'de' ) ;
24+
25+ // Login menu should now be in German
26+ cy . get ( 'a[data-test="login-menu"]' ) . contains ( 'Anmelden' ) ;
27+
28+ // Change back to English from language switcher
29+ cy . get ( 'a[data-test="lang-switch"]' ) . click ( ) ;
30+ cy . get ( '#language-menu-list li' ) . contains ( 'English' ) . click ( ) ;
31+
32+ // HTML "lang" attribute should switch to "en"
33+ cy . get ( 'html' ) . invoke ( 'attr' , 'lang' ) . should ( 'eq' , 'en' ) ;
34+
35+ // Login menu should now be in English
36+ cy . get ( 'a[data-test="login-menu"]' ) . contains ( 'Log In' ) ;
37+ } ) ;
1338} ) ;
Original file line number Diff line number Diff line change 55 aria-haspopup ="menu "
66 [title] ="'nav.language' | translate "
77 (click) ="$event.preventDefault() " data-toggle ="dropdown " ngbDropdownToggle
8+ data-test ="lang-switch "
89 tabindex ="0 ">
910 < i class ="fas fa-globe-asia fa-lg fa-fw "> </ i >
1011 </ a >
You can’t perform that action at this time.
0 commit comments