|
1 | 1 | import {Directionality} from '@angular/cdk/bidi';
|
2 | 2 | import {COMMA, ENTER, TAB} from '@angular/cdk/keycodes';
|
3 | 3 | import {PlatformModule} from '@angular/cdk/platform';
|
4 |
| -import {dispatchKeyboardEvent} from '@angular/cdk/testing/private'; |
| 4 | +import { |
| 5 | + createKeyboardEvent, |
| 6 | + dispatchKeyboardEvent, |
| 7 | + dispatchEvent, |
| 8 | +} from '@angular/cdk/testing/private'; |
5 | 9 | import {Component, DebugElement, ViewChild} from '@angular/core';
|
6 | 10 | import {ComponentFixture, TestBed, fakeAsync, flush, waitForAsync} from '@angular/core/testing';
|
7 | 11 | import {MatFormFieldModule} from '@angular/material/form-field';
|
@@ -248,6 +252,20 @@ describe('MatChipInput', () => {
|
248 | 252 |
|
249 | 253 | expect(inputNativeElement.getAttribute('aria-describedby')).toBeNull();
|
250 | 254 | }));
|
| 255 | + |
| 256 | + it('should not emit chipEnd if the key is repeated', () => { |
| 257 | + spyOn(testChipInput, 'add'); |
| 258 | + |
| 259 | + chipInputDirective.separatorKeyCodes = [COMMA]; |
| 260 | + fixture.detectChanges(); |
| 261 | + |
| 262 | + const event = createKeyboardEvent('keydown', COMMA); |
| 263 | + Object.defineProperty(event, 'repeat', {get: () => true}); |
| 264 | + dispatchEvent(inputNativeElement, event); |
| 265 | + fixture.detectChanges(); |
| 266 | + |
| 267 | + expect(testChipInput.add).not.toHaveBeenCalled(); |
| 268 | + }); |
251 | 269 | });
|
252 | 270 | });
|
253 | 271 |
|
|
0 commit comments