@@ -245,6 +245,27 @@ describe('BaseTable', () => {
245245 expect ( screen . getAllByRole ( 'row' ) ) . toHaveLength ( 4 ) ;
246246 } ) ;
247247
248+ it ( 'does not apply hover styling to the header row when hasHover is set' , ( ) => {
249+ // Use the public Table (provides TableContext); BaseTable alone has no
250+ // context, so rows wouldn't pick up hover styling at all.
251+ const { container} = render (
252+ < Table data = { users } columns = { columns } hasHover /> ,
253+ ) ;
254+ const headerRow = container . querySelector ( 'thead tr' ) ;
255+ const bodyRow = container . querySelector ( 'tbody tr' ) ;
256+ expect ( headerRow ) . not . toBeNull ( ) ;
257+ expect ( bodyRow ) . not . toBeNull ( ) ;
258+
259+ const headerClasses = new Set (
260+ ( headerRow ?. className ?? '' ) . split ( / \s + / ) . filter ( Boolean ) ,
261+ ) ;
262+ // The body row carries hover-styling class(es) that the header row does not.
263+ const bodyOnlyClasses = ( bodyRow ?. className ?? '' )
264+ . split ( / \s + / )
265+ . filter ( c => c && ! headerClasses . has ( c ) ) ;
266+ expect ( bodyOnlyClasses . length ) . toBeGreaterThan ( 0 ) ;
267+ } ) ;
268+
248269 it ( 'auto-generates columns from data keys when columns omitted' , ( ) => {
249270 render ( < BaseTable data = { users } /> ) ;
250271 const headers = screen . getAllByRole ( 'columnheader' ) ;
@@ -276,11 +297,7 @@ describe('BaseTable', () => {
276297
277298 it ( 'uses idKey function to key rows' , ( ) => {
278299 render (
279- < BaseTable
280- data = { users }
281- columns = { columns }
282- idKey = { item => item . email }
283- /> ,
300+ < BaseTable data = { users } columns = { columns } idKey = { item => item . email } /> ,
284301 ) ;
285302 expect ( screen . getAllByRole ( 'row' ) ) . toHaveLength ( 4 ) ;
286303 } ) ;
@@ -374,9 +391,7 @@ describe('BaseTable', () => {
374391 htmlProps : { ...props . htmlProps , 'data-testid' : 'plugin-table' } ,
375392 } ) ,
376393 } ;
377- render (
378- < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ,
379- ) ;
394+ render ( < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ) ;
380395 expect ( screen . getByTestId ( 'plugin-table' ) ) . toBeInTheDocument ( ) ;
381396 } ) ;
382397
@@ -387,9 +402,7 @@ describe('BaseTable', () => {
387402 htmlProps : { ...props . htmlProps , 'data-testid' : 'plugin-header-row' } ,
388403 } ) ,
389404 } ;
390- render (
391- < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ,
392- ) ;
405+ render ( < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ) ;
393406 expect ( screen . getByTestId ( 'plugin-header-row' ) ) . toBeInTheDocument ( ) ;
394407 } ) ;
395408
@@ -404,9 +417,7 @@ describe('BaseTable', () => {
404417 } ;
405418 } ,
406419 } ;
407- render (
408- < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ,
409- ) ;
420+ render ( < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ) ;
410421 expect ( receivedKeys ) . toEqual ( [ 'name' , 'age' , 'email' ] ) ;
411422 const headers = screen . getAllByRole ( 'columnheader' ) ;
412423 expect ( headers [ 0 ] ) . toHaveAttribute ( 'data-column' , 'name' ) ;
@@ -423,9 +434,7 @@ describe('BaseTable', () => {
423434 } ;
424435 } ,
425436 } ;
426- render (
427- < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ,
428- ) ;
437+ render ( < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ) ;
429438 expect ( receivedItems ) . toEqual ( [ 'Alice' , 'Bob' , 'Charlie' ] ) ;
430439 } ) ;
431440
@@ -437,9 +446,7 @@ describe('BaseTable', () => {
437446 return props ;
438447 } ,
439448 } ;
440- render (
441- < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ,
442- ) ;
449+ render ( < BaseTable data = { users } columns = { columns } plugins = { [ plugin ] } /> ) ;
443450 // 3 rows * 3 columns = 9 calls
444451 expect ( calls ) . toHaveLength ( 9 ) ;
445452 expect ( calls [ 0 ] ) . toEqual ( { col : 'name' , name : 'Alice' } ) ;
@@ -746,11 +753,7 @@ describe('Table', () => {
746753 } ) ,
747754 } ;
748755 render (
749- < Table
750- data = { users }
751- columns = { columns }
752- plugins = { { custom : userPlugin } }
753- /> ,
756+ < Table data = { users } columns = { columns } plugins = { { custom : userPlugin } } /> ,
754757 ) ;
755758 expect ( screen . getByTestId ( 'custom-plugin' ) ) . toBeInTheDocument ( ) ;
756759 } ) ;
@@ -767,11 +770,7 @@ describe('Table', () => {
767770 } ,
768771 } ;
769772 render (
770- < Table
771- data = { users }
772- columns = { columns }
773- plugins = { { custom : userPlugin } }
774- /> ,
773+ < Table data = { users } columns = { columns } plugins = { { custom : userPlugin } } /> ,
775774 ) ;
776775 expect ( screen . getByTestId ( 'after-xds' ) ) . toBeInTheDocument ( ) ;
777776 } ) ;
0 commit comments