@@ -88,6 +88,17 @@ test('#adapter.setSelected adds selectedChipId to state', () => {
88
88
td . verify ( getSelectedChipIds ( ) , { times : 1 } ) ;
89
89
} ) ;
90
90
91
+ test ( '#chip.props.setSelected calls both #chip.props.handleSelect and #chipSet.props.handleSelect' , ( ) => {
92
+ const chipHandleSelect = coerceForTesting < ( id : string , selected : boolean ) => void > ( td . func ( ) ) ;
93
+ const wrapper = mount < ChipSet > ( < ChipSet > < Chip /> </ ChipSet > ) ;
94
+ wrapper . setProps ( { children : < Chip id = '1' handleSelect = { chipHandleSelect } /> } ) ;
95
+ wrapper . instance ( ) . handleSelect = coerceForTesting < ( chipIds : string , selected : boolean ) => void > ( td . func ( ) ) ;
96
+ const chip = wrapper . children ( ) . props ( ) . children [ 0 ] ;
97
+ chip . props . handleSelect ( '1' , true ) ;
98
+ td . verify ( wrapper . instance ( ) . handleSelect ( '1' , true ) , { times : 1 } ) ;
99
+ td . verify ( chipHandleSelect ( '1' , true ) , { times : 1 } ) ;
100
+ } ) ;
101
+
91
102
// this is bad
92
103
test ( '#adapter.setSelected removes selectedChipId from state' , ( ) => {
93
104
const wrapper = shallow < ChipSet > (
@@ -187,6 +198,16 @@ test('#handleSelect calls updates parent component with selectedChipIds correctl
187
198
td . verify ( handleChipSelection ( [ 'chip1' ] , [ 'chip1' , 'chip2' ] ) , { times : 1 } ) ;
188
199
} ) ;
189
200
201
+ test ( '#chip.props.handleInteraction calls both #chip.handleInteraction calls #foundation.handleChipInteraction' , ( ) => {
202
+ const handleChipInteraction = coerceForTesting < ( id : string ) => void > ( td . func ( ) ) ;
203
+ const wrapper = mount < ChipSet > ( < ChipSet > < Chip /> </ ChipSet > ) ;
204
+ wrapper . instance ( ) . handleInteraction = coerceForTesting < ( chipId : string ) => void > ( td . func ( ) ) ;
205
+ wrapper . setProps ( { children : < Chip id = '1' handleInteraction = { handleChipInteraction } /> } ) ;
206
+ const chip = wrapper . children ( ) . props ( ) . children [ 0 ] ;
207
+ chip . props . handleInteraction ( '1' ) ;
208
+ td . verify ( wrapper . instance ( ) . handleInteraction ( '1' ) , { times : 1 } ) ;
209
+ td . verify ( handleChipInteraction ( '1' ) , { times : 1 } ) ;
210
+ } ) ;
190
211
191
212
test ( '#handleInteraction calls #foundation.handleChipInteraction' , ( ) => {
192
213
const handleChipInteraction = td . func ( ) ;
@@ -336,6 +357,17 @@ test('chip is rendered with handleRemove method', () => {
336
357
td . verify ( wrapper . instance ( ) . handleRemove ( '1' ) , { times : 1 } ) ;
337
358
} ) ;
338
359
360
+ test ( '#chip.props.handleRemove calls both #chipSet.handleRemove and #chip.props.handleRemove' , ( ) => {
361
+ const handleChipRemove = coerceForTesting < ( id : string ) => void > ( td . func ( ) ) ;
362
+ const wrapper = mount < ChipSet > ( < ChipSet > < Chip /> </ ChipSet > ) ;
363
+ wrapper . instance ( ) . handleRemove = coerceForTesting < ( chipId : string ) => void > ( td . func ( ) ) ;
364
+ wrapper . setProps ( { children : < Chip id = '1' handleRemove = { handleChipRemove } /> } ) ;
365
+ const chip = wrapper . children ( ) . props ( ) . children [ 0 ] ;
366
+ chip . props . handleRemove ( '1' ) ;
367
+ td . verify ( wrapper . instance ( ) . handleRemove ( '1' ) , { times : 1 } ) ;
368
+ td . verify ( handleChipRemove ( '1' ) , { times : 1 } ) ;
369
+ } ) ;
370
+
339
371
test ( 'chip is rendered ChipCheckmark if is filter variants' , ( ) => {
340
372
const wrapper = mount (
341
373
< ChipSet filter >
0 commit comments