@@ -245,6 +245,93 @@ describe('Row Chips', () => {
245245 fixture . detectChanges ( ) ;
246246 expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeTruthy ( ) ;
247247 } ) ;
248+
249+ it ( 'should not begin editing on single click' , ( ) => {
250+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
251+ dispatchKeyboardEvent ( chipNativeElement , 'click' ) ;
252+ fixture . detectChanges ( ) ;
253+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
254+ } ) ;
255+
256+ it ( 'should begin editing on single click when focused' , fakeAsync ( ( ) => {
257+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
258+
259+ chipNativeElement . focus ( ) ;
260+ flush ( ) ;
261+ fixture . detectChanges ( ) ;
262+
263+ dispatchKeyboardEvent ( chipNativeElement , 'click' ) ;
264+ fixture . detectChanges ( ) ;
265+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeTruthy ( ) ;
266+ } ) ) ;
267+
268+ describe ( 'when disabled' , ( ) => {
269+ beforeEach ( ( ) => {
270+ testComponent . disabled = true ;
271+ fixture . changeDetectorRef . markForCheck ( ) ;
272+ fixture . detectChanges ( ) ;
273+ } ) ;
274+
275+ it ( 'should not begin editing on double click' , ( ) => {
276+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
277+ dispatchFakeEvent ( chipNativeElement , 'dblclick' ) ;
278+ fixture . detectChanges ( ) ;
279+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
280+ } ) ;
281+
282+ it ( 'should not begin editing on ENTER' , ( ) => {
283+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
284+ dispatchKeyboardEvent ( chipNativeElement , 'keydown' , ENTER ) ;
285+ fixture . detectChanges ( ) ;
286+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
287+ } ) ;
288+
289+ it ( 'should not begin editing on single click when focused' , fakeAsync ( ( ) => {
290+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
291+
292+ chipNativeElement . focus ( ) ;
293+ flush ( ) ;
294+ fixture . detectChanges ( ) ;
295+
296+ dispatchKeyboardEvent ( chipNativeElement , 'click' ) ;
297+ fixture . detectChanges ( ) ;
298+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
299+ } ) ) ;
300+ } ) ;
301+
302+ describe ( 'when not editable' , ( ) => {
303+ beforeEach ( ( ) => {
304+ testComponent . editable = false ;
305+ fixture . changeDetectorRef . markForCheck ( ) ;
306+ fixture . detectChanges ( ) ;
307+ } ) ;
308+
309+ it ( 'should not begin editing on double click' , ( ) => {
310+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
311+ dispatchFakeEvent ( chipNativeElement , 'dblclick' ) ;
312+ fixture . detectChanges ( ) ;
313+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
314+ } ) ;
315+
316+ it ( 'should not begin editing on ENTER' , ( ) => {
317+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
318+ dispatchKeyboardEvent ( chipNativeElement , 'keydown' , ENTER ) ;
319+ fixture . detectChanges ( ) ;
320+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
321+ } ) ;
322+
323+ it ( 'should not begin editing on single click when focused' , fakeAsync ( ( ) => {
324+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
325+
326+ chipNativeElement . focus ( ) ;
327+ flush ( ) ;
328+ fixture . detectChanges ( ) ;
329+
330+ dispatchKeyboardEvent ( chipNativeElement , 'click' ) ;
331+ fixture . detectChanges ( ) ;
332+ expect ( chipNativeElement . querySelector ( '.mat-chip-edit-input' ) ) . toBeFalsy ( ) ;
333+ } ) ) ;
334+ } ) ;
248335 } ) ;
249336
250337 describe ( 'editing behavior' , ( ) => {
0 commit comments