1
- import React from 'react' ;
2
1
import { mount } from 'enzyme' ;
3
2
import TextArea from '../src' ;
4
- import { focusTest , sleep } from './utils' ;
5
3
import calculateNodeHeight , {
6
4
calculateNodeStyling ,
7
5
} from '../src/calculateNodeHeight' ;
6
+ import { focusTest , sleep } from './utils' ;
8
7
9
8
focusTest ( TextArea ) ;
10
9
10
+ let userAgentGetter ;
11
+
12
+ beforeEach ( ( ) => {
13
+ userAgentGetter = jest . spyOn ( window . navigator , 'userAgent' , 'get' ) ;
14
+ } ) ;
15
+
11
16
describe ( 'TextArea' , ( ) => {
12
17
const originalGetComputedStyle = window . getComputedStyle ;
13
18
beforeAll ( ( ) => {
@@ -241,6 +246,9 @@ describe('TextArea', () => {
241
246
} ) ;
242
247
243
248
it ( 'scroll to bottom when autoSize' , async ( ) => {
249
+ userAgentGetter . mockReturnValue (
250
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0' ,
251
+ ) ;
244
252
const wrapper = mount ( < TextArea autoSize /> , { attachTo : document . body } ) ;
245
253
wrapper . find ( 'textarea' ) . simulate ( 'focus' ) ;
246
254
wrapper . find ( 'textarea' ) . getDOMNode ( ) . focus ( ) ;
@@ -250,7 +258,8 @@ describe('TextArea', () => {
250
258
) ;
251
259
wrapper . find ( 'textarea' ) . simulate ( 'change' , { target : { value : '\n1' } } ) ;
252
260
await sleep ( 100 ) ;
253
- expect ( setSelectionRangeFn ) . toHaveBeenCalled ( ) ;
261
+ if ( navigator . userAgent . includes ( 'Firefox' ) )
262
+ expect ( setSelectionRangeFn ) . toHaveBeenCalled ( ) ;
254
263
wrapper . unmount ( ) ;
255
264
} ) ;
256
265
} ) ;
0 commit comments