|
1 | 1 | import {TestBed, ComponentFixture, fakeAsync, tick, inject} from '@angular/core/testing'; |
2 | 2 | import {Component, ViewChild} from '@angular/core'; |
3 | 3 | import {Platform} from '@angular/cdk/platform'; |
4 | | -import {dispatchMouseEvent, dispatchTouchEvent} from '@angular/cdk/testing'; |
| 4 | +import { |
| 5 | + dispatchMouseEvent, |
| 6 | + dispatchTouchEvent, |
| 7 | + createMouseEvent, |
| 8 | + dispatchEvent, |
| 9 | +} from '@angular/cdk/testing'; |
5 | 10 | import {defaultRippleAnimationConfig, RippleAnimationConfig} from './ripple-renderer'; |
6 | 11 | import { |
7 | 12 | MatRipple, MatRippleModule, MAT_RIPPLE_GLOBAL_OPTIONS, RippleState, RippleGlobalOptions |
@@ -135,6 +140,15 @@ describe('MatRipple', () => { |
135 | 140 | expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(0); |
136 | 141 | })); |
137 | 142 |
|
| 143 | + it('should ignore fake mouse events from screen readers', () => fakeAsync(() => { |
| 144 | + const event = createMouseEvent('mousedown'); |
| 145 | + Object.defineProperty(event, 'buttons', {get: () => 0}); |
| 146 | + |
| 147 | + dispatchEvent(rippleTarget, event); |
| 148 | + tick(enterDuration); |
| 149 | + expect(rippleTarget.querySelector('.mat-ripple-element')).toBeFalsy(); |
| 150 | + })); |
| 151 | + |
138 | 152 | it('removes ripple after timeout', fakeAsync(() => { |
139 | 153 | dispatchMouseEvent(rippleTarget, 'mousedown'); |
140 | 154 | dispatchMouseEvent(rippleTarget, 'mouseup'); |
|
0 commit comments