|
1 | 1 | import {Directionality} from '@angular/cdk/bidi';
|
2 | 2 | import {BACKSPACE, DELETE, SPACE} from '@angular/cdk/keycodes';
|
3 |
| -import {createKeyboardEvent} from '@angular/cdk/testing'; |
| 3 | +import {createKeyboardEvent, dispatchFakeEvent} from '@angular/cdk/testing'; |
4 | 4 | import {Component, DebugElement} from '@angular/core';
|
5 | 5 | import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
6 | 6 | import {By} from '@angular/platform-browser';
|
@@ -132,6 +132,24 @@ describe('Chips', () => {
|
132 | 132 |
|
133 | 133 | expect(testComponent.chipRemove).toHaveBeenCalledWith({chip: chipInstance});
|
134 | 134 | });
|
| 135 | + |
| 136 | + it('should not prevent the default click action', () => { |
| 137 | + const event = dispatchFakeEvent(chipNativeElement, 'click'); |
| 138 | + fixture.detectChanges(); |
| 139 | + |
| 140 | + expect(event.defaultPrevented).toBe(false); |
| 141 | + }); |
| 142 | + |
| 143 | + it('should prevent the default click action when the chip is disabled', () => { |
| 144 | + chipInstance.disabled = true; |
| 145 | + fixture.detectChanges(); |
| 146 | + |
| 147 | + const event = dispatchFakeEvent(chipNativeElement, 'click'); |
| 148 | + fixture.detectChanges(); |
| 149 | + |
| 150 | + expect(event.defaultPrevented).toBe(true); |
| 151 | + }); |
| 152 | + |
135 | 153 | });
|
136 | 154 |
|
137 | 155 | describe('keyboard behavior', () => {
|
|
0 commit comments