|
1 |
| -import {TestBed, ComponentFixture, fakeAsync, tick, inject} from '@angular/core/testing'; |
2 |
| -import {Component, ViewChild} from '@angular/core'; |
3 | 1 | import {Platform} from '@angular/cdk/platform';
|
4 |
| -import {dispatchMouseEvent, dispatchTouchEvent} from '@angular/cdk/testing'; |
5 |
| -import {defaultRippleAnimationConfig, RippleAnimationConfig} from './ripple-renderer'; |
6 | 2 | import {
|
7 |
| - MatRipple, MatRippleModule, MAT_RIPPLE_GLOBAL_OPTIONS, RippleState, RippleGlobalOptions |
8 |
| -} from './index'; |
| 3 | + createMouseEvent, |
| 4 | + dispatchEvent, |
| 5 | + dispatchMouseEvent, |
| 6 | + dispatchTouchEvent, |
| 7 | +} from '@angular/cdk/testing'; |
| 8 | +import {Component, ViewChild} from '@angular/core'; |
| 9 | +import {ComponentFixture, fakeAsync, inject, TestBed, tick} from '@angular/core/testing'; |
9 | 10 | import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
| 11 | +import { |
| 12 | + MAT_RIPPLE_GLOBAL_OPTIONS, |
| 13 | + MatRipple, |
| 14 | + MatRippleModule, |
| 15 | + RippleGlobalOptions, |
| 16 | + RippleState, |
| 17 | +} from './index'; |
| 18 | +import {defaultRippleAnimationConfig, RippleAnimationConfig} from './ripple-renderer'; |
10 | 19 |
|
11 | 20 | /** Shorthands for the enter and exit duration of ripples. */
|
12 | 21 | const {enterDuration, exitDuration} = defaultRippleAnimationConfig;
|
@@ -135,6 +144,15 @@ describe('MatRipple', () => {
|
135 | 144 | expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(0);
|
136 | 145 | }));
|
137 | 146 |
|
| 147 | + it('should ignore fake mouse events from screen readers', () => fakeAsync(() => { |
| 148 | + const event = createMouseEvent('mousedown'); |
| 149 | + Object.defineProperty(event, 'buttons', {get: () => 0}); |
| 150 | + |
| 151 | + dispatchEvent(rippleTarget, event); |
| 152 | + tick(enterDuration); |
| 153 | + expect(rippleTarget.querySelector('.mat-ripple-element')).toBeFalsy(); |
| 154 | + })); |
| 155 | + |
138 | 156 | it('removes ripple after timeout', fakeAsync(() => {
|
139 | 157 | dispatchMouseEvent(rippleTarget, 'mousedown');
|
140 | 158 | dispatchMouseEvent(rippleTarget, 'mouseup');
|
|
0 commit comments