@ -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, from} from 'rxjs';
|
||||
import {from, Observable} from 'rxjs';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
|
||||
@ -15,10 +15,14 @@ describe('Observable.from', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('from array should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return from([1, 2]); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return from([1, 2]);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -26,7 +30,9 @@ describe('Observable.from', () => {
|
||||
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');
|
||||
@ -37,7 +43,9 @@ describe('Observable.from', () => {
|
||||
});
|
||||
|
||||
it('from array like object should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return from('foo'); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return from('foo');
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -45,7 +53,9 @@ describe('Observable.from', () => {
|
||||
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');
|
||||
@ -58,8 +68,11 @@ describe('Observable.from', () => {
|
||||
it('from promise object 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 from(new Promise((resolve, reject) => { resolve(1); })); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return from(new Promise((resolve, reject) => {
|
||||
resolve(1);
|
||||
}));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -67,7 +80,9 @@ describe('Observable.from', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(result);
|
||||
},
|
||||
(error: any) => { fail('should not call error' + error); },
|
||||
(error: any) => {
|
||||
fail('should not call error' + error);
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('completed');
|
||||
|
Reference in New Issue
Block a user