File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/components/content-presentation/summary-list/__tests__ Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 11import { render } from '@testing-library/react' ;
2- import { createRef } from 'react' ;
2+ import { createRef , type ComponentProps } from 'react' ;
33
44import { SummaryList } from '..' ;
55
@@ -96,6 +96,26 @@ describe('SummaryList', () => {
9696 expect ( container ) . toMatchSnapshot ( ) ;
9797 } ) ;
9898
99+ it ( 'renders as custom element' , ( ) => {
100+ function CustomLink ( { children, href, ...rest } : ComponentProps < 'a' > ) {
101+ return (
102+ < a href = { href } { ...rest } data-custom-link = "true" >
103+ { children }
104+ </ a >
105+ ) ;
106+ }
107+
108+ const { container } = render (
109+ < SummaryList . Action href = "#" visuallyHiddenText = "example key" asElement = { CustomLink } >
110+ Edit
111+ </ SummaryList . Action > ,
112+ ) ;
113+
114+ const rowActionEl = container . querySelector ( 'a' ) ;
115+
116+ expect ( rowActionEl ?. dataset ) . toHaveProperty ( 'customLink' , 'true' ) ;
117+ } ) ;
118+
99119 it ( 'forwards refs' , ( ) => {
100120 const ref = createRef < HTMLAnchorElement > ( ) ;
101121
You can’t perform that action at this time.
0 commit comments