@@ -13,12 +13,7 @@ import openControlledTest from './shared/openControlledTest';
13
13
import removeSelectedTest from './shared/removeSelectedTest' ;
14
14
import renderTest from './shared/renderTest' ;
15
15
import throwOptionValue from './shared/throwOptionValue' ;
16
- import {
17
- injectRunAllTimers ,
18
- findSelection ,
19
- expectOpen ,
20
- toggleOpen ,
21
- } from './utils/common' ;
16
+ import { injectRunAllTimers , findSelection , expectOpen , toggleOpen } from './utils/common' ;
22
17
23
18
describe ( 'Select.Tags' , ( ) => {
24
19
injectRunAllTimers ( jest ) ;
@@ -72,12 +67,7 @@ describe('Select.Tags', () => {
72
67
const handleSelect = jest . fn ( ) ;
73
68
const option2 = < Option value = "2" > 2</ Option > ;
74
69
const wrapper = mount (
75
- < Select
76
- mode = "tags"
77
- tokenSeparators = { [ ',' ] }
78
- onChange = { handleChange }
79
- onSelect = { handleSelect }
80
- >
70
+ < Select mode = "tags" tokenSeparators = { [ ',' ] } onChange = { handleChange } onSelect = { handleSelect } >
81
71
< Option value = "1" > 1</ Option >
82
72
{ option2 }
83
73
</ Select > ,
@@ -87,10 +77,7 @@ describe('Select.Tags', () => {
87
77
88
78
wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '2,3,4' } } ) ;
89
79
90
- expect ( handleChange ) . toHaveBeenCalledWith (
91
- [ '2' , '3' , '4' ] ,
92
- expect . anything ( ) ,
93
- ) ;
80
+ expect ( handleChange ) . toHaveBeenCalledWith ( [ '2' , '3' , '4' ] , expect . anything ( ) ) ;
94
81
expect ( handleSelect ) . toHaveBeenCalledTimes ( 3 ) ;
95
82
expect ( handleSelect ) . toHaveBeenLastCalledWith ( '4' , expect . anything ( ) ) ;
96
83
expect ( findSelection ( wrapper ) . text ( ) ) . toEqual ( '2' ) ;
@@ -100,6 +87,30 @@ describe('Select.Tags', () => {
100
87
expectOpen ( wrapper , false ) ;
101
88
} ) ;
102
89
90
+ it ( 'paste content to split' , ( ) => {
91
+ const onChange = jest . fn ( ) ;
92
+ const wrapper = mount (
93
+ < Select mode = "tags" tokenSeparators = { [ ' ' , '\n' ] } onChange = { onChange } >
94
+ < Option value = "1" > 1</ Option >
95
+ </ Select > ,
96
+ ) ;
97
+
98
+ wrapper . find ( 'input' ) . simulate ( 'paste' , {
99
+ clipboardData : {
100
+ getData : ( ) => `
101
+ light
102
+ bamboo
103
+ ` ,
104
+ } ,
105
+ } ) ;
106
+ wrapper . find ( 'input' ) . simulate ( 'change' , {
107
+ target : { value : ' light bamboo ' } ,
108
+ } ) ;
109
+
110
+ expect ( onChange ) . toHaveBeenCalledWith ( [ 'light' , 'bamboo' ] , expect . anything ( ) ) ;
111
+ expect ( onChange ) . toHaveBeenCalledTimes ( 1 ) ;
112
+ } ) ;
113
+
103
114
it ( 'renders unlisted item in value' , ( ) => {
104
115
const wrapper = mount (
105
116
< Select mode = "tags" value = "3" open >
@@ -180,9 +191,7 @@ describe('Select.Tags', () => {
180
191
</ span >
181
192
) ;
182
193
} ;
183
- const wrapper = mount (
184
- < Select mode = "tags" tokenSeparators = { [ ',' ] } tagRender = { tagRender } /> ,
185
- ) ;
194
+ const wrapper = mount ( < Select mode = "tags" tokenSeparators = { [ ',' ] } tagRender = { tagRender } /> ) ;
186
195
187
196
wrapper . find ( 'input' ) . instance ( ) . focus = jest . fn ( ) ;
188
197
0 commit comments