diff --git a/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.test.tsx b/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.test.tsx index 53027575d53..70d3a59b13b 100644 --- a/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.test.tsx +++ b/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.test.tsx @@ -1,12 +1,19 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; -import type { StudioBreadcrumbsProps } from './StudioBreadcrumbs'; +import { defaultAriaLabel, StudioBreadcrumbsProps } from './StudioBreadcrumbs'; +import { + StudioBreadcrumbs, + StudioBreadcrumbsItem, + StudioBreadcrumbsLink, + StudioBreadcrumbsList, +} from './'; -import { StudioBreadcrumbs } from './'; +// Test data +const customAriaLabel = 'Custom aria label'; const renderWithRoot = (props?: StudioBreadcrumbsProps) => render( - + Nivå 3 @@ -28,10 +35,26 @@ const renderWithRoot = (props?: StudioBreadcrumbsProps) => ); describe('StudioBreadcrumbs', () => { - it('should render correctly with default props', () => { + it('should render with a default aria label', () => { renderWithRoot(); - expect(screen.getByRole('navigation')).toBeInTheDocument(); + const component = screen.getByRole('navigation'); + + expect(component).toHaveAttribute('aria-label', defaultAriaLabel); + }); + + it('should render with a custom aria label', () => { + renderWithRoot({ 'aria-label': customAriaLabel }); + + const component = screen.getByRole('navigation'); + + expect(component).toHaveAttribute('aria-label', customAriaLabel); + }); + + it('should export StudioBreadcrumbsList, StudioBreadcrumbsItem, and StudioBreadcrumbsLink', () => { + expect(StudioBreadcrumbsList).toBeDefined(); + expect(StudioBreadcrumbsItem).toBeDefined(); + expect(StudioBreadcrumbsLink).toBeDefined(); }); }); diff --git a/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.tsx b/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.tsx index e3bf5facffe..87fbabfd48f 100644 --- a/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.tsx +++ b/frontend/libs/studio-components/src/components/StudioBreadcrumbs/StudioBreadcrumbs.tsx @@ -6,8 +6,10 @@ export type StudioBreadcrumbsProps = { 'aria-label'?: string; } & HTMLAttributes; +export const defaultAriaLabel = 'You are here:'; + const StudioBreadcrumbs = forwardRef( - ({ 'aria-label': ariaLabel = 'You are here:', className, ...rest }, ref) => ( + ({ 'aria-label': ariaLabel = defaultAriaLabel, className, ...rest }, ref) => (