@@ -5,7 +5,6 @@ import {describe, expect, it, vi} from 'vitest'
5
5
import BaseStyles from '../BaseStyles'
6
6
import theme from '../theme'
7
7
import ThemeProvider from '../ThemeProvider'
8
- import { FeatureFlags } from '../FeatureFlags'
9
8
import { SegmentedControl } from '../SegmentedControl'
10
9
11
10
const segmentData = [
@@ -144,19 +143,13 @@ describe('SegmentedControl', () => {
144
143
}
145
144
} )
146
145
147
- it ( 'renders icon button with tooltip as label when feature flag is enabled ' , ( ) => {
146
+ it ( 'renders icon button with tooltip as label' , ( ) => {
148
147
const { getByRole, getByText} = render (
149
- < FeatureFlags
150
- flags = { {
151
- primer_react_segmented_control_tooltip : true ,
152
- } }
153
- >
154
- < SegmentedControl aria-label = "File view" >
155
- { segmentData . map ( ( { label, icon} ) => (
156
- < SegmentedControl . IconButton icon = { icon } aria-label = { label } key = { label } />
157
- ) ) }
158
- </ SegmentedControl >
159
- </ FeatureFlags > ,
148
+ < SegmentedControl aria-label = "File view" >
149
+ { segmentData . map ( ( { label, icon} ) => (
150
+ < SegmentedControl . IconButton icon = { icon } aria-label = { label } key = { label } />
151
+ ) ) }
152
+ </ SegmentedControl > ,
160
153
)
161
154
162
155
for ( const datum of segmentData ) {
@@ -167,41 +160,20 @@ describe('SegmentedControl', () => {
167
160
}
168
161
} )
169
162
170
- it ( 'renders icon button with tooltip description when feature flag is enabled ' , ( ) => {
163
+ it ( 'renders icon button with tooltip description' , ( ) => {
171
164
const { getByRole, getByText} = render (
172
- < FeatureFlags
173
- flags = { {
174
- primer_react_segmented_control_tooltip : true ,
175
- } }
176
- >
177
- < SegmentedControl aria-label = "File view" >
178
- { segmentData . map ( ( { label, icon, description} ) => (
179
- < SegmentedControl . IconButton icon = { icon } aria-label = { label } description = { description } key = { label } />
180
- ) ) }
181
- </ SegmentedControl >
182
- </ FeatureFlags > ,
183
- )
184
-
185
- for ( const datum of segmentData ) {
186
- const labelledButton = getByRole ( 'button' , { name : datum . label } )
187
- const tooltipElement = getByText ( datum . description )
188
- expect ( labelledButton ) . toHaveAttribute ( 'aria-describedby' , tooltipElement . id )
189
- expect ( labelledButton ) . toHaveAccessibleName ( datum . label )
190
- expect ( labelledButton ) . toHaveAttribute ( 'aria-label' , datum . label )
191
- }
192
- } )
193
-
194
- it ( 'renders icon button with aria-label and no tooltip' , ( ) => {
195
- const { getByRole} = render (
196
165
< SegmentedControl aria-label = "File view" >
197
- { segmentData . map ( ( { label, icon} ) => (
198
- < SegmentedControl . IconButton icon = { icon } aria-label = { label } key = { label } />
166
+ { segmentData . map ( ( { label, icon, description } ) => (
167
+ < SegmentedControl . IconButton icon = { icon } aria-label = { label } description = { description } key = { label } />
199
168
) ) }
200
169
</ SegmentedControl > ,
201
170
)
202
171
203
172
for ( const datum of segmentData ) {
204
173
const labelledButton = getByRole ( 'button' , { name : datum . label } )
174
+ const tooltipElement = getByText ( datum . description )
175
+ expect ( labelledButton ) . toHaveAttribute ( 'aria-describedby' , tooltipElement . id )
176
+ expect ( labelledButton ) . toHaveAccessibleName ( datum . label )
205
177
expect ( labelledButton ) . toHaveAttribute ( 'aria-label' , datum . label )
206
178
}
207
179
} )
0 commit comments