|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | import {supportsPassiveEventListeners} from '@angular/cdk/platform';
|
10 |
| -import {Component, ElementRef, ViewChild} from '@angular/core'; |
| 10 | +import {Component, ElementRef, NgZone, ViewChild} from '@angular/core'; |
11 | 11 | import {ComponentFixture, inject, TestBed} from '@angular/core/testing';
|
12 | 12 | import {EMPTY} from 'rxjs';
|
13 | 13 | import {AutofillEvent, AutofillMonitor} from './autofill';
|
@@ -150,6 +150,19 @@ describe('AutofillMonitor', () => {
|
150 | 150 | expect(spy).toHaveBeenCalled();
|
151 | 151 | });
|
152 | 152 |
|
| 153 | + it('should emit on stream inside the NgZone', () => { |
| 154 | + const inputEl = testComponent.input1.nativeElement; |
| 155 | + let animationStartCallback: Function = () => {}; |
| 156 | + inputEl.addEventListener.and.callFake((_, cb) => animationStartCallback = cb); |
| 157 | + const autofillStream = autofillMonitor.monitor(inputEl); |
| 158 | + const spy = jasmine.createSpy('zone spy'); |
| 159 | + |
| 160 | + autofillStream.subscribe(() => spy(NgZone.isInAngularZone())); |
| 161 | + expect(spy).not.toHaveBeenCalled(); |
| 162 | + |
| 163 | + animationStartCallback({animationName: 'cdk-text-field-autofill-start', target: inputEl}); |
| 164 | + expect(spy).toHaveBeenCalledWith(true); |
| 165 | + }); |
153 | 166 | });
|
154 | 167 |
|
155 | 168 | describe('cdkAutofill', () => {
|
|
0 commit comments