@@ -93,4 +93,41 @@ describe("Breadcrumbs component tests", () => {
9393 userEvent . click ( getByText ( "Preferences" ) ) ;
9494 expect ( onItemClick ) . toHaveBeenCalledWith ( "/" ) ;
9595 } ) ;
96+ test ( "handleOnClick prevents default and calls onClick when href is provided" , ( ) => {
97+ const onItemClick = jest . fn ( ) ;
98+ const { getByText } = render (
99+ < DxcBreadcrumbs
100+ onItemClick = { onItemClick }
101+ items = { [
102+ { label : "Home" , href : "/home" } ,
103+ { label : "Current Page" , href : "" } ,
104+ ] }
105+ />
106+ ) ;
107+ const homeLink = getByText ( "Home" ) ;
108+ userEvent . click ( homeLink ) ;
109+ expect ( onItemClick ) . toHaveBeenCalledWith ( "/home" ) ;
110+ } ) ;
111+ test ( "handleOnMouseEnter sets title when text overflows" , ( ) => {
112+ const { getByText } = render (
113+ < DxcBreadcrumbs
114+ items = { [
115+ { label : "Home" , href : "/home" } ,
116+ { label : "Very Long Current Page Label That Should Overflow" , href : "" } ,
117+ ] }
118+ />
119+ ) ;
120+
121+ const currentPageElement = getByText ( "Very Long Current Page Label That Should Overflow" ) ;
122+
123+ // Mock element dimensions to simulate overflow
124+ Object . defineProperty ( currentPageElement , "scrollWidth" , { value : 200 , configurable : true } ) ;
125+ Object . defineProperty ( currentPageElement , "clientWidth" , { value : 100 , configurable : true } ) ;
126+
127+ // Simulate mouse enter
128+ userEvent . hover ( currentPageElement ) ;
129+
130+ // Check if title is set when there's overflow
131+ expect ( currentPageElement . title ) . toBe ( "Very Long Current Page Label That Should Overflow" ) ;
132+ } ) ;
96133} ) ;
0 commit comments