|
5 | 5 | dispatchEvent,
|
6 | 6 | dispatchFakeEvent,
|
7 | 7 | dispatchKeyboardEvent,
|
| 8 | + dispatchMouseEvent, |
8 | 9 | } from '@angular/cdk/testing/private';
|
9 | 10 | import {Component, DebugElement, ElementRef, ViewChild} from '@angular/core';
|
10 | 11 | import {ComponentFixture, TestBed, fakeAsync, flush, waitForAsync} from '@angular/core/testing';
|
@@ -248,19 +249,18 @@ describe('Row Chips', () => {
|
248 | 249 |
|
249 | 250 | it('should not begin editing on single click', () => {
|
250 | 251 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
|
251 |
| - dispatchKeyboardEvent(chipNativeElement, 'click'); |
| 252 | + dispatchMouseEvent(chipNativeElement, 'click'); |
252 | 253 | fixture.detectChanges();
|
253 | 254 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
|
254 | 255 | });
|
255 | 256 |
|
256 | 257 | it('should begin editing on single click when focused', fakeAsync(() => {
|
257 | 258 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
|
258 |
| - |
259 | 259 | chipNativeElement.focus();
|
260 |
| - flush(); |
261 |
| - fixture.detectChanges(); |
262 | 260 |
|
263 |
| - dispatchKeyboardEvent(chipNativeElement, 'click'); |
| 261 | + // Need to also simulate the mousedown as that sets the already focused flag. |
| 262 | + dispatchMouseEvent(chipNativeElement, 'mousedown'); |
| 263 | + dispatchMouseEvent(chipNativeElement, 'click'); |
264 | 264 | fixture.detectChanges();
|
265 | 265 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeTruthy();
|
266 | 266 | }));
|
@@ -288,12 +288,11 @@ describe('Row Chips', () => {
|
288 | 288 |
|
289 | 289 | it('should not begin editing on single click when focused', fakeAsync(() => {
|
290 | 290 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
|
291 |
| - |
292 | 291 | chipNativeElement.focus();
|
293 |
| - flush(); |
294 |
| - fixture.detectChanges(); |
295 | 292 |
|
296 |
| - dispatchKeyboardEvent(chipNativeElement, 'click'); |
| 293 | + // Need to also simulate the mousedown as that sets the already focused flag. |
| 294 | + dispatchMouseEvent(chipNativeElement, 'mousedown'); |
| 295 | + dispatchMouseEvent(chipNativeElement, 'click'); |
297 | 296 | fixture.detectChanges();
|
298 | 297 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
|
299 | 298 | }));
|
@@ -322,12 +321,11 @@ describe('Row Chips', () => {
|
322 | 321 |
|
323 | 322 | it('should not begin editing on single click when focused', fakeAsync(() => {
|
324 | 323 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
|
325 |
| - |
326 | 324 | chipNativeElement.focus();
|
327 |
| - flush(); |
328 |
| - fixture.detectChanges(); |
329 | 325 |
|
330 |
| - dispatchKeyboardEvent(chipNativeElement, 'click'); |
| 326 | + // Need to also simulate the mousedown as that sets the already focused flag. |
| 327 | + dispatchMouseEvent(chipNativeElement, 'mousedown'); |
| 328 | + dispatchMouseEvent(chipNativeElement, 'click'); |
331 | 329 | fixture.detectChanges();
|
332 | 330 | expect(chipNativeElement.querySelector('.mat-chip-edit-input')).toBeFalsy();
|
333 | 331 | }));
|
|
0 commit comments