@@ -2194,19 +2194,26 @@ describe('usePress', function () {
21942194 let handler = jest . fn ( ) ;
21952195 let mockUserSelect = 'contain' ;
21962196 let oldUserSelect = document . documentElement . style . webkitUserSelect ;
2197+ let platformGetter ;
2198+
2199+ beforeAll ( ( ) => {
2200+ platformGetter = jest . spyOn ( window . navigator , 'platform' , 'get' ) ;
2201+ } ) ;
21972202
21982203 afterAll ( ( ) => {
21992204 handler . mockClear ( ) ;
2205+ jest . restoreAllMocks ( ) ;
22002206 } ) ;
22012207
22022208 beforeEach ( ( ) => {
22032209 document . documentElement . style . webkitUserSelect = mockUserSelect ;
2210+ platformGetter . mockReturnValue ( 'iPhone' ) ;
22042211 } ) ;
22052212 afterEach ( ( ) => {
22062213 document . documentElement . style . webkitUserSelect = oldUserSelect ;
22072214 } ) ;
22082215
2209- it ( 'should add user-select: none to html element when press start' , function ( ) {
2216+ it ( 'should add user-select: none to html element when press start (iOS) ' , function ( ) {
22102217 let { getByText} = render (
22112218 < Example
22122219 onPressStart = { handler }
@@ -2221,7 +2228,23 @@ describe('usePress', function () {
22212228 expect ( document . documentElement . style . webkitUserSelect ) . toBe ( 'none' ) ;
22222229 } ) ;
22232230
2224- it ( 'should remove user-select: none to html element when press end' , function ( ) {
2231+ it ( 'should not add user-select: none to html element when press start (non-iOS)' , function ( ) {
2232+ platformGetter . mockReturnValue ( 'Android' ) ;
2233+ let { getByText} = render (
2234+ < Example
2235+ onPressStart = { handler }
2236+ onPressEnd = { handler }
2237+ onPressChange = { handler }
2238+ onPress = { handler }
2239+ onPressUp = { handler } />
2240+ ) ;
2241+
2242+ let el = getByText ( 'test' ) ;
2243+ fireEvent . touchStart ( el , { targetTouches : [ { identifier : 1 } ] } ) ;
2244+ expect ( document . documentElement . style . webkitUserSelect ) . toBe ( mockUserSelect ) ;
2245+ } ) ;
2246+
2247+ it ( 'should remove user-select: none to html element when press end (iOS)' , function ( ) {
22252248 let { getByText} = render (
22262249 < Example
22272250 onPressStart = { handler }
@@ -2252,7 +2275,7 @@ describe('usePress', function () {
22522275 expect ( document . documentElement . style . webkitUserSelect ) . toBe ( mockUserSelect ) ;
22532276 } ) ;
22542277
2255- it ( 'should not remove user-select: none when pressing two different elements quickly' , function ( ) {
2278+ it ( 'should not remove user-select: none when pressing two different elements quickly (iOS) ' , function ( ) {
22562279 let { getAllByText} = render (
22572280 < >
22582281 < Example
@@ -2288,7 +2311,7 @@ describe('usePress', function () {
22882311 expect ( document . documentElement . style . webkitUserSelect ) . toBe ( mockUserSelect ) ;
22892312 } ) ;
22902313
2291- it ( 'should remove user-select: none from html element if pressable component unmounts' , function ( ) {
2314+ it ( 'should remove user-select: none from html element if pressable component unmounts (iOS) ' , function ( ) {
22922315 let { getByText, unmount} = render (
22932316 < Example
22942317 onPressStart = { handler }
0 commit comments