@@ -9,6 +9,9 @@ vi.mock('$env/static/public', () => ({
99 PUBLIC_NAV_BAR_LINKS : '{"Home": "/", "About": "/about"}'
1010} ) ) ;
1111
12+ // Set default value for the global define
13+ globalThis . __SHOW_REGION_NAME_IN_NAV_BAR__ = true ;
14+
1215// Mock ThemeSwitcher component
1316vi . mock ( '$lib/ThemeSwitch/ThemeSwitcher.svelte' , ( ) => ( {
1417 default : ( ) => '<div data-testid="theme-switcher">Theme Switcher</div>'
@@ -131,3 +134,44 @@ describe('Header', () => {
131134 expect ( textLink ) . toHaveClass ( 'block' , 'text-xl' , 'font-extrabold' ) ;
132135 } ) ;
133136} ) ;
137+
138+ describe ( 'Header with region name hidden' , ( ) => {
139+ beforeEach ( ( ) => {
140+ globalThis . __SHOW_REGION_NAME_IN_NAV_BAR__ = false ;
141+
142+ // Mock ResizeObserver
143+ global . ResizeObserver = vi . fn ( ) . mockImplementation ( ( ) => ( {
144+ observe : vi . fn ( ) ,
145+ unobserve : vi . fn ( ) ,
146+ disconnect : vi . fn ( )
147+ } ) ) ;
148+ } ) ;
149+
150+ afterEach ( ( ) => {
151+ globalThis . __SHOW_REGION_NAME_IN_NAV_BAR__ = true ;
152+ vi . restoreAllMocks ( ) ;
153+ } ) ;
154+
155+ test ( 'hides region name text when config is false' , ( ) => {
156+ render ( Header ) ;
157+
158+ // Region name text should not be present
159+ expect ( screen . queryByText ( 'Test Region' ) ) . not . toBeInTheDocument ( ) ;
160+ } ) ;
161+
162+ test ( 'logo alt text still uses region name for accessibility' , ( ) => {
163+ render ( Header ) ;
164+
165+ // Logo should still have the region name as alt text
166+ const logo = screen . getByRole ( 'img' ) ;
167+ expect ( logo ) . toHaveAttribute ( 'alt' , 'Test Region' ) ;
168+ } ) ;
169+
170+ test ( 'only logo link exists when region name is hidden' , ( ) => {
171+ render ( Header ) ;
172+
173+ // Should only have one link for the logo
174+ const links = screen . getAllByRole ( 'link' , { name : / t e s t r e g i o n / i } ) ;
175+ expect ( links ) . toHaveLength ( 1 ) ;
176+ } ) ;
177+ } ) ;
0 commit comments