@@ -140,8 +140,7 @@ describe('<Preferences />', () => {
140
140
} ) ;
141
141
142
142
// get ahold of the text field
143
- const input = screen . getByTestId ( 'font-size-text-field' ) ;
144
- // const input = screen.getByRole("textbox", {name: /decrease font size/i});
143
+ const input = screen . getByRole ( 'textbox' , { name : / f o n t s i z e / i } ) ;
145
144
146
145
// change input to 24
147
146
act ( ( ) => {
@@ -150,7 +149,11 @@ describe('<Preferences />', () => {
150
149
151
150
// submit form
152
151
act ( ( ) => {
153
- fireEvent . submit ( screen . getByTestId ( 'font-size-form' ) ) ;
152
+ fireEvent . submit (
153
+ screen . getByRole ( 'form' , {
154
+ name : / s e t f o n t s i z e / i
155
+ } )
156
+ ) ;
154
157
} ) ;
155
158
156
159
// expect that setFontSize was called once with 24
@@ -165,7 +168,7 @@ describe('<Preferences />', () => {
165
168
} ) ;
166
169
167
170
// get ahold of the text field
168
- const input = screen . getByTestId ( ' font- size-text-field' ) ;
171
+ const input = screen . getByRole ( 'textbox' , { name : / f o n t s i z e / i } ) ;
169
172
170
173
act ( ( ) => {
171
174
fireEvent . change ( input , { target : { value : '100' } } ) ;
@@ -174,7 +177,11 @@ describe('<Preferences />', () => {
174
177
expect ( input . value ) . toBe ( '100' ) ;
175
178
176
179
act ( ( ) => {
177
- fireEvent . submit ( screen . getByTestId ( 'font-size-form' ) ) ;
180
+ fireEvent . submit (
181
+ screen . getByRole ( 'form' , {
182
+ name : / s e t f o n t s i z e / i
183
+ } )
184
+ ) ;
178
185
} ) ;
179
186
180
187
expect ( props . setFontSize ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -188,7 +195,7 @@ describe('<Preferences />', () => {
188
195
} ) ;
189
196
190
197
// get ahold of the text field
191
- const input = screen . getByTestId ( ' font- size-text-field' ) ;
198
+ const input = screen . getByRole ( 'textbox' , { name : / f o n t s i z e / i } ) ;
192
199
193
200
act ( ( ) => {
194
201
fireEvent . change ( input , { target : { value : '0' } } ) ;
@@ -197,7 +204,11 @@ describe('<Preferences />', () => {
197
204
expect ( input . value ) . toBe ( '0' ) ;
198
205
199
206
act ( ( ) => {
200
- fireEvent . submit ( screen . getByTestId ( 'font-size-form' ) ) ;
207
+ fireEvent . submit (
208
+ screen . getByRole ( 'form' , {
209
+ name : / s e t f o n t s i z e / i
210
+ } )
211
+ ) ;
201
212
} ) ;
202
213
203
214
expect ( props . setFontSize ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -213,7 +224,7 @@ describe('<Preferences />', () => {
213
224
} ) ;
214
225
215
226
// get ahold of the text field
216
- const input = screen . getByTestId ( ' font- size-text-field' ) ;
227
+ const input = screen . getByRole ( 'textbox' , { name : / f o n t s i z e / i } ) ;
217
228
218
229
act ( ( ) => {
219
230
fireEvent . change ( input , { target : { value : 'hi' } } ) ;
@@ -224,7 +235,11 @@ describe('<Preferences />', () => {
224
235
225
236
// we hit submit
226
237
act ( ( ) => {
227
- fireEvent . submit ( screen . getByTestId ( 'font-size-form' ) ) ;
238
+ fireEvent . submit (
239
+ screen . getByRole ( 'form' , {
240
+ name : / s e t f o n t s i z e / i
241
+ } )
242
+ ) ;
228
243
} ) ;
229
244
230
245
// it still sets the font size but it's still 12
@@ -239,7 +254,7 @@ describe('<Preferences />', () => {
239
254
} ) ;
240
255
241
256
// get ahold of the text field
242
- const input = screen . getByTestId ( ' font- size-text-field' ) ;
257
+ const input = screen . getByRole ( 'textbox' , { name : / f o n t s i z e / i } ) ;
243
258
244
259
act ( ( ) => {
245
260
fireEvent . change ( input , { target : { value : '-' } } ) ;
@@ -248,7 +263,11 @@ describe('<Preferences />', () => {
248
263
expect ( input . value ) . toBe ( '12' ) ;
249
264
250
265
act ( ( ) => {
251
- fireEvent . submit ( screen . getByTestId ( 'font-size-form' ) ) ;
266
+ fireEvent . submit (
267
+ screen . getByRole ( 'form' , {
268
+ name : / s e t f o n t s i z e / i
269
+ } )
270
+ ) ;
252
271
} ) ;
253
272
254
273
expect ( props . setFontSize ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments