@@ -34,6 +34,44 @@ const segmentData = [
3434describe ( 'SegmentedControl' , ( ) => {
3535 implementsClassName ( props => < SegmentedControl aria-label = "File view" { ...props } /> , classes . SegmentedControl )
3636
37+ it ( 'renders data-component attribute on the root' , ( ) => {
38+ const { getByRole} = render (
39+ < SegmentedControl aria-label = "File view" >
40+ { segmentData . map ( ( { label} ) => (
41+ < SegmentedControl . Button key = { label } > { label } </ SegmentedControl . Button >
42+ ) ) }
43+ </ SegmentedControl > ,
44+ )
45+
46+ expect ( getByRole ( 'list' ) ) . toHaveAttribute ( 'data-component' , 'SegmentedControl' )
47+ } )
48+
49+ it ( 'renders data-component attribute on segmented control buttons' , ( ) => {
50+ const { getByRole} = render (
51+ < SegmentedControl aria-label = "File view" >
52+ < SegmentedControl . Button > Preview</ SegmentedControl . Button >
53+ </ SegmentedControl > ,
54+ )
55+
56+ expect ( getByRole ( 'button' , { name : 'Preview' } ) . closest ( 'li' ) ) . toHaveAttribute (
57+ 'data-component' ,
58+ 'SegmentedControl.Button' ,
59+ )
60+ } )
61+
62+ it ( 'renders data-component attribute on segmented control icon buttons' , ( ) => {
63+ const { getByRole} = render (
64+ < SegmentedControl aria-label = "File view" >
65+ < SegmentedControl . IconButton icon = { ( ) => < EyeIcon /> } aria-label = "Preview" />
66+ </ SegmentedControl > ,
67+ )
68+
69+ expect ( getByRole ( 'button' , { name : 'Preview' } ) . closest ( 'li' ) ) . toHaveAttribute (
70+ 'data-component' ,
71+ 'SegmentedControl.IconButton' ,
72+ )
73+ } )
74+
3775 it ( 'renders with a selected segment - controlled' , ( ) => {
3876 const { getByText} = render (
3977 < SegmentedControl aria-label = "File view" >
0 commit comments