@ -5,7 +5,7 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {Observable, Subject, of } from 'rxjs';
|
||||
import {Observable, of, Subject} from 'rxjs';
|
||||
import {mapTo, multicast, tap} from 'rxjs/operators';
|
||||
|
||||
|
||||
@ -20,10 +20,14 @@ describe('Observable.multicast', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('multicast func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = doZone1.run(() => {
|
||||
return observable1.pipe(tap((v: any) => {
|
||||
@ -32,7 +36,9 @@ describe('Observable.multicast', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
observable1 = mapZone1.run(() => { return observable1.pipe(mapTo('test')); });
|
||||
observable1 = mapZone1.run(() => {
|
||||
return observable1.pipe(mapTo('test'));
|
||||
});
|
||||
|
||||
const multi: any = multicastZone1.run(() => {
|
||||
return observable1.pipe(multicast(() => {
|
||||
@ -41,9 +47,13 @@ describe('Observable.multicast', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
multi.subscribe((val: any) => { log.push('one' + val); });
|
||||
multi.subscribe((val: any) => {
|
||||
log.push('one' + val);
|
||||
});
|
||||
|
||||
multi.subscribe((val: any) => { log.push('two' + val); });
|
||||
multi.subscribe((val: any) => {
|
||||
log.push('two' + val);
|
||||
});
|
||||
|
||||
multi.connect();
|
||||
|
||||
@ -53,7 +63,9 @@ describe('Observable.multicast', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(result);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
Reference in New Issue
Block a user