File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React from 'react';
2
2
import ReactDOM from 'react-dom' ;
3
3
import { expect } from 'chai' ;
4
4
import { shallow , mount } from 'enzyme' ;
5
- import { spy } from 'sinon' ;
5
+ import { spy , stub } from 'sinon' ;
6
6
import Suggestions from '../src/components/Suggestions' ;
7
7
import noop from 'lodash/noop' ;
8
8
import { DEFAULT_LABEL_FIELD } from '../src/components/constants' ;
@@ -221,4 +221,11 @@ describe('Suggestions', function() {
221
221
222
222
expect ( $el . find ( '.bar' ) . length ) . to . equal ( 4 ) ;
223
223
} ) ;
224
+
225
+ test ( 'should trigger the click handler on touchStart' , function ( ) {
226
+ const onTagClickedStub = stub ( ) ;
227
+ const $el = mount ( mockItem ( { handleClick : onTagClickedStub } ) ) ;
228
+ $el . find ( 'li' ) . first ( ) . simulate ( 'touchStart' ) ;
229
+ expect ( onTagClickedStub . calledOnce ) . to . be . true ;
230
+ } ) ;
224
231
} ) ;
Original file line number Diff line number Diff line change @@ -107,6 +107,13 @@ describe('Tag', () => {
107
107
expect ( spy . calledOnce ) . to . be . true ;
108
108
} ) ;
109
109
110
+ test ( 'should trigger the tag click handler on touchStart' , ( ) => {
111
+ const onTagClickedStub = sinon . stub ( ) ;
112
+ const $el = mount ( mockItem ( { onTagClicked : onTagClickedStub } ) ) ;
113
+ $el . find ( 'span' ) . simulate ( 'touchStart' ) ;
114
+ expect ( onTagClickedStub . calledOnce ) . to . be . true ;
115
+ } ) ;
116
+
110
117
test ( 'should be draggable' , ( ) => {
111
118
const root = TestUtils . renderIntoDocument ( mockItem ( ) ) ;
112
119
const backend = root . getManager ( ) . getBackend ( ) ;
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ class Suggestions extends Component {
102
102
< li
103
103
key = { i }
104
104
onMouseDown = { props . handleClick . bind ( null , i ) }
105
+ onTouchStart = { props . handleClick . bind ( null , i ) }
105
106
onMouseOver = { props . handleHover . bind ( null , i ) }
106
107
className = {
107
108
i === props . selectedIndex ? props . classNames . activeSuggestion : ''
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ class Tag extends Component {
32
32
className = { ClassNames ( 'tag-wrapper' , classNames . tag , className ) }
33
33
style = { { opacity : isDragging ? 0 : 1 , 'cursor' : canDrag ( props ) ? 'move' : 'auto' } }
34
34
onClick = { props . onTagClicked }
35
- onKeyDown = { props . onTagClicked } >
35
+ onKeyDown = { props . onTagClicked }
36
+ onTouchStart = { props . onTagClicked } >
36
37
{ label }
37
38
< RemoveComponent
38
39
tag = { props . tag }
You can’t perform that action at this time.
0 commit comments