@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, fromEvent, fromEventPattern} from 'rxjs';
|
||||
import {fromEvent, fromEventPattern, Observable} from 'rxjs';
|
||||
|
||||
import {isBrowser} from '../../lib/common/utils';
|
||||
import {ifEnvSupports} from '../test-util';
|
||||
@ -24,11 +24,15 @@ describe('Observable.fromEvent', () => {
|
||||
const triggerZone: Zone = Zone.current.fork({name: 'Trigger Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('fromEvent EventTarget func callback should run in the correct zone',
|
||||
ifEnvSupports(isEventTarget, () => {
|
||||
observable1 = constructorZone1.run(() => { return fromEvent(document, 'click'); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return fromEvent(document, 'click');
|
||||
});
|
||||
|
||||
const clickEvent = document.createEvent('Event');
|
||||
clickEvent.initEvent('click', true, true);
|
||||
@ -39,14 +43,18 @@ describe('Observable.fromEvent', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(result);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('completed');
|
||||
});
|
||||
});
|
||||
|
||||
triggerZone.run(() => { document.dispatchEvent(clickEvent); });
|
||||
triggerZone.run(() => {
|
||||
document.dispatchEvent(clickEvent);
|
||||
});
|
||||
|
||||
expect(log).toEqual([clickEvent]);
|
||||
}));
|
||||
@ -79,7 +87,9 @@ describe('Observable.fromEvent', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(result);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('completed');
|
||||
|
Reference in New Issue
Block a user