@ -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 {audit, auditTime} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -14,7 +14,9 @@ xdescribe('Observable.audit', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('audit func callback should run in the correct zone', asyncTest((done: any) => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
@ -36,7 +38,9 @@ xdescribe('Observable.audit', () => {
|
||||
subscriber.unsubscribe();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -65,7 +69,9 @@ xdescribe('Observable.audit', () => {
|
||||
subscriber.unsubscribe();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, empty, interval, of } from 'rxjs';
|
||||
import {empty, interval, Observable, of} from 'rxjs';
|
||||
import {buffer, bufferCount, bufferTime, bufferToggle, bufferWhen} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -15,7 +15,9 @@ xdescribe('Observable.buffer', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('buffer func callback should run in the correct zone', asyncTest((done: any) => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
@ -35,7 +37,9 @@ xdescribe('Observable.buffer', () => {
|
||||
subscriber.unsubscribe();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -64,7 +68,9 @@ xdescribe('Observable.buffer', () => {
|
||||
subscriber.unsubscribe();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -93,7 +99,9 @@ xdescribe('Observable.buffer', () => {
|
||||
subscriber.unsubscribe();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -113,7 +121,7 @@ xdescribe('Observable.buffer', () => {
|
||||
const opening = interval(25);
|
||||
const closingSelector = (v: any) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
return v % 2 === 0 ? of (v) : empty();
|
||||
return v % 2 === 0 ? of(v) : empty();
|
||||
};
|
||||
return source.pipe(bufferToggle(opening, closingSelector));
|
||||
});
|
||||
@ -126,7 +134,9 @@ xdescribe('Observable.buffer', () => {
|
||||
log.push(result);
|
||||
subscriber.unsubscribe();
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -159,7 +169,9 @@ xdescribe('Observable.buffer', () => {
|
||||
subscriber.unsubscribe();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -5,21 +5,23 @@
|
||||
* 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, of } from 'rxjs';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {catchError, map, retry} from 'rxjs/operators';
|
||||
|
||||
describe('Observable.catch', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('catch 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(() => {
|
||||
const error = new Error('test');
|
||||
const source = of (1, 2, 3).pipe(map((n: number) => {
|
||||
const source = of(1, 2, 3).pipe(map((n: number) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
if (n === 2) {
|
||||
throw error;
|
||||
@ -28,7 +30,7 @@ describe('Observable.catch', () => {
|
||||
}));
|
||||
return source.pipe(catchError((err: any) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
return of ('error1', 'error2');
|
||||
return of('error1', 'error2');
|
||||
}));
|
||||
});
|
||||
|
||||
@ -38,7 +40,9 @@ describe('Observable.catch', () => {
|
||||
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);
|
||||
@ -52,7 +56,7 @@ describe('Observable.catch', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of (1, 2, 3).pipe(
|
||||
return of(1, 2, 3).pipe(
|
||||
map((n: number) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
if (n === 2) {
|
||||
|
@ -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, interval, of } from 'rxjs';
|
||||
import {from, interval, Observable, of} from 'rxjs';
|
||||
import {elementAt, every, filter, find, findIndex, first, flatMap, groupBy, ignoreElements, isEmpty, last, map, mapTo, max, min, reduce, repeat, scan, single, skip, skipUntil, skipWhile, startWith} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest, isPhantomJS} from '../test-util';
|
||||
@ -20,13 +20,17 @@ describe('Observable.collection', () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
afterEach(function() { jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; });
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout;
|
||||
});
|
||||
|
||||
it('elementAt 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'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3).pipe(elementAt(1)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(elementAt(1));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -34,7 +38,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -48,7 +54,9 @@ describe('Observable.collection', () => {
|
||||
const everyZone1: Zone = Zone.current.fork({name: 'Every Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = everyZone1.run(() => {
|
||||
return observable1.pipe(every((v: any) => {
|
||||
@ -63,7 +71,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -77,7 +87,9 @@ describe('Observable.collection', () => {
|
||||
const filterZone1: Zone = Zone.current.fork({name: 'Filter Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = filterZone1.run(() => {
|
||||
return observable1.pipe(filter((v: any) => {
|
||||
@ -92,7 +104,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -106,7 +120,9 @@ describe('Observable.collection', () => {
|
||||
const findZone1: Zone = Zone.current.fork({name: 'Find Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = findZone1.run(() => {
|
||||
return observable1.pipe(find((v: any) => {
|
||||
@ -121,7 +137,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -135,7 +153,9 @@ describe('Observable.collection', () => {
|
||||
const findZone1: Zone = Zone.current.fork({name: 'Find Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = findZone1.run(() => {
|
||||
return observable1.pipe(findIndex((v: any) => {
|
||||
@ -150,7 +170,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -164,7 +186,9 @@ describe('Observable.collection', () => {
|
||||
const firstZone1: Zone = Zone.current.fork({name: 'First Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = firstZone1.run(() => {
|
||||
return observable1.pipe(first((v: any) => {
|
||||
@ -179,7 +203,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -221,7 +247,9 @@ describe('Observable.collection', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
(err: any) => { fail('should not call error' + err); },
|
||||
(err: any) => {
|
||||
fail('should not call error' + err);
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -238,12 +266,18 @@ describe('Observable.collection', () => {
|
||||
const ignoreZone1: Zone = Zone.current.fork({name: 'Ignore Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3).pipe(ignoreElements()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(ignoreElements());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
(result: any) => { fail('should not call next'); },
|
||||
(err: any) => { fail('should not call error'); },
|
||||
(result: any) => {
|
||||
fail('should not call next');
|
||||
},
|
||||
(err: any) => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -257,7 +291,9 @@ describe('Observable.collection', () => {
|
||||
const isEmptyZone1: Zone = Zone.current.fork({name: 'IsEmpty Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3).pipe(isEmpty()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(isEmpty());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -265,7 +301,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -279,7 +317,9 @@ describe('Observable.collection', () => {
|
||||
const lastZone1: Zone = Zone.current.fork({name: 'Last Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3).pipe(last()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(last());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -287,7 +327,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -301,7 +343,9 @@ describe('Observable.collection', () => {
|
||||
const mapZone1: Zone = Zone.current.fork({name: 'Map Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = mapZone1.run(() => {
|
||||
return observable1.pipe(map((v: any) => {
|
||||
@ -316,7 +360,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -330,9 +376,13 @@ describe('Observable.collection', () => {
|
||||
const mapToZone1: Zone = Zone.current.fork({name: 'MapTo Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = mapToZone1.run(() => { return observable1.pipe(mapTo('a')); });
|
||||
observable1 = mapToZone1.run(() => {
|
||||
return observable1.pipe(mapTo('a'));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -340,7 +390,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -353,7 +405,9 @@ describe('Observable.collection', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (4, 2, 3).pipe(max()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(4, 2, 3).pipe(max());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -361,7 +415,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -375,7 +431,9 @@ describe('Observable.collection', () => {
|
||||
const maxZone1: Zone = Zone.current.fork({name: 'Max Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (4, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(4, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = maxZone1.run(() => {
|
||||
return observable1.pipe(max((x: number, y: number) => {
|
||||
@ -390,7 +448,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -403,7 +463,9 @@ describe('Observable.collection', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (4, 2, 3).pipe(min()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(4, 2, 3).pipe(min());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -411,7 +473,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -425,7 +489,9 @@ describe('Observable.collection', () => {
|
||||
const minZone1: Zone = Zone.current.fork({name: 'Min Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (4, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(4, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = minZone1.run(() => {
|
||||
return observable1.pipe(max((x: number, y: number) => {
|
||||
@ -440,7 +506,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -453,7 +521,9 @@ describe('Observable.collection', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const reduceZone1: Zone = Zone.current.fork({name: 'Min Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (4, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(4, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = reduceZone1.run(() => {
|
||||
return observable1.pipe(reduce((acc: number, one: number) => {
|
||||
@ -468,7 +538,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -481,7 +553,9 @@ describe('Observable.collection', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const scanZone1: Zone = Zone.current.fork({name: 'Min Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (4, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(4, 2, 3);
|
||||
});
|
||||
|
||||
observable1 = scanZone1.run(() => {
|
||||
return observable1.pipe(scan((acc: number, one: number) => {
|
||||
@ -496,7 +570,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -508,7 +584,9 @@ describe('Observable.collection', () => {
|
||||
it('repeat 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).pipe(repeat(2)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1).pipe(repeat(2));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -516,7 +594,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -529,7 +609,9 @@ describe('Observable.collection', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const singleZone1: Zone = Zone.current.fork({name: 'Single Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3, 4, 5); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3, 4, 5);
|
||||
});
|
||||
|
||||
observable1 = singleZone1.run(() => {
|
||||
return observable1.pipe(single((val: any) => {
|
||||
@ -544,7 +626,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -556,7 +640,9 @@ describe('Observable.collection', () => {
|
||||
it('skip 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, 4, 5).pipe(skip(3)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3, 4, 5).pipe(skip(3));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -564,7 +650,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
@ -576,8 +664,9 @@ describe('Observable.collection', () => {
|
||||
xit('skipUntil 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(skipUntil(interval(25))); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return interval(10).pipe(skipUntil(interval(25)));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber = observable1.subscribe(
|
||||
@ -586,7 +675,9 @@ describe('Observable.collection', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
subscriber.unsubscribe();
|
||||
},
|
||||
(err: any) => { fail('should not call error'); },
|
||||
(err: any) => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -600,7 +691,9 @@ describe('Observable.collection', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const skipZone1: Zone = Zone.current.fork({name: 'Skip Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return interval(10); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return interval(10);
|
||||
});
|
||||
|
||||
observable1 = skipZone1.run(() => {
|
||||
return observable1.pipe(skipWhile((val: any) => {
|
||||
@ -617,14 +710,18 @@ describe('Observable.collection', () => {
|
||||
expect(result).toEqual(2);
|
||||
done();
|
||||
},
|
||||
(err: any) => { fail('should not call error'); });
|
||||
(err: any) => {
|
||||
fail('should not call error');
|
||||
});
|
||||
});
|
||||
}, Zone.root));
|
||||
|
||||
it('startWith 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).pipe(startWith(3)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2).pipe(startWith(3));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber = observable1.subscribe(
|
||||
@ -632,7 +729,9 @@ describe('Observable.collection', () => {
|
||||
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);
|
||||
|
@ -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, combineLatest, of } from 'rxjs';
|
||||
import {combineLatest, Observable, of} from 'rxjs';
|
||||
import {combineAll, map} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -14,16 +14,18 @@ describe('Observable.combine', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('combineAll 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(() => {
|
||||
const source = of (1, 2);
|
||||
const source = of(1, 2);
|
||||
const highOrder = source.pipe(map((src: any) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
return of (src);
|
||||
return of(src);
|
||||
}));
|
||||
return highOrder.pipe(combineAll());
|
||||
});
|
||||
@ -34,7 +36,9 @@ describe('Observable.combine', () => {
|
||||
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);
|
||||
@ -49,10 +53,10 @@ describe('Observable.combine', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => {
|
||||
const source = of (1, 2, 3);
|
||||
const source = of(1, 2, 3);
|
||||
const highOrder = source.pipe(map((src: any) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
return of (src);
|
||||
return of(src);
|
||||
}));
|
||||
return highOrder.pipe(combineAll((x: any, y: any) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
@ -66,7 +70,9 @@ describe('Observable.combine', () => {
|
||||
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);
|
||||
@ -80,8 +86,8 @@ describe('Observable.combine', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => {
|
||||
const source = of (1, 2, 3);
|
||||
const input = of (4, 5, 6);
|
||||
const source = of(1, 2, 3);
|
||||
const input = of(4, 5, 6);
|
||||
return combineLatest(source, input);
|
||||
});
|
||||
|
||||
@ -91,7 +97,9 @@ describe('Observable.combine', () => {
|
||||
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);
|
||||
@ -105,9 +113,11 @@ describe('Observable.combine', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => {
|
||||
const source = of (1, 2, 3);
|
||||
const input = of (4, 5, 6);
|
||||
return combineLatest(source, input, (x: number, y: number) => { return x + y; });
|
||||
const source = of(1, 2, 3);
|
||||
const input = of(4, 5, 6);
|
||||
return combineLatest(source, input, (x: number, y: number) => {
|
||||
return x + y;
|
||||
});
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
@ -116,7 +126,9 @@ describe('Observable.combine', () => {
|
||||
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);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, asapScheduler, concat, of , range} from 'rxjs';
|
||||
import {asapScheduler, concat, Observable, of, range} from 'rxjs';
|
||||
import {concatAll, concatMap, concatMapTo, map} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -22,7 +22,9 @@ describe('Observable instance method concat', () => {
|
||||
|
||||
let concatObservable: any;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('concat func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => {
|
||||
@ -34,9 +36,13 @@ describe('Observable instance method concat', () => {
|
||||
});
|
||||
});
|
||||
|
||||
observable2 = constructorZone2.run(() => { return range(3, 4); });
|
||||
observable2 = constructorZone2.run(() => {
|
||||
return range(3, 4);
|
||||
});
|
||||
|
||||
constructorZone3.run(() => { concatObservable = concat(observable1, observable2); });
|
||||
constructorZone3.run(() => {
|
||||
concatObservable = concat(observable1, observable2);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
concatObservable.subscribe((concat: any) => {
|
||||
@ -54,12 +60,17 @@ describe('Observable instance method concat', () => {
|
||||
const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'});
|
||||
const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2);
|
||||
});
|
||||
|
||||
observable2 = constructorZone2.run(() => { return range(3, 4); });
|
||||
observable2 = constructorZone2.run(() => {
|
||||
return range(3, 4);
|
||||
});
|
||||
|
||||
constructorZone3.run(
|
||||
() => { concatObservable = concat(observable1, observable2, asapScheduler); });
|
||||
constructorZone3.run(() => {
|
||||
concatObservable = concat(observable1, observable2, asapScheduler);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
concatObservable.subscribe(
|
||||
@ -67,7 +78,9 @@ describe('Observable instance method concat', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(concat);
|
||||
},
|
||||
(error: any) => { fail('subscribe failed' + error); },
|
||||
(error: any) => {
|
||||
fail('subscribe failed' + error);
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
expect(log).toEqual([1, 2, 3, 4, 5, 6]);
|
||||
@ -82,12 +95,14 @@ describe('Observable instance method concat', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (0, 1, 2); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(0, 1, 2);
|
||||
});
|
||||
|
||||
constructorZone2.run(() => {
|
||||
const highOrder = observable1.pipe(map((v: any) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone2.name);
|
||||
return of (v + 1);
|
||||
return of(v + 1);
|
||||
}));
|
||||
concatObservable = highOrder.pipe(concatAll());
|
||||
});
|
||||
@ -98,7 +113,9 @@ describe('Observable instance method concat', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(concat);
|
||||
},
|
||||
(error: any) => { fail('subscribe failed' + error); },
|
||||
(error: any) => {
|
||||
fail('subscribe failed' + error);
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
expect(log).toEqual([1, 2, 3]);
|
||||
@ -125,7 +142,7 @@ describe('Observable instance method concat', () => {
|
||||
constructorZone2.run(() => {
|
||||
concatObservable = observable1.pipe(concatMap((v: any) => {
|
||||
expect(Zone.current.name).toEqual(constructorZone2.name);
|
||||
return of (0, 1);
|
||||
return of(0, 1);
|
||||
}));
|
||||
});
|
||||
|
||||
@ -135,7 +152,9 @@ describe('Observable instance method concat', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(concat);
|
||||
},
|
||||
(error: any) => { fail('subscribe failed' + error); },
|
||||
(error: any) => {
|
||||
fail('subscribe failed' + error);
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
expect(log).toEqual([0, 1, 0, 1, 0, 1, 0, 1]);
|
||||
@ -159,7 +178,9 @@ describe('Observable instance method concat', () => {
|
||||
});
|
||||
});
|
||||
|
||||
constructorZone2.run(() => { concatObservable = observable1.pipe(concatMapTo(of (0, 1))); });
|
||||
constructorZone2.run(() => {
|
||||
concatObservable = observable1.pipe(concatMapTo(of(0, 1)));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
concatObservable.subscribe(
|
||||
@ -167,7 +188,9 @@ describe('Observable instance method concat', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(concat);
|
||||
},
|
||||
(error: any) => { fail('subscribe failed' + error); },
|
||||
(error: any) => {
|
||||
fail('subscribe failed' + error);
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
expect(log).toEqual([0, 1, 0, 1, 0, 1, 0, 1]);
|
||||
|
@ -14,7 +14,9 @@ describe('Observable.count', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('count func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => {
|
||||
@ -30,7 +32,9 @@ describe('Observable.count', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -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, of , timer} from 'rxjs';
|
||||
import {Observable, of, timer} from 'rxjs';
|
||||
import {debounce, debounceTime} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -14,13 +14,15 @@ describe('Observable.debounce', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('debounce 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 of (1, 2, 3).pipe(debounce(() => {
|
||||
return of(1, 2, 3).pipe(debounce(() => {
|
||||
expect(Zone.current.name).toEqual(constructorZone1.name);
|
||||
return timer(100);
|
||||
}));
|
||||
@ -32,7 +34,9 @@ describe('Observable.debounce', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -45,7 +49,9 @@ describe('Observable.debounce', () => {
|
||||
it('debounceTime 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 of (1, 2, 3).pipe(debounceTime(100)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(debounceTime(100));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber = observable1.subscribe(
|
||||
@ -53,7 +59,9 @@ describe('Observable.debounce', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -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, of } from 'rxjs';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {defaultIfEmpty} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -14,13 +14,16 @@ describe('Observable.defaultIfEmpty', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('defaultIfEmpty 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 of ().pipe(defaultIfEmpty('empty' as any)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of().pipe(defaultIfEmpty('empty' as any));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -28,7 +31,9 @@ describe('Observable.defaultIfEmpty', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, of , timer} from 'rxjs';
|
||||
import {Observable, of, timer} from 'rxjs';
|
||||
import {delay, delayWhen} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -15,12 +15,16 @@ describe('Observable.delay', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('delay 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 of (1, 2, 3).pipe(delay(100)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(delay(100));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -28,7 +32,9 @@ describe('Observable.delay', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -41,8 +47,11 @@ describe('Observable.delay', () => {
|
||||
it('delayWhen 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 of (1, 2, 3).pipe(delayWhen((v: any) => { return timer(v * 10); })); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(delayWhen((v: any) => {
|
||||
return timer(v * 10);
|
||||
}));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -50,7 +59,9 @@ describe('Observable.delay', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -6,21 +6,24 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, of } from 'rxjs';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {distinct, distinctUntilChanged, distinctUntilKeyChanged} from 'rxjs/operators';
|
||||
|
||||
describe('Observable.distinct', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('distinct 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'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(
|
||||
() => { return of (1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).pipe(distinct()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).pipe(distinct());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -28,7 +31,9 @@ describe('Observable.distinct', () => {
|
||||
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);
|
||||
@ -41,8 +46,9 @@ describe('Observable.distinct', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(
|
||||
() => { return of (1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4).pipe(distinctUntilChanged()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4).pipe(distinctUntilChanged());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -50,7 +56,9 @@ describe('Observable.distinct', () => {
|
||||
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);
|
||||
@ -64,8 +72,8 @@ describe('Observable.distinct', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of ({age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'},
|
||||
{age: 6, name: 'Foo'})
|
||||
return of({age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'},
|
||||
{age: 6, name: 'Foo'})
|
||||
.pipe(distinctUntilKeyChanged('name'));
|
||||
});
|
||||
|
||||
@ -75,7 +83,9 @@ describe('Observable.distinct', () => {
|
||||
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);
|
||||
|
@ -5,21 +5,25 @@
|
||||
* 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, of } from 'rxjs';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {tap} from 'rxjs/operators';
|
||||
|
||||
describe('Observable.tap', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('do func callback should run in the correct zone', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const doZone1: Zone = Zone.current.fork({name: 'Do Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1);
|
||||
});
|
||||
|
||||
observable1 = doZone1.run(() => {
|
||||
return observable1.pipe(tap((v: any) => {
|
||||
@ -34,7 +38,9 @@ describe('Observable.tap', () => {
|
||||
log.push('result' + 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);
|
||||
|
@ -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, observable, of } from 'rxjs';
|
||||
import {Observable, observable, of} from 'rxjs';
|
||||
import {pairwise, partition, pluck} from 'rxjs/operators';
|
||||
|
||||
import {ifEnvSupports} from '../test-util';
|
||||
@ -18,10 +18,14 @@ describe('Observable.map', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('pairwise func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3).pipe(pairwise()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3).pipe(pairwise());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -29,7 +33,9 @@ describe('Observable.map', () => {
|
||||
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');
|
||||
@ -41,7 +47,9 @@ describe('Observable.map', () => {
|
||||
|
||||
it('partition func callback should run in the correct zone', () => {
|
||||
const partitionZone = Zone.current.fork({name: 'Partition Zone1'});
|
||||
const observable1: any = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
const observable1: any = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
const part: any = partitionZone.run(() => {
|
||||
return observable1.pipe(partition((val: any) => {
|
||||
@ -56,7 +64,9 @@ describe('Observable.map', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('first' + result);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('completed');
|
||||
@ -67,7 +77,9 @@ describe('Observable.map', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('second' + result);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('completed');
|
||||
@ -78,8 +90,9 @@ describe('Observable.map', () => {
|
||||
});
|
||||
|
||||
it('pluck func callback should run in the correct zone', () => {
|
||||
observable1 =
|
||||
constructorZone1.run(() => { return of ({a: 1, b: 2}, {a: 3, b: 4}).pipe(pluck('a')); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of({a: 1, b: 2}, {a: 3, b: 4}).pipe(pluck('a'));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -87,7 +100,9 @@ describe('Observable.map', () => {
|
||||
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');
|
||||
|
@ -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, merge, of , range} from 'rxjs';
|
||||
import {interval, merge, Observable, of, range} from 'rxjs';
|
||||
import {expand, map, mergeAll, mergeMap, mergeMapTo, switchAll, switchMap, switchMapTo, take} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest, ifEnvSupports} from '../test-util';
|
||||
@ -22,20 +22,24 @@ describe('Observable.merge', () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
afterEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; });
|
||||
afterEach(() => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout;
|
||||
});
|
||||
|
||||
it('expand func callback should run in the correct zone', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const expandZone1: Zone = Zone.current.fork({name: 'Expand Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (2); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(2);
|
||||
});
|
||||
|
||||
observable1 = expandZone1.run(() => {
|
||||
return observable1.pipe(
|
||||
expand((val: any) => {
|
||||
expect(Zone.current.name).toEqual(expandZone1.name);
|
||||
return of (1 + val);
|
||||
return of(1 + val);
|
||||
}),
|
||||
take(2));
|
||||
});
|
||||
@ -46,7 +50,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
@ -59,8 +65,9 @@ describe('Observable.merge', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(
|
||||
() => { return merge(interval(10).pipe(take(2)), interval(15).pipe(take(1))); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return merge(interval(10).pipe(take(2)), interval(15).pipe(take(1)));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -68,7 +75,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
@ -82,8 +91,13 @@ describe('Observable.merge', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(
|
||||
() => { return of (1, 2).pipe(map((v: any) => { return of (v + 1); }), mergeAll()); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2).pipe(
|
||||
map((v: any) => {
|
||||
return of(v + 1);
|
||||
}),
|
||||
mergeAll());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -91,7 +105,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
@ -105,8 +121,11 @@ describe('Observable.merge', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(
|
||||
() => { return of (1, 2).pipe(mergeMap((v: any) => { return of (v + 1); })); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2).pipe(mergeMap((v: any) => {
|
||||
return of(v + 1);
|
||||
}));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -114,7 +133,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
@ -127,7 +148,9 @@ describe('Observable.merge', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2).pipe(mergeMapTo(of (10))); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2).pipe(mergeMapTo(of(10)));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -135,7 +158,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
@ -148,7 +173,11 @@ describe('Observable.merge', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return range(0, 3).pipe(map(function(x: any) { return range(x, 3); }), switchAll());
|
||||
return range(0, 3).pipe(
|
||||
map(function(x: any) {
|
||||
return range(x, 3);
|
||||
}),
|
||||
switchAll());
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
@ -157,7 +186,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
@ -169,8 +200,11 @@ describe('Observable.merge', () => {
|
||||
it('switchMap 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 range(0, 3).pipe(switchMap(function(x: any) { return range(x, 3); })); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return range(0, 3).pipe(switchMap(function(x: any) {
|
||||
return range(x, 3);
|
||||
}));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -178,7 +212,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
@ -190,7 +226,9 @@ describe('Observable.merge', () => {
|
||||
it('switchMapTo 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 range(0, 3).pipe(switchMapTo('a')); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return range(0, 3).pipe(switchMapTo('a'));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -198,7 +236,9 @@ describe('Observable.merge', () => {
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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 {Notification, Observable, of } from 'rxjs';
|
||||
import {Notification, Observable, of} from 'rxjs';
|
||||
import {dematerialize} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest, ifEnvSupports} from '../test-util';
|
||||
@ -20,7 +20,9 @@ describe('Observable.notification', ifEnvSupports(supportNotification, () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('notification func callback should run in the correct zone', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
@ -30,7 +32,7 @@ describe('Observable.notification', ifEnvSupports(supportNotification, () => {
|
||||
const notifA = new Notification('N' as any, 'A');
|
||||
const notifB = new Notification('N' as any, 'B');
|
||||
const notifE = new Notification('E' as any, void 0, error);
|
||||
const materialized = of (notifA, notifB, notifE as any);
|
||||
const materialized = of(notifA, notifB, notifE as any);
|
||||
return materialized.pipe(dematerialize());
|
||||
});
|
||||
|
||||
|
@ -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, race} from 'rxjs';
|
||||
import {interval, Observable, race} from 'rxjs';
|
||||
import {mapTo} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -14,13 +14,16 @@ describe('Observable.race', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('race 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 race(interval(10).pipe(mapTo('a')), interval(15).pipe(mapTo('b'))); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return race(interval(10).pipe(mapTo('a')), interval(15).pipe(mapTo('b')));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber: any = observable1.subscribe(
|
||||
@ -29,7 +32,9 @@ describe('Observable.race', () => {
|
||||
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);
|
||||
|
@ -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, of , timer} from 'rxjs';
|
||||
import {Observable, of, timer} from 'rxjs';
|
||||
import {delayWhen, map, retryWhen} from 'rxjs/operators';
|
||||
|
||||
describe('Observable.retryWhen', () => {
|
||||
@ -18,14 +18,16 @@ describe('Observable.retryWhen', () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
afterEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; });
|
||||
afterEach(() => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout;
|
||||
});
|
||||
|
||||
it('retryWhen func callback should run in the correct zone', (done: DoneFn) => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let isErrorHandled = false;
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of (1, 2, 3).pipe(
|
||||
return of(1, 2, 3).pipe(
|
||||
map(v => {
|
||||
if (v > 2 && !isErrorHandled) {
|
||||
isErrorHandled = true;
|
||||
@ -42,7 +44,9 @@ describe('Observable.retryWhen', () => {
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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, of } from 'rxjs';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {timeout} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest, isPhantomJS} from '../test-util';
|
||||
@ -14,7 +14,9 @@ describe('Observable.timeout', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('timeout func callback should run in the correct zone', asyncTest((done: any) => {
|
||||
if (isPhantomJS()) {
|
||||
@ -23,7 +25,9 @@ describe('Observable.timeout', () => {
|
||||
}
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
observable1 = constructorZone1.run(() => { return of (1).pipe(timeout(10)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1).pipe(timeout(10));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -31,7 +35,9 @@ describe('Observable.timeout', () => {
|
||||
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);
|
||||
@ -44,7 +50,9 @@ describe('Observable.timeout', () => {
|
||||
it('promise 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'});
|
||||
const promise: any = constructorZone1.run(() => { return of (1).toPromise(); });
|
||||
const promise: any = constructorZone1.run(() => {
|
||||
return of(1).toPromise();
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
promise.then(
|
||||
@ -53,7 +61,9 @@ describe('Observable.timeout', () => {
|
||||
expect(result).toEqual(1);
|
||||
done();
|
||||
},
|
||||
(err: any) => { fail('should not call error'); });
|
||||
(err: any) => {
|
||||
fail('should not call error');
|
||||
});
|
||||
});
|
||||
}, Zone.root));
|
||||
});
|
||||
|
@ -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, timer} from 'rxjs';
|
||||
import {interval, Observable, timer} from 'rxjs';
|
||||
import {mergeAll, take, window, windowCount, windowToggle, windowWhen} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -17,7 +17,9 @@ xdescribe('Observable.window', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('window func callback should run in the correct zone', asyncTest((done: any) => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
@ -35,7 +37,9 @@ xdescribe('Observable.window', () => {
|
||||
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);
|
||||
@ -61,7 +65,9 @@ xdescribe('Observable.window', () => {
|
||||
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);
|
||||
@ -76,7 +82,9 @@ xdescribe('Observable.window', () => {
|
||||
const windowZone1: Zone = Zone.current.fork({name: 'Window Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return timer(0, 10).pipe(take(10)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return timer(0, 10).pipe(take(10));
|
||||
});
|
||||
|
||||
windowZone1.run(() => {
|
||||
return observable1.pipe(windowToggle(interval(30), (val: any) => {
|
||||
@ -91,7 +99,9 @@ xdescribe('Observable.window', () => {
|
||||
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);
|
||||
@ -106,7 +116,9 @@ xdescribe('Observable.window', () => {
|
||||
const windowZone1: Zone = Zone.current.fork({name: 'Window Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return timer(0, 10).pipe(take(10)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return timer(0, 10).pipe(take(10));
|
||||
});
|
||||
|
||||
windowZone1.run(() => {
|
||||
return observable1.pipe(
|
||||
@ -123,7 +135,9 @@ xdescribe('Observable.window', () => {
|
||||
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);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {asapScheduler, of } from 'rxjs';
|
||||
import {asapScheduler, of} from 'rxjs';
|
||||
import {map, observeOn} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -16,16 +16,23 @@ describe('Scheduler.asap', () => {
|
||||
let errorCallback: Function;
|
||||
const constructorZone: Zone = Zone.root.fork({name: 'Constructor Zone'});
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('scheduler asap should run in correct zone', asyncTest((done: any) => {
|
||||
let observable: any;
|
||||
constructorZone.run(() => { observable = of (1, 2, 3).pipe(observeOn(asapScheduler)); });
|
||||
constructorZone.run(() => {
|
||||
observable = of(1, 2, 3).pipe(observeOn(asapScheduler));
|
||||
});
|
||||
|
||||
const zone = Zone.current.fork({name: 'subscribeZone'});
|
||||
|
||||
zone.run(() => {
|
||||
observable.pipe(map((value: number) => { return value; }))
|
||||
observable
|
||||
.pipe(map((value: number) => {
|
||||
return value;
|
||||
}))
|
||||
.subscribe(
|
||||
(value: number) => {
|
||||
expect(Zone.current.name).toEqual(zone.name);
|
||||
@ -33,13 +40,17 @@ describe('Scheduler.asap', () => {
|
||||
setTimeout(done);
|
||||
}
|
||||
},
|
||||
(err: any) => { fail('should not be here'); });
|
||||
(err: any) => {
|
||||
fail('should not be here');
|
||||
});
|
||||
});
|
||||
}, Zone.root));
|
||||
|
||||
it('scheduler asap error should run in correct zone', asyncTest((done: any) => {
|
||||
let observable: any;
|
||||
constructorZone.run(() => { observable = of (1, 2, 3).pipe(observeOn(asapScheduler)); });
|
||||
constructorZone.run(() => {
|
||||
observable = of(1, 2, 3).pipe(observeOn(asapScheduler));
|
||||
});
|
||||
|
||||
Zone.root.run(() => {
|
||||
observable
|
||||
|
@ -18,7 +18,9 @@ describe('Observable.bindCallback', () => {
|
||||
let boundFunc: any;
|
||||
let observable: any;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('bindCallback func callback should run in the correct zone', () => {
|
||||
constructorZone.run(() => {
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, asapScheduler, bindCallback, bindNodeCallback} from 'rxjs';
|
||||
import {asapScheduler, bindCallback, bindNodeCallback, Observable} from 'rxjs';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
|
||||
@ -18,7 +18,9 @@ describe('Observable.bindNodeCallback', () => {
|
||||
let boundFunc: any;
|
||||
let observable: any;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('bindNodeCallback func callback should run in the correct zone', () => {
|
||||
constructorZone.run(() => {
|
||||
@ -100,7 +102,9 @@ describe('Observable.bindNodeCallback', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push('next' + arg);
|
||||
},
|
||||
(error: any) => { log.push('error' + error); });
|
||||
(error: any) => {
|
||||
log.push('error' + error);
|
||||
});
|
||||
});
|
||||
|
||||
expect(log).toEqual(['nexttest,']);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, combineLatest} from 'rxjs';
|
||||
import {combineLatest, Observable} from 'rxjs';
|
||||
|
||||
describe('Observable.combineLatest', () => {
|
||||
let log: any[];
|
||||
@ -21,7 +21,9 @@ describe('Observable.combineLatest', () => {
|
||||
|
||||
let combinedObservable: any;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('combineLatest func should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => new Observable((_subscriber) => {
|
||||
@ -35,7 +37,9 @@ describe('Observable.combineLatest', () => {
|
||||
log.push('setup2');
|
||||
}));
|
||||
|
||||
constructorZone3.run(() => { combinedObservable = combineLatest(observable1, observable2); });
|
||||
constructorZone3.run(() => {
|
||||
combinedObservable = combineLatest(observable1, observable2);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
combinedObservable.subscribe((combined: any) => {
|
||||
|
@ -157,7 +157,9 @@ describe('Zone interaction', () => {
|
||||
};
|
||||
}));
|
||||
|
||||
observable.subscribe(() => { log.push('next'); });
|
||||
observable.subscribe(() => {
|
||||
log.push('next');
|
||||
});
|
||||
|
||||
expect(log).toEqual(['next', 'cleanup']);
|
||||
});
|
||||
@ -170,7 +172,9 @@ describe('Zone interaction', () => {
|
||||
|
||||
let subject: any;
|
||||
|
||||
constructorZone.run(() => { subject = new Subject(); });
|
||||
constructorZone.run(() => {
|
||||
subject = new Subject();
|
||||
});
|
||||
|
||||
let subscription1: any;
|
||||
let subscription2: any;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, asapScheduler, concat, range} from 'rxjs';
|
||||
import {asapScheduler, concat, Observable, range} from 'rxjs';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
|
||||
@ -21,7 +21,9 @@ describe('Observable.concat', () => {
|
||||
|
||||
let concatObservable: any;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('concat func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => {
|
||||
@ -33,9 +35,13 @@ describe('Observable.concat', () => {
|
||||
});
|
||||
});
|
||||
|
||||
observable2 = constructorZone2.run(() => { return range(3, 4); });
|
||||
observable2 = constructorZone2.run(() => {
|
||||
return range(3, 4);
|
||||
});
|
||||
|
||||
constructorZone3.run(() => { concatObservable = concat(observable1, observable2); });
|
||||
constructorZone3.run(() => {
|
||||
concatObservable = concat(observable1, observable2);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
concatObservable.subscribe((concat: any) => {
|
||||
@ -62,10 +68,13 @@ describe('Observable.concat', () => {
|
||||
});
|
||||
});
|
||||
|
||||
observable2 = constructorZone2.run(() => { return range(3, 4); });
|
||||
observable2 = constructorZone2.run(() => {
|
||||
return range(3, 4);
|
||||
});
|
||||
|
||||
constructorZone3.run(
|
||||
() => { concatObservable = concat(observable1, observable2, asapScheduler); });
|
||||
constructorZone3.run(() => {
|
||||
concatObservable = concat(observable1, observable2, asapScheduler);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
concatObservable.subscribe(
|
||||
@ -73,7 +82,9 @@ describe('Observable.concat', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(concat);
|
||||
},
|
||||
(error: any) => { fail('subscribe failed' + error); },
|
||||
(error: any) => {
|
||||
fail('subscribe failed' + error);
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
expect(log).toEqual([1, 2, 3, 4, 5, 6]);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, defer} from 'rxjs';
|
||||
import {defer, Observable} from 'rxjs';
|
||||
|
||||
describe('Observable.defer', () => {
|
||||
let log: any[];
|
||||
@ -14,7 +14,9 @@ describe('Observable.defer', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('defer func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => {
|
||||
|
@ -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, empty} from 'rxjs';
|
||||
import {empty, Observable} from 'rxjs';
|
||||
|
||||
describe('Observable.empty', () => {
|
||||
let log: any[];
|
||||
@ -13,16 +13,26 @@ describe('Observable.empty', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('empty func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return empty(); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return empty();
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
(result: any) => { fail('should not call next'); },
|
||||
() => { fail('should not call error'); },
|
||||
() => { expect(Zone.current.name).toEqual(subscriptionZone.name); });
|
||||
(result: any) => {
|
||||
fail('should not call next');
|
||||
},
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable, forkJoin, from, range} from 'rxjs';
|
||||
import {forkJoin, from, Observable, range} from 'rxjs';
|
||||
|
||||
describe('Observable.forkjoin', () => {
|
||||
let log: any[];
|
||||
@ -14,10 +14,14 @@ describe('Observable.forkjoin', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('forkjoin func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return forkJoin(range(1, 2), from([4, 5])); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return forkJoin(range(1, 2), from([4, 5]));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -25,7 +29,9 @@ describe('Observable.forkjoin', () => {
|
||||
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');
|
||||
@ -49,7 +55,9 @@ describe('Observable.forkjoin', () => {
|
||||
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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -13,16 +13,23 @@ describe('Observable.fromPromise', () => {
|
||||
let log: any[];
|
||||
let observable1: any;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('fromPromise func callback should run in the correct zone', asyncTest((done: any) => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const promiseZone1: Zone = Zone.current.fork({name: 'Promise Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let res: any;
|
||||
let promise: any =
|
||||
promiseZone1.run(() => { return new Promise((resolve, reject) => { res = resolve; }); });
|
||||
observable1 = constructorZone1.run(() => { return from(promise); });
|
||||
let promise: any = promiseZone1.run(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
res = resolve;
|
||||
});
|
||||
});
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return from(promise);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -32,7 +39,10 @@ describe('Observable.fromPromise', () => {
|
||||
expect(log).toEqual([1]);
|
||||
done();
|
||||
},
|
||||
() => { fail('should not call error'); }, () => {});
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {});
|
||||
});
|
||||
res(1);
|
||||
|
||||
|
@ -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 {asyncTest} from '../test-util';
|
||||
|
||||
@ -13,12 +13,16 @@ describe('Observable.interval', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('interval 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); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return interval(10);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber = observable1.subscribe(
|
||||
@ -31,7 +35,10 @@ describe('Observable.interval', () => {
|
||||
done();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); }, () => {});
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {});
|
||||
});
|
||||
}, Zone.root));
|
||||
});
|
||||
|
@ -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, merge} from 'rxjs';
|
||||
import {interval, merge, Observable} from 'rxjs';
|
||||
import {map, take} from 'rxjs/operators';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
@ -13,21 +13,26 @@ import {asyncTest} from '../test-util';
|
||||
describe('Observable.merge', () => {
|
||||
let log: any[];
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('merge func callback should run in the correct zone', asyncTest((done: any) => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'});
|
||||
const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
const observable1: any = constructorZone1.run(
|
||||
() => { return interval(8).pipe(map(v => 'observable1' + v), take(1)); });
|
||||
const observable1: any = constructorZone1.run(() => {
|
||||
return interval(8).pipe(map(v => 'observable1' + v), take(1));
|
||||
});
|
||||
|
||||
const observable2: any = constructorZone2.run(
|
||||
() => { return interval(10).pipe(map(v => 'observable2' + v), take(1)); });
|
||||
const observable2: any = constructorZone2.run(() => {
|
||||
return interval(10).pipe(map(v => 'observable2' + v), take(1));
|
||||
});
|
||||
|
||||
const observable3: any =
|
||||
constructorZone3.run(() => { return merge(observable1, observable2); });
|
||||
const observable3: any = constructorZone3.run(() => {
|
||||
return merge(observable1, observable2);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber = observable3.subscribe(
|
||||
@ -35,7 +40,9 @@ describe('Observable.merge', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -14,10 +14,14 @@ describe('Observable.never', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('never func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return NEVER.pipe(startWith(7)); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return NEVER.pipe(startWith(7));
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -25,7 +29,12 @@ describe('Observable.never', () => {
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
log.push(result);
|
||||
},
|
||||
() => { fail('should not call error'); }, () => { fail('should not call complete'); });
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
fail('should not call complete');
|
||||
});
|
||||
});
|
||||
|
||||
expect(log).toEqual([7]);
|
||||
|
@ -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, of } from 'rxjs';
|
||||
import {Observable, of} from 'rxjs';
|
||||
|
||||
describe('Observable.of', () => {
|
||||
let log: any[];
|
||||
@ -13,10 +13,14 @@ describe('Observable.of', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('of func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return of (1, 2, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return of(1, 2, 3);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -24,7 +28,9 @@ describe('Observable.of', () => {
|
||||
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');
|
||||
|
@ -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, asapScheduler, range} from 'rxjs';
|
||||
import {asapScheduler, Observable, range} from 'rxjs';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
|
||||
@ -15,10 +15,14 @@ describe('Observable.range', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('range func callback should run in the correct zone', () => {
|
||||
observable1 = constructorZone1.run(() => { return range(1, 3); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return range(1, 3);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -26,7 +30,9 @@ describe('Observable.range', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
@ -39,7 +45,9 @@ describe('Observable.range', () => {
|
||||
it('range func callback should run in the correct zone with scheduler', 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 range(1, 3, asapScheduler); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return range(1, 3, asapScheduler);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
@ -47,7 +55,9 @@ describe('Observable.range', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call error'); },
|
||||
() => {
|
||||
fail('should not call error');
|
||||
},
|
||||
() => {
|
||||
log.push('completed');
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
|
@ -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, asapScheduler, throwError} from 'rxjs';
|
||||
import {asapScheduler, Observable, throwError} from 'rxjs';
|
||||
|
||||
import {asyncTest} from '../test-util';
|
||||
|
||||
@ -15,20 +15,28 @@ describe('Observable.throw', () => {
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('throw func callback should run in the correct zone', () => {
|
||||
let error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return throwError(error); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return throwError(error);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
(result: any) => { fail('should not call next'); },
|
||||
(result: any) => {
|
||||
fail('should not call next');
|
||||
},
|
||||
(error: any) => {
|
||||
log.push(error);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { fail('should not call complete'); });
|
||||
() => {
|
||||
fail('should not call complete');
|
||||
});
|
||||
});
|
||||
|
||||
expect(log).toEqual([error]);
|
||||
@ -38,18 +46,24 @@ describe('Observable.throw', () => {
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
let error = new Error('test');
|
||||
observable1 = constructorZone1.run(() => { return throwError(error, asapScheduler); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return throwError(error, asapScheduler);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
observable1.subscribe(
|
||||
(result: any) => { fail('should not call next'); },
|
||||
(result: any) => {
|
||||
fail('should not call next');
|
||||
},
|
||||
(error: any) => {
|
||||
log.push(error);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
expect(log).toEqual([error]);
|
||||
done();
|
||||
},
|
||||
() => { fail('should not call complete'); });
|
||||
() => {
|
||||
fail('should not call complete');
|
||||
});
|
||||
});
|
||||
|
||||
expect(log).toEqual([]);
|
||||
|
@ -12,12 +12,16 @@ describe('Observable.timer', () => {
|
||||
let log: any[];
|
||||
let observable1: Observable<any>;
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('timer 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 timer(10, 20); });
|
||||
observable1 = constructorZone1.run(() => {
|
||||
return timer(10, 20);
|
||||
});
|
||||
|
||||
subscriptionZone.run(() => {
|
||||
const subscriber = observable1.subscribe(
|
||||
@ -33,7 +37,9 @@ describe('Observable.timer', () => {
|
||||
done();
|
||||
}
|
||||
},
|
||||
() => { fail('should not call error'); });
|
||||
() => {
|
||||
fail('should not call error');
|
||||
});
|
||||
expect(log).toEqual([]);
|
||||
});
|
||||
}, Zone.root));
|
||||
|
@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
export function supportFeature(Observable: any, method: string) {
|
||||
const func = function() { return !!Observable.prototype[method]; };
|
||||
const func = function() {
|
||||
return !!Observable.prototype[method];
|
||||
};
|
||||
(func as any).message = `Observable.${method} not support`;
|
||||
}
|
||||
|
@ -6,18 +6,24 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {of , range, zip} from 'rxjs';
|
||||
import {of, range, zip} from 'rxjs';
|
||||
|
||||
describe('Observable.zip', () => {
|
||||
let log: any[];
|
||||
const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'});
|
||||
const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'});
|
||||
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('zip func callback should run in the correct zone', () => {
|
||||
const observable1: any = constructorZone1.run(() => { return range(1, 3); });
|
||||
const observable2: any = constructorZone1.run(() => { return of ('foo', 'bar', 'beer'); });
|
||||
const observable1: any = constructorZone1.run(() => {
|
||||
return range(1, 3);
|
||||
});
|
||||
const observable2: any = constructorZone1.run(() => {
|
||||
return of('foo', 'bar', 'beer');
|
||||
});
|
||||
|
||||
const observable3: any = constructorZone1.run(() => {
|
||||
return zip(observable1, observable2, function(n: number, str: string) {
|
||||
@ -32,7 +38,9 @@ describe('Observable.zip', () => {
|
||||
log.push(result);
|
||||
expect(Zone.current.name).toEqual(subscriptionZone.name);
|
||||
},
|
||||
() => { 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