@ -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, of } from 'rxjs';
|
||||
import {interval, Observable, of} from 'rxjs';
|
||||
import {take, takeLast, takeUntil, takeWhile} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -20,12 +20,16 @@ describe('Observable.take', () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
afterEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; });
|
||||
afterEach(() => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout;
|
||||
});
|
||||
|
||||
it('take func callback should run in the correct zone', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3).pipe(take(1)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(take(1));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -33,7 +37,9 @@ describe('Observable.take', () => {
|
||||
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);
|
||||
@ -45,7 +51,9 @@ describe('Observable.take', () => {
|
||||
it('takeLast func callback should run in the correct zone', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3).pipe(takeLast(1)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(takeLast(1));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -53,7 +61,9 @@ describe('Observable.take', () => {
|
||||
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);
|
||||
@ -65,8 +75,9 @@ describe('Observable.take', () => {
|
||||
xit('takeUntil 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(takeUntil(interval(25))); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return interval(10).pipe(takeUntil(interval(25)));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -74,7 +85,9 @@ describe('Observable.take', () => {
|
||||
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);
|
||||
@ -88,7 +101,9 @@ describe('Observable.take', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const takeZone1: Zone = Zone.current.fork({name: 'Take Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return interval(10); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return interval(10);
|
||||
});
|
||||
|
||||
observable1 = takeZone1.run(() => {
|
||||
return observable1.pipe(takeWhile((val: any) => {
|
||||
@ -103,7 +118,9 @@ describe('Observable.take', () => {
|
||||
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