@ -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, interval} from 'rxjs';
|
||||
import {interval, Observable} from 'rxjs';
|
||||
import {sample, take, throttle} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -14,13 +14,16 @@ describe('Observable.sample', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('sample func callback should run in the correct zone', asyncTest((done: any) => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 =
|
||||
constructorZone1.run(() => { return interval(10).pipe(sample(interval(15))); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return interval(10).pipe(sample(interval(15)));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber: any = observable1.subscribe(
|
||||
@ -29,7 +32,9 @@ describe('Observable.sample', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
subscriber.complete();
|
||||
},
|
||||
(err: any) => { fail('should not call error'); },
|
||||
(err: any) => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -55,7 +60,9 @@ describe('Observable.sample', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
(err: any) => { fail('should not call error'); },
|
||||
(err: any) => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
Reference in New Issue
Block a user