@@ -140,8 +140,7 @@ describe('<Preferences />', () => {
140140 } ) ;
141141
142142 // 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 } ) ;
145144
146145 // change input to 24
147146 act ( ( ) => {
@@ -150,7 +149,11 @@ describe('<Preferences />', () => {
150149
151150 // submit form
152151 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+ ) ;
154157 } ) ;
155158
156159 // expect that setFontSize was called once with 24
@@ -165,7 +168,7 @@ describe('<Preferences />', () => {
165168 } ) ;
166169
167170 // 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 } ) ;
169172
170173 act ( ( ) => {
171174 fireEvent . change ( input , { target : { value : '100' } } ) ;
@@ -174,7 +177,11 @@ describe('<Preferences />', () => {
174177 expect ( input . value ) . toBe ( '100' ) ;
175178
176179 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+ ) ;
178185 } ) ;
179186
180187 expect ( props . setFontSize ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -188,7 +195,7 @@ describe('<Preferences />', () => {
188195 } ) ;
189196
190197 // 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 } ) ;
192199
193200 act ( ( ) => {
194201 fireEvent . change ( input , { target : { value : '0' } } ) ;
@@ -197,7 +204,11 @@ describe('<Preferences />', () => {
197204 expect ( input . value ) . toBe ( '0' ) ;
198205
199206 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+ ) ;
201212 } ) ;
202213
203214 expect ( props . setFontSize ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -213,7 +224,7 @@ describe('<Preferences />', () => {
213224 } ) ;
214225
215226 // 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 } ) ;
217228
218229 act ( ( ) => {
219230 fireEvent . change ( input , { target : { value : 'hi' } } ) ;
@@ -224,7 +235,11 @@ describe('<Preferences />', () => {
224235
225236 // we hit submit
226237 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+ ) ;
228243 } ) ;
229244
230245 // it still sets the font size but it's still 12
@@ -239,7 +254,7 @@ describe('<Preferences />', () => {
239254 } ) ;
240255
241256 // 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 } ) ;
243258
244259 act ( ( ) => {
245260 fireEvent . change ( input , { target : { value : '-' } } ) ;
@@ -248,7 +263,11 @@ describe('<Preferences />', () => {
248263 expect ( input . value ) . toBe ( '12' ) ;
249264
250265 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+ ) ;
252271 } ) ;
253272
254273 expect ( props . setFontSize ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments