diff --git a/karma-base.conf.js b/karma-base.conf.js index 32f447cff..35b218c97 100644 --- a/karma-base.conf.js +++ b/karma-base.conf.js @@ -17,6 +17,7 @@ module.exports = function(config) { {pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false}, {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, {pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/core-js/**/*.js', included: false, watched: false}, {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false}, {pattern: 'test/assets/**/*.*', watched: true, served: true, included: false}, {pattern: 'build/**/*.js.map', watched: true, served: true, included: false}, diff --git a/lib/rxjs/rxjs-fake-async.ts b/lib/rxjs/rxjs-fake-async.ts index 85ef31dc7..fc1b617b7 100644 --- a/lib/rxjs/rxjs-fake-async.ts +++ b/lib/rxjs/rxjs-fake-async.ts @@ -6,18 +6,16 @@ * found in the LICENSE file at https://angular.io/license */ -import {Scheduler} from 'rxjs/Scheduler'; -import {asap} from 'rxjs/scheduler/asap'; -import {async} from 'rxjs/scheduler/async'; +import {asapScheduler, asyncScheduler, Scheduler} from 'rxjs'; Zone.__load_patch('rxjs.Scheduler.now', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchMethod(Scheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { return Date.now.apply(self, args); }); - api.patchMethod(async, 'now', (delegate: Function) => (self: any, args: any[]) => { + api.patchMethod(asyncScheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { return Date.now.apply(self, args); }); - api.patchMethod(asap, 'now', (delegate: Function) => (self: any, args: any[]) => { + api.patchMethod(asapScheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { return Date.now.apply(self, args); }); }); diff --git a/lib/rxjs/rxjs.ts b/lib/rxjs/rxjs.ts index b8e5340a1..4a29a7405 100644 --- a/lib/rxjs/rxjs.ts +++ b/lib/rxjs/rxjs.ts @@ -6,20 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import 'rxjs/add/observable/bindCallback'; -import 'rxjs/add/observable/bindNodeCallback'; -import 'rxjs/add/observable/defer'; -import 'rxjs/add/observable/forkJoin'; -import 'rxjs/add/observable/fromEventPattern'; -import 'rxjs/add/operator/multicast'; +import {Observable, Subscriber, Subscription} from 'rxjs'; -import {Observable} from 'rxjs/Observable'; -import {asap} from 'rxjs/scheduler/asap'; -import {Subscriber} from 'rxjs/Subscriber'; -import {Subscription} from 'rxjs/Subscription'; -import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; - -(Zone as any).__load_patch('rxjs', (global: any, Zone: ZoneType) => { +(Zone as any).__load_patch('rxjs', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const symbol: (symbolString: string) => string = (Zone as any).__symbol__; const nextSource = 'rxjs.Subscriber.next'; const errorSource = 'rxjs.Subscriber.error'; @@ -27,40 +16,10 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; const ObjectDefineProperties = Object.defineProperties; - const empty = { - closed: true, - next(value: any): void{}, - error(err: any): void { - throw err; - }, - complete(): void {} - }; - - function toSubscriber( - nextOrObserver?: any, error?: (error: any) => void, complete?: () => void): Subscriber { - if (nextOrObserver) { - if (nextOrObserver instanceof Subscriber) { - return (>nextOrObserver); - } - - if (nextOrObserver[rxSubscriber]) { - return nextOrObserver[rxSubscriber](); - } - } - - if (!nextOrObserver && !error && !complete) { - return new Subscriber(empty); - } - - return new Subscriber(nextOrObserver, error, complete); - } - const patchObservable = function() { const ObservablePrototype: any = Observable.prototype; - const symbolSubscribe = symbol('subscribe'); const _symbolSubscribe = symbol('_subscribe'); const _subscribe = ObservablePrototype[_symbolSubscribe] = ObservablePrototype._subscribe; - const subscribe = ObservablePrototype[symbolSubscribe] = ObservablePrototype.subscribe; ObjectDefineProperties(Observable.prototype, { _zone: {value: null, writable: true, configurable: true}, @@ -89,30 +48,58 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; }, set: function(this: Observable, subscribe: any) { (this as any)._zone = Zone.current; - (this as any)._zoneSubscribe = subscribe; + (this as any)._zoneSubscribe = function() { + if (this._zone && this._zone !== Zone.current) { + const tearDown = this._zone.run(subscribe, this, arguments); + if (tearDown && typeof tearDown === 'function') { + const zone = this._zone; + return function() { + if (zone !== Zone.current) { + return zone.run(tearDown, this, arguments); + } + return tearDown.apply(this, arguments); + }; + } + return tearDown; + } + return subscribe.apply(this, arguments); + }; } }, - subscribe: { - writable: true, - configurable: true, - value: function(this: Observable, observerOrNext: any, error: any, complete: any) { - // Only grab a zone if we Zone exists and it is different from the current zone. - const _zone = (this as any)._zone; - if (_zone && _zone !== Zone.current) { - // Current Zone is different from the intended zone. - // Restore the zone before invoking the subscribe callback. - return _zone.run(subscribe, this, [toSubscriber(observerOrNext, error, complete)]); - } - return subscribe.call(this, observerOrNext, error, complete); + subjectFactory: { + get: function() { + return (this as any)._zoneSubjectFactory; + }, + set: function(factory: any) { + const zone = this._zone; + this._zoneSubjectFactory = function() { + if (zone && zone !== Zone.current) { + return zone.run(factory, this, arguments); + } + return factory.apply(this, arguments); + }; } } }); }; + api.patchMethod(Observable.prototype, 'lift', (delegate: any) => (self: any, args: any[]) => { + const observable: any = delegate.apply(self, args); + if (observable.operator) { + observable.operator._zone = Zone.current; + api.patchMethod( + observable.operator, 'call', + (operatorDelegate: any) => (operatorSelf: any, operatorArgs: any[]) => { + if (operatorSelf._zone && operatorSelf._zone !== Zone.current) { + return operatorSelf._zone.run(operatorDelegate, operatorSelf, operatorArgs); + } + return operatorDelegate.apply(operatorSelf, operatorArgs); + }); + } + return observable; + }); + const patchSubscription = function() { - const unsubscribeSymbol = symbol('unsubscribe'); - const unsubscribe = (Subscription.prototype as any)[unsubscribeSymbol] = - Subscription.prototype.unsubscribe; ObjectDefineProperties(Subscription.prototype, { _zone: {value: null, writable: true, configurable: true}, _zoneUnsubscribe: {value: null, writable: true, configurable: true}, @@ -126,22 +113,12 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; }, set: function(this: Subscription, unsubscribe: any) { (this as any)._zone = Zone.current; - (this as any)._zoneUnsubscribe = unsubscribe; - } - }, - unsubscribe: { - writable: true, - configurable: true, - value: function(this: Subscription) { - // Only grab a zone if we Zone exists and it is different from the current zone. - const _zone: Zone = (this as any)._zone; - if (_zone && _zone !== Zone.current) { - // Current Zone is different from the intended zone. - // Restore the zone before invoking the subscribe callback. - _zone.run(unsubscribe, this); - } else { - unsubscribe.apply(this); - } + (this as any)._zoneUnsubscribe = function() { + if (this._zone && this._zone !== Zone.current) { + return this._zone.run(unsubscribe, this, arguments); + } + return unsubscribe.apply(this, arguments); + }; } } }); @@ -205,158 +182,7 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; }; }; - const patchObservableInstance = function(observable: any) { - observable._zone = Zone.current; - }; - - const patchObservableFactoryCreator = function(obj: any, factoryName: string) { - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factoryCreator: any = obj[symbolFactory] = obj[factoryName]; - if (!factoryCreator) { - return; - } - obj[factoryName] = function() { - const factory: any = factoryCreator.apply(this, arguments); - return function() { - const observable = factory.apply(this, arguments); - patchObservableInstance(observable); - return observable; - }; - }; - }; - - const patchObservableFactory = function(obj: any, factoryName: string) { - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factory: any = obj[symbolFactory] = obj[factoryName]; - if (!factory) { - return; - } - obj[factoryName] = function() { - const observable = factory.apply(this, arguments); - patchObservableInstance(observable); - return observable; - }; - }; - - const patchObservableFactoryArgs = function(obj: any, factoryName: string) { - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factory: any = obj[symbolFactory] = obj[factoryName]; - if (!factory) { - return; - } - obj[factoryName] = function() { - const initZone = Zone.current; - const args = Array.prototype.slice.call(arguments); - for (let i = 0; i < args.length; i++) { - const arg = args[i]; - if (typeof arg === 'function') { - args[i] = function() { - const argArgs = Array.prototype.slice.call(arguments); - const runningZone = Zone.current; - if (initZone && runningZone && initZone !== runningZone) { - return initZone.run(arg, this, argArgs); - } else { - return arg.apply(this, argArgs); - } - }; - } - } - - const observable = factory.apply(this, args); - patchObservableInstance(observable); - return observable; - }; - }; - - const patchMulticast = function() { - const obj: any = Observable.prototype; - const factoryName: string = 'multicast'; - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factory: any = obj[symbolFactory] = obj[factoryName]; - if (!factory) { - return; - } - obj[factoryName] = function() { - const _zone: any = Zone.current; - const args = Array.prototype.slice.call(arguments); - let subjectOrSubjectFactory: any = args.length > 0 ? args[0] : undefined; - if (typeof subjectOrSubjectFactory !== 'function') { - const originalFactory: any = subjectOrSubjectFactory; - subjectOrSubjectFactory = function() { - return originalFactory; - }; - } - args[0] = function() { - let subject: any; - if (_zone && _zone !== Zone.current) { - subject = _zone.run(subjectOrSubjectFactory, this, arguments); - } else { - subject = subjectOrSubjectFactory.apply(this, arguments); - } - if (subject && _zone) { - subject._zone = _zone; - } - return subject; - }; - const observable = factory.apply(this, args); - patchObservableInstance(observable); - return observable; - }; - }; - - const patchImmediate = function(asap: any) { - if (!asap) { - return; - } - - const scheduleSymbol = symbol('scheduleSymbol'); - const zoneSymbol = symbol('zone'); - if (asap[scheduleSymbol]) { - return; - } - - const schedule = asap[scheduleSymbol] = asap.schedule; - asap.schedule = function() { - const args = Array.prototype.slice.call(arguments); - const work = args.length > 0 ? args[0] : undefined; - const delay = args.length > 1 ? args[1] : 0; - const state = (args.length > 2 ? args[2] : undefined) || {}; - state[zoneSymbol] = Zone.current; - - const patchedWork = function() { - const workArgs = Array.prototype.slice.call(arguments); - const action = workArgs.length > 0 ? workArgs[0] : undefined; - const scheduleZone = action && action[zoneSymbol]; - if (scheduleZone && scheduleZone !== Zone.current) { - return scheduleZone.runGuarded(work, this, arguments); - } else { - return work.apply(this, arguments); - } - }; - return schedule.call(this, patchedWork, delay, state); - }; - }; - patchObservable(); patchSubscription(); patchSubscriber(); - patchObservableFactoryCreator(Observable, 'bindCallback'); - patchObservableFactoryCreator(Observable, 'bindNodeCallback'); - patchObservableFactory(Observable, 'defer'); - patchObservableFactory(Observable, 'forkJoin'); - patchObservableFactoryArgs(Observable, 'fromEventPattern'); - patchMulticast(); - patchImmediate(asap); }); diff --git a/package.json b/package.json index 533547247..e7b2dbd19 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "clang-format": "^1.2.3", "concurrently": "^2.2.0", "conventional-changelog": "^1.1.7", + "core-js": "^2.5.7", "es6-promise": "^3.0.2", "google-closure-compiler": "^20170409.0.0", "gulp": "^3.8.11", @@ -93,13 +94,13 @@ "phantomjs": "^2.1.7", "promises-aplus-tests": "^2.1.2", "pump": "^1.0.1", - "rxjs": "^5.5.3", + "rxjs": "^6.2.1", "selenium-webdriver": "^3.4.0", "systemjs": "^0.19.37", "ts-loader": "^0.6.0", "tslint": "^4.1.1", "tslint-eslint-rules": "^3.1.0", - "typescript": "2.5.2", + "typescript": "2.9.2", "vrsource-tslint-rules": "^4.0.0", "webdriver-manager": "^12.0.6", "webdriverio": "^4.8.0", diff --git a/test/browser_entry_point.ts b/test/browser_entry_point.ts index 4ec6e5776..d594c89fd 100644 --- a/test/browser_entry_point.ts +++ b/test/browser_entry_point.ts @@ -6,6 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import 'core-js/features/set'; +import 'core-js/features/map'; // List all tests here: import './common_tests'; import './browser/browser.spec'; diff --git a/test/main.ts b/test/main.ts index ccfedf5a8..a68c7ec49 100644 --- a/test/main.ts +++ b/test/main.ts @@ -25,7 +25,10 @@ if (typeof __karma__ !== 'undefined') { System.config({ defaultJSExtensions: true, map: { - 'rxjs': 'base/node_modules/rxjs', + 'rxjs': 'base/node_modules/rxjs/index', + 'rxjs/operators': 'base/node_modules/rxjs/operators/index', + 'core-js/features/set': 'base/node_modules/core-js/es6/set', + 'core-js/features/map': 'base/node_modules/core-js/es6/map', 'es6-promise': 'base/node_modules/es6-promise/dist/es6-promise' }, }); diff --git a/test/rxjs/rxjs.Observable.audit.spec.ts b/test/rxjs/rxjs.Observable.audit.spec.ts index f608b81a6..f46eddc54 100644 --- a/test/rxjs/rxjs.Observable.audit.spec.ts +++ b/test/rxjs/rxjs.Observable.audit.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable} from 'rxjs'; +import {audit, auditTime} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; xdescribe('Observable.audit', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,11 +22,11 @@ xdescribe('Observable.audit', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(100); - return source.audit(ev => { + const source = interval(100); + return source.pipe(audit(ev => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.interval(150); - }); + return interval(150); + })); }); subscriptionZone.run(() => { @@ -33,7 +35,7 @@ xdescribe('Observable.audit', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -54,8 +56,8 @@ xdescribe('Observable.audit', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(100); - return source.auditTime(360); + const source = interval(100); + return source.pipe(auditTime(360)); }); subscriptionZone.run(() => { @@ -64,7 +66,7 @@ xdescribe('Observable.audit', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result >= 7) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { diff --git a/test/rxjs/rxjs.Observable.buffer.spec.ts b/test/rxjs/rxjs.Observable.buffer.spec.ts index c134e71bb..fce6f909d 100644 --- a/test/rxjs/rxjs.Observable.buffer.spec.ts +++ b/test/rxjs/rxjs.Observable.buffer.spec.ts @@ -5,12 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {empty, interval, Observable, of} from 'rxjs'; +import {buffer, bufferCount, bufferTime, bufferToggle, bufferWhen} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; xdescribe('Observable.buffer', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,9 +23,9 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(350); - const interval = Rx.Observable.interval(100); - return interval.buffer(source); + const source = interval(350); + const iv = interval(100); + return iv.pipe(buffer(source)); }); subscriptionZone.run(() => { @@ -31,7 +34,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result[0] >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -52,8 +55,8 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const interval = Rx.Observable.interval(100); - return interval.bufferCount(3); + const iv = interval(100); + return iv.pipe(bufferCount(3)); }); subscriptionZone.run(() => { @@ -62,7 +65,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result[0] >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -83,8 +86,8 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const interval = Rx.Observable.interval(100); - return interval.bufferTime(350); + const iv = interval(100); + return iv.pipe(bufferTime(350)); }); subscriptionZone.run(() => { @@ -93,7 +96,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result[0] >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -114,13 +117,13 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(10); - const opening = Rx.Observable.interval(25); + const source = interval(10); + const opening = interval(25); const closingSelector = (v: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return v % 2 === 0 ? Rx.Observable.of(v) : Rx.Observable.empty(); + return v % 2 === 0 ? of(v) : empty(); }; - return source.bufferToggle(opening, closingSelector); + return source.pipe(bufferToggle(opening, closingSelector)); }); let i = 0; @@ -129,7 +132,7 @@ xdescribe('Observable.buffer', () => { (result: any) => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); - subscriber.complete(); + subscriber.unsubscribe(); }, () => { fail('should not call error'); @@ -149,11 +152,11 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(100); - return source.bufferWhen(() => { + const source = interval(100); + return source.pipe(bufferWhen(() => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.interval(220); - }); + return interval(220); + })); }); let i = 0; @@ -163,7 +166,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (i++ >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -179,4 +182,4 @@ xdescribe('Observable.buffer', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.catch.spec.ts b/test/rxjs/rxjs.Observable.catch.spec.ts index 09a1e8270..33bd613cc 100644 --- a/test/rxjs/rxjs.Observable.catch.spec.ts +++ b/test/rxjs/rxjs.Observable.catch.spec.ts @@ -5,11 +5,12 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; +import {catchError, map, retry} from 'rxjs/operators'; describe('Observable.catch', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,17 +21,17 @@ describe('Observable.catch', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { const error = new Error('test'); - const source = Rx.Observable.of(1, 2, 3).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; } return n; - }); - return source.catch((err: any) => { + })); + return source.pipe(catchError((err: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.of('error1', 'error2'); - }); + return of('error1', 'error2'); + })); }); subscriptionZone.run(() => { @@ -55,15 +56,15 @@ describe('Observable.catch', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3) - .map((n: number) => { + return of(1, 2, 3).pipe( + map((n: number) => { expect(Zone.current.name).toEqual(constructorZone1.name); if (n === 2) { throw error; } return n; - }) - .retry(1); + }), + retry(1)); }); subscriptionZone.run(() => { @@ -83,4 +84,4 @@ describe('Observable.catch', () => { }); expect(log).toEqual([1, 1, error]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.collection.spec.ts b/test/rxjs/rxjs.Observable.collection.spec.ts index e7f6ba608..a39208df2 100644 --- a/test/rxjs/rxjs.Observable.collection.spec.ts +++ b/test/rxjs/rxjs.Observable.collection.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; -import {asyncTest} from '../test-util'; +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'; describe('Observable.collection', () => { let log: string[]; - let observable1: any; + let observable1: Observable; let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { @@ -27,7 +29,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).elementAt(1); + return of(1, 2, 3).pipe(elementAt(1)); }); subscriptionZone.run(() => { @@ -53,14 +55,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = everyZone1.run(() => { - return observable1.every((v: any) => { + return observable1.pipe(every((v: any) => { expect(Zone.current.name).toEqual(everyZone1.name); return v % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -86,14 +88,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = filterZone1.run(() => { - return observable1.filter((v: any) => { + return observable1.pipe(filter((v: any) => { expect(Zone.current.name).toEqual(filterZone1.name); return v % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -119,14 +121,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = findZone1.run(() => { - return observable1.find((v: any) => { + return observable1.pipe(find((v: any) => { expect(Zone.current.name).toEqual(findZone1.name); return v === 2; - }); + })); }); subscriptionZone.run(() => { @@ -152,14 +154,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = findZone1.run(() => { - return observable1.findIndex((v: any) => { + return observable1.pipe(findIndex((v: any) => { expect(Zone.current.name).toEqual(findZone1.name); return v === 2; - }); + })); }); subscriptionZone.run(() => { @@ -185,14 +187,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = firstZone1.run(() => { - return observable1.first((v: any) => { + return observable1.pipe(first((v: any) => { expect(Zone.current.name).toEqual(firstZone1.name); return v === 2; - }); + })); }); subscriptionZone.run(() => { @@ -213,26 +215,30 @@ describe('Observable.collection', () => { }); it('groupBy func callback should run in the correct zone', () => { + if (isPhantomJS()) { + return; + } const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const groupByZone1: Zone = Zone.current.fork({name: 'groupBy Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - const error = new Error('test'); observable1 = constructorZone1.run(() => { const people = [ {name: 'Sue', age: 25}, {name: 'Joe', age: 30}, {name: 'Frank', age: 25}, {name: 'Sarah', age: 35} ]; - return Rx.Observable.from(people); + return from(people); }); observable1 = groupByZone1.run(() => { - return observable1 - .groupBy((person: any) => { + return observable1.pipe( + groupBy((person: any) => { expect(Zone.current.name).toEqual(groupByZone1.name); return person.age; - }) + }), // return as array of each group - .flatMap((group: any) => group.reduce((acc: any, curr: any) => [...acc, curr], [])); + flatMap((group: any) => { + return group.pipe(reduce((acc: any, curr: any) => [...acc, curr], [])); + })); }); subscriptionZone.run(() => { @@ -242,7 +248,7 @@ describe('Observable.collection', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); }, (err: any) => { - fail('should not call error'); + fail('should not call error' + err); }, () => { log.push('completed'); @@ -261,7 +267,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).ignoreElements(); + return of(1, 2, 3).pipe(ignoreElements()); }); subscriptionZone.run(() => { @@ -286,7 +292,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).isEmpty(); + return of(1, 2, 3).pipe(isEmpty()); }); subscriptionZone.run(() => { @@ -312,7 +318,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).last(); + return of(1, 2, 3).pipe(last()); }); subscriptionZone.run(() => { @@ -338,14 +344,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = mapZone1.run(() => { - return observable1.map((v: any) => { + return observable1.pipe(map((v: any) => { expect(Zone.current.name).toEqual(mapZone1.name); return v + 1; - }); + })); }); subscriptionZone.run(() => { @@ -371,11 +377,11 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = mapToZone1.run(() => { - return observable1.mapTo('a'); + return observable1.pipe(mapTo('a')); }); subscriptionZone.run(() => { @@ -400,7 +406,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3).max(); + return of(4, 2, 3).pipe(max()); }); subscriptionZone.run(() => { @@ -426,14 +432,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = maxZone1.run(() => { - return observable1.max((x: number, y: number) => { + return observable1.pipe(max((x: number, y: number) => { expect(Zone.current.name).toEqual(maxZone1.name); return x < y ? -1 : 1; - }); + })); }); subscriptionZone.run(() => { @@ -458,7 +464,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3).min(); + return of(4, 2, 3).pipe(min()); }); subscriptionZone.run(() => { @@ -484,14 +490,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = minZone1.run(() => { - return observable1.max((x: number, y: number) => { + return observable1.pipe(max((x: number, y: number) => { expect(Zone.current.name).toEqual(minZone1.name); return x < y ? 1 : -1; - }); + })); }); subscriptionZone.run(() => { @@ -516,14 +522,14 @@ describe('Observable.collection', () => { const reduceZone1: Zone = Zone.current.fork({name: 'Min Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = reduceZone1.run(() => { - return observable1.reduce((acc: number, one: number) => { + return observable1.pipe(reduce((acc: number, one: number) => { expect(Zone.current.name).toEqual(reduceZone1.name); return acc + one; - }); + })); }); subscriptionZone.run(() => { @@ -548,14 +554,14 @@ describe('Observable.collection', () => { const scanZone1: Zone = Zone.current.fork({name: 'Min Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = scanZone1.run(() => { - return observable1.scan((acc: number, one: number) => { + return observable1.pipe(scan((acc: number, one: number) => { expect(Zone.current.name).toEqual(scanZone1.name); return acc + one; - }); + })); }); subscriptionZone.run(() => { @@ -579,7 +585,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1).repeat(2); + return of(1).pipe(repeat(2)); }); subscriptionZone.run(() => { @@ -604,14 +610,14 @@ describe('Observable.collection', () => { const singleZone1: Zone = Zone.current.fork({name: 'Single Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3, 4, 5); + return of(1, 2, 3, 4, 5); }); observable1 = singleZone1.run(() => { - return observable1.single((val: any) => { + return observable1.pipe(single((val: any) => { expect(Zone.current.name).toEqual(singleZone1.name); return val === 4; - }); + })); }); subscriptionZone.run(() => { @@ -635,7 +641,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3, 4, 5).skip(3); + return of(1, 2, 3, 4, 5).pipe(skip(3)); }); subscriptionZone.run(() => { @@ -659,7 +665,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).skipUntil(Rx.Observable.interval(25)); + return interval(10).pipe(skipUntil(interval(25))); }); subscriptionZone.run(() => { @@ -667,7 +673,7 @@ describe('Observable.collection', () => { (result: any) => { log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); - subscriber.complete(); + subscriber.unsubscribe(); }, (err: any) => { fail('should not call error'); @@ -686,31 +692,26 @@ describe('Observable.collection', () => { const skipZone1: Zone = Zone.current.fork({name: 'Skip Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10); + return interval(10); }); observable1 = skipZone1.run(() => { - return observable1.skipWhile((val: any) => { + return observable1.pipe(skipWhile((val: any) => { expect(Zone.current.name).toEqual(skipZone1.name); return val < 2; - }); + })); }); subscriptionZone.run(() => { const subscriber = observable1.subscribe( (result: any) => { - log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); - subscriber.complete(); + subscriber.unsubscribe(); + expect(result).toEqual(2); + done(); }, (err: any) => { fail('should not call error'); - }, - () => { - log.push('completed'); - expect(Zone.current.name).toEqual(subscriptionZone.name); - expect(log).toEqual([2, 'completed']); - done(); }); }); }, Zone.root)); @@ -719,7 +720,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2).startWith(3); + return of(1, 2).pipe(startWith(3)); }); subscriptionZone.run(() => { @@ -738,4 +739,4 @@ describe('Observable.collection', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.combine.spec.ts b/test/rxjs/rxjs.Observable.combine.spec.ts index c77f0596e..017ae4270 100644 --- a/test/rxjs/rxjs.Observable.combine.spec.ts +++ b/test/rxjs/rxjs.Observable.combine.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {combineLatest, Observable, of} from 'rxjs'; +import {combineAll, map} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.combine', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,12 +22,12 @@ 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 = Rx.Observable.of(1, 2); - const highOrder = source.map((src: any) => { + const source = of(1, 2); + const highOrder = source.pipe(map((src: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.of(src); - }); - return highOrder.combineAll(); + return of(src); + })); + return highOrder.pipe(combineAll()); }); subscriptionZone.run(() => { @@ -51,15 +53,15 @@ 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 = Rx.Observable.of(1, 2, 3); - const highOrder = source.map((src: any) => { + const source = of(1, 2, 3); + const highOrder = source.pipe(map((src: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.of(src); - }); - return highOrder.combineAll((x: any, y: any) => { + return of(src); + })); + return highOrder.pipe(combineAll((x: any, y: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); return {x: x, y: y}; - }); + })); }); subscriptionZone.run(() => { @@ -84,9 +86,9 @@ 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 = Rx.Observable.of(1, 2, 3); - const input = Rx.Observable.of(4, 5, 6); - return source.combineLatest(input); + const source = of(1, 2, 3); + const input = of(4, 5, 6); + return combineLatest(source, input); }); subscriptionZone.run(() => { @@ -111,9 +113,9 @@ 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 = Rx.Observable.of(1, 2, 3); - const input = Rx.Observable.of(4, 5, 6); - return source.combineLatest(input, function(x: any, y: any) { + const source = of(1, 2, 3); + const input = of(4, 5, 6); + return combineLatest(source, input, (x: number, y: number) => { return x + y; }); }); diff --git a/test/rxjs/rxjs.Observable.concat.spec.ts b/test/rxjs/rxjs.Observable.concat.spec.ts index 472b3f2cb..59f67de7b 100644 --- a/test/rxjs/rxjs.Observable.concat.spec.ts +++ b/test/rxjs/rxjs.Observable.concat.spec.ts @@ -6,7 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, concat, Observable, of, range} from 'rxjs'; +import {concatAll, concatMap, concatMapTo, map} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable instance method concat', () => { @@ -15,7 +17,7 @@ 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'}); - let observable1: any; + let observable1: Observable; let observable2: any; let concatObservable: any; @@ -26,7 +28,7 @@ describe('Observable instance method concat', () => { it('concat func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -35,11 +37,11 @@ describe('Observable instance method concat', () => { }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = observable1.concat(observable2); + concatObservable = concat(observable1, observable2); }); subscriptionZone.run(() => { @@ -59,15 +61,15 @@ describe('Observable instance method concat', () => { const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2); + return of(1, 2); }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = observable1.concat(observable2, Rx.Scheduler.asap); + concatObservable = concat(observable1, observable2, asapScheduler); }); subscriptionZone.run(() => { @@ -94,15 +96,15 @@ describe('Observable instance method concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(0, 1, 2); + return of(0, 1, 2); }); constructorZone2.run(() => { - const highOrder = observable1.map((v: any) => { + const highOrder = observable1.pipe(map((v: any) => { expect(Zone.current.name).toEqual(constructorZone2.name); - return Rx.Observable.of(v + 1); - }); - concatObservable = highOrder.concatAll(); + return of(v + 1); + })); + concatObservable = highOrder.pipe(concatAll()); }); subscriptionZone.run(() => { @@ -127,7 +129,7 @@ describe('Observable instance method concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -138,10 +140,10 @@ describe('Observable instance method concat', () => { }); constructorZone2.run(() => { - concatObservable = observable1.concatMap((v: any) => { + concatObservable = observable1.pipe(concatMap((v: any) => { expect(Zone.current.name).toEqual(constructorZone2.name); - return Rx.Observable.of(0, 1); - }); + return of(0, 1); + })); }); subscriptionZone.run(() => { @@ -166,7 +168,7 @@ describe('Observable instance method concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -177,7 +179,7 @@ describe('Observable instance method concat', () => { }); constructorZone2.run(() => { - concatObservable = observable1.concatMapTo(Rx.Observable.of(0, 1)); + concatObservable = observable1.pipe(concatMapTo(of(0, 1))); }); subscriptionZone.run(() => { diff --git a/test/rxjs/rxjs.Observable.count.spec.ts b/test/rxjs/rxjs.Observable.count.spec.ts index 4bb7ab8bb..d866bbaf6 100644 --- a/test/rxjs/rxjs.Observable.count.spec.ts +++ b/test/rxjs/rxjs.Observable.count.spec.ts @@ -5,13 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, range} from 'rxjs'; +import {count} from 'rxjs/operators'; describe('Observable.count', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,10 +20,10 @@ describe('Observable.count', () => { it('count func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.range(1, 3).count((i: number) => { + return range(1, 3).pipe(count((i: number) => { expect(Zone.current.name).toEqual(constructorZone1.name); return i % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -41,4 +42,4 @@ describe('Observable.count', () => { }); expect(log).toEqual([1, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.debounce.spec.ts b/test/rxjs/rxjs.Observable.debounce.spec.ts index 36666e457..ff77c5001 100644 --- a/test/rxjs/rxjs.Observable.debounce.spec.ts +++ b/test/rxjs/rxjs.Observable.debounce.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of, timer} from 'rxjs'; +import {debounce, debounceTime} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.debounce', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,10 +22,10 @@ describe('Observable.debounce', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).debounce(() => { + return of(1, 2, 3).pipe(debounce(() => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.timer(100); - }); + return timer(100); + })); }); subscriptionZone.run(() => { @@ -48,7 +50,7 @@ describe('Observable.debounce', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).debounceTime(100); + return of(1, 2, 3).pipe(debounceTime(100)); }); subscriptionZone.run(() => { @@ -68,4 +70,4 @@ describe('Observable.debounce', () => { }); expect(log).toEqual([3, 'completed']); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.default.spec.ts b/test/rxjs/rxjs.Observable.default.spec.ts index 4c7cc4b7c..23ac2fb33 100644 --- a/test/rxjs/rxjs.Observable.default.spec.ts +++ b/test/rxjs/rxjs.Observable.default.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; +import {defaultIfEmpty} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.defaultIfEmpty', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +22,7 @@ describe('Observable.defaultIfEmpty', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of().defaultIfEmpty('empty'); + return of().pipe(defaultIfEmpty('empty')); }); subscriptionZone.run(() => { diff --git a/test/rxjs/rxjs.Observable.delay.spec.ts b/test/rxjs/rxjs.Observable.delay.spec.ts index 289e8c362..a459cf5a2 100644 --- a/test/rxjs/rxjs.Observable.delay.spec.ts +++ b/test/rxjs/rxjs.Observable.delay.spec.ts @@ -5,12 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {Observable, of, timer} from 'rxjs'; +import {delay, delayWhen} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.delay', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +23,7 @@ describe('Observable.delay', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).delay(100); + return of(1, 2, 3).pipe(delay(100)); }); subscriptionZone.run(() => { @@ -45,9 +48,9 @@ describe('Observable.delay', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).delayWhen((v: any) => { - return Rx.Observable.timer(v * 10); - }); + return of(1, 2, 3).pipe(delayWhen((v: any) => { + return timer(v * 10); + })); }); subscriptionZone.run(() => { @@ -67,4 +70,4 @@ describe('Observable.delay', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.distinct.spec.ts b/test/rxjs/rxjs.Observable.distinct.spec.ts index 6e5534186..394c2dd8a 100644 --- a/test/rxjs/rxjs.Observable.distinct.spec.ts +++ b/test/rxjs/rxjs.Observable.distinct.spec.ts @@ -5,11 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {Observable, of} from 'rxjs'; +import {distinct, distinctUntilChanged, distinctUntilKeyChanged} from 'rxjs/operators'; describe('Observable.distinct', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +22,7 @@ describe('Observable.distinct', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).distinct(); + return of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).pipe(distinct()); }); subscriptionZone.run(() => { @@ -45,7 +47,7 @@ describe('Observable.distinct', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4).distinctUntilChanged(); + return of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4).pipe(distinctUntilChanged()); }); subscriptionZone.run(() => { @@ -70,10 +72,9 @@ describe('Observable.distinct', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable - .of({age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'}, - {age: 6, name: 'Foo'}) - .distinctUntilKeyChanged('name'); + return of({age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'}, + {age: 6, name: 'Foo'}) + .pipe(distinctUntilKeyChanged('name')); }); subscriptionZone.run(() => { @@ -93,4 +94,4 @@ describe('Observable.distinct', () => { expect(log).toEqual( [{age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'}, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.do.spec.ts b/test/rxjs/rxjs.Observable.do.spec.ts index 3cbb3d4cd..75dd492bf 100644 --- a/test/rxjs/rxjs.Observable.do.spec.ts +++ b/test/rxjs/rxjs.Observable.do.spec.ts @@ -5,11 +5,12 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; +import {tap} from 'rxjs/operators'; -describe('Observable.do', () => { +describe('Observable.tap', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -21,14 +22,14 @@ describe('Observable.do', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1); + return of(1); }); observable1 = doZone1.run(() => { - return observable1.do((v: any) => { + return observable1.pipe(tap((v: any) => { log.push(v); expect(Zone.current.name).toEqual(doZone1.name); - }); + })); }); subscriptionZone.run(() => { @@ -47,4 +48,4 @@ describe('Observable.do', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.map.spec.ts b/test/rxjs/rxjs.Observable.map.spec.ts index 11c6ebe59..64a155847 100644 --- a/test/rxjs/rxjs.Observable.map.spec.ts +++ b/test/rxjs/rxjs.Observable.map.spec.ts @@ -5,13 +5,18 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, observable, of} from 'rxjs'; +import {pairwise, partition, pluck} from 'rxjs/operators'; + +import {ifEnvSupports} from '../test-util'; + +import {supportFeature} from './rxjs.util'; describe('Observable.map', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +24,7 @@ describe('Observable.map', () => { it('pairwise func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).pairwise(); + return of(1, 2, 3).pipe(pairwise()); }); subscriptionZone.run(() => { @@ -42,15 +47,15 @@ describe('Observable.map', () => { it('partition func callback should run in the correct zone', () => { const partitionZone = Zone.current.fork({name: 'Partition Zone1'}); - observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + const observable1: any = constructorZone1.run(() => { + return of(1, 2, 3); }); const part: any = partitionZone.run(() => { - return observable1.partition((val: any) => { + return observable1.pipe(partition((val: any) => { expect(Zone.current.name).toEqual(partitionZone.name); return val % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -86,7 +91,7 @@ describe('Observable.map', () => { it('pluck func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of({a: 1, b: 2}, {a: 3, b: 4}).pluck('a'); + return of({a: 1, b: 2}, {a: 3, b: 4}).pipe(pluck('a')); }); subscriptionZone.run(() => { @@ -106,4 +111,4 @@ describe('Observable.map', () => { expect(log).toEqual([1, 3, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.merge.spec.ts b/test/rxjs/rxjs.Observable.merge.spec.ts index 0f4f51da3..2d13dafd0 100644 --- a/test/rxjs/rxjs.Observable.merge.spec.ts +++ b/test/rxjs/rxjs.Observable.merge.spec.ts @@ -5,12 +5,16 @@ * 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 * as Rx from 'rxjs/Rx'; -import {asyncTest} from '../test-util'; +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'; + +import {supportFeature} from './rxjs.util'; describe('Observable.merge', () => { let log: string[]; - let observable1: any; + let observable1: Observable; let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { @@ -28,16 +32,16 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(2); + return of(2); }); observable1 = expandZone1.run(() => { - return observable1 - .expand((val: any) => { + return observable1.pipe( + expand((val: any) => { expect(Zone.current.name).toEqual(expandZone1.name); - return Rx.Observable.of(1 + val); - }) - .take(2); + return of(1 + val); + }), + take(2)); }); subscriptionZone.run(() => { @@ -62,8 +66,7 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.merge( - Rx.Observable.interval(10).take(2), Rx.Observable.interval(15).take(1)); + return merge(interval(10).pipe(take(2)), interval(15).pipe(take(1))); }); subscriptionZone.run(() => { @@ -89,11 +92,11 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2) - .map((v: any) => { - return Rx.Observable.of(v + 1); - }) - .mergeAll(); + return of(1, 2).pipe( + map((v: any) => { + return of(v + 1); + }), + mergeAll()); }); subscriptionZone.run(() => { @@ -119,9 +122,9 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2).mergeMap((v: any) => { - return Rx.Observable.of(v + 1); - }); + return of(1, 2).pipe(mergeMap((v: any) => { + return of(v + 1); + })); }); subscriptionZone.run(() => { @@ -146,7 +149,7 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2).mergeMapTo(Rx.Observable.of(10)); + return of(1, 2).pipe(mergeMapTo(of(10))); }); subscriptionZone.run(() => { @@ -170,11 +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 Rx.Observable.range(0, 3) - .map(function(x: any) { - return Rx.Observable.range(x, 3); - }) - .switch(); + return range(0, 3).pipe( + map(function(x: any) { + return range(x, 3); + }), + switchAll()); }); subscriptionZone.run(() => { @@ -198,9 +201,9 @@ 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 Rx.Observable.range(0, 3).switchMap(function(x: any) { - return Rx.Observable.range(x, 3); - }); + return range(0, 3).pipe(switchMap(function(x: any) { + return range(x, 3); + })); }); subscriptionZone.run(() => { @@ -224,7 +227,7 @@ 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 Rx.Observable.range(0, 3).switchMapTo('a'); + return range(0, 3).pipe(switchMapTo('a')); }); subscriptionZone.run(() => { @@ -243,4 +246,4 @@ describe('Observable.merge', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.multicast.spec.ts b/test/rxjs/rxjs.Observable.multicast.spec.ts index 2c1cb65f0..8473a0a78 100644 --- a/test/rxjs/rxjs.Observable.multicast.spec.ts +++ b/test/rxjs/rxjs.Observable.multicast.spec.ts @@ -5,7 +5,8 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of, Subject} from 'rxjs'; +import {mapTo, multicast, tap} from 'rxjs/operators'; // TODO: @JiaLiPassion, Observable.prototype.multicast return a readonly _subscribe // should find another way to patch subscribe @@ -16,7 +17,7 @@ describe('Observable.multicast', () => { const mapZone1: Zone = Zone.current.fork({name: 'Map Zone1'}); const multicastZone1: Zone = Zone.current.fork({name: 'Multicast Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -24,25 +25,25 @@ describe('Observable.multicast', () => { it('multicast func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = doZone1.run(() => { - return observable1.do((v: any) => { + return observable1.pipe(tap((v: any) => { expect(Zone.current.name).toEqual(doZone1.name); log.push('do' + v); - }); + })); }); observable1 = mapZone1.run(() => { - return observable1.mapTo('test'); + return observable1.pipe(mapTo('test')); }); const multi: any = multicastZone1.run(() => { - return observable1.multicast(() => { + return observable1.pipe(multicast(() => { expect(Zone.current.name).toEqual(multicastZone1.name); - return new Rx.Subject(); - }); + return new Subject(); + })); }); multi.subscribe((val: any) => { @@ -75,4 +76,4 @@ describe('Observable.multicast', () => { 'test', 'do2', 'test', 'do3', 'test', 'completed' ]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.notification.spec.ts b/test/rxjs/rxjs.Observable.notification.spec.ts index c87ffb5fd..6212c85e8 100644 --- a/test/rxjs/rxjs.Observable.notification.spec.ts +++ b/test/rxjs/rxjs.Observable.notification.spec.ts @@ -5,18 +5,20 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Notification, Observable, of} from 'rxjs'; +import {dematerialize} from 'rxjs/operators'; + import {asyncTest, ifEnvSupports} from '../test-util'; const supportNotification = function() { - return typeof Rx.Notification !== 'undefined'; + return typeof Notification !== 'undefined'; }; (supportNotification as any).message = 'RxNotification'; describe('Observable.notification', ifEnvSupports(supportNotification, () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -27,11 +29,11 @@ describe('Observable.notification', ifEnvSupports(supportNotification, () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - const notifA = new Rx.Notification('N', 'A'); - const notifB = new Rx.Notification('N', 'B'); - const notifE = new Rx.Notification('E', void 0, error); - const materialized = Rx.Observable.of(notifA, notifB, notifE as any); - return materialized.dematerialize(); + const notifA = new Notification('N', 'A'); + const notifB = new Notification('N', 'B'); + const notifE = new Notification('E', void 0, error); + const materialized = of(notifA, notifB, notifE as any); + return materialized.pipe(dematerialize()); }); subscriptionZone.run(() => { @@ -51,4 +53,4 @@ describe('Observable.notification', ifEnvSupports(supportNotification, () => { }); }); }); - })); \ No newline at end of file + })); diff --git a/test/rxjs/rxjs.Observable.race.spec.ts b/test/rxjs/rxjs.Observable.race.spec.ts index 44369d44d..7db80efc3 100644 --- a/test/rxjs/rxjs.Observable.race.spec.ts +++ b/test/rxjs/rxjs.Observable.race.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable, race} from 'rxjs'; +import {mapTo} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.race', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,8 +22,7 @@ describe('Observable.race', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.race( - Rx.Observable.interval(10).mapTo('a'), Rx.Observable.interval(15).mapTo('b')); + return race(interval(10).pipe(mapTo('a')), interval(15).pipe(mapTo('b'))); }); subscriptionZone.run(() => { @@ -42,4 +43,4 @@ describe('Observable.race', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.sample.spec.ts b/test/rxjs/rxjs.Observable.sample.spec.ts index 2f767df4d..1bc39406f 100644 --- a/test/rxjs/rxjs.Observable.sample.spec.ts +++ b/test/rxjs/rxjs.Observable.sample.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable} from 'rxjs'; +import {sample, take, throttle} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.sample', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +22,7 @@ describe('Observable.sample', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).sample(Rx.Observable.interval(15)); + return interval(10).pipe(sample(interval(15))); }); subscriptionZone.run(() => { @@ -46,10 +48,10 @@ describe('Observable.sample', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).take(5).throttle((val: any) => { - expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.interval(20); - }); + return interval(10).pipe(take(5), throttle((val: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + return interval(20); + })); }); subscriptionZone.run(() => { @@ -69,4 +71,4 @@ describe('Observable.sample', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.take.spec.ts b/test/rxjs/rxjs.Observable.take.spec.ts index 0edc377a2..4921a7359 100644 --- a/test/rxjs/rxjs.Observable.take.spec.ts +++ b/test/rxjs/rxjs.Observable.take.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable, of} from 'rxjs'; +import {take, takeLast, takeUntil, takeWhile} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.take', () => { let log: string[]; - let observable1: any; + let observable1: Observable; let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { @@ -26,7 +28,7 @@ describe('Observable.take', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).take(1); + return of(1, 2, 3).pipe(take(1)); }); subscriptionZone.run(() => { @@ -50,7 +52,7 @@ describe('Observable.take', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).takeLast(1); + return of(1, 2, 3).pipe(takeLast(1)); }); subscriptionZone.run(() => { @@ -74,7 +76,7 @@ describe('Observable.take', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).takeUntil(Rx.Observable.interval(25)); + return interval(10).pipe(takeUntil(interval(25))); }); subscriptionZone.run(() => { @@ -100,14 +102,14 @@ describe('Observable.take', () => { const takeZone1: Zone = Zone.current.fork({name: 'Take Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10); + return interval(10); }); observable1 = takeZone1.run(() => { - return observable1.takeWhile((val: any) => { + return observable1.pipe(takeWhile((val: any) => { expect(Zone.current.name).toEqual(takeZone1.name); return val < 2; - }); + })); }); subscriptionZone.run(() => { @@ -127,4 +129,4 @@ describe('Observable.take', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.timeout.spec.ts b/test/rxjs/rxjs.Observable.timeout.spec.ts index 28e7ccfbf..7675be42b 100644 --- a/test/rxjs/rxjs.Observable.timeout.spec.ts +++ b/test/rxjs/rxjs.Observable.timeout.spec.ts @@ -5,22 +5,28 @@ * 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 * as Rx from 'rxjs/Rx'; -import {asyncTest} from '../test-util'; +import {Observable, of} from 'rxjs'; +import {timeout} from 'rxjs/operators'; + +import {asyncTest, isPhantomJS} from '../test-util'; describe('Observable.timeout', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; }); it('timeout func callback should run in the correct zone', asyncTest((done: any) => { + if (isPhantomJS()) { + done(); + return; + } const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1).timeout(10); + return of(1).pipe(timeout(10)); }); subscriptionZone.run(() => { @@ -45,7 +51,7 @@ describe('Observable.timeout', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const promise: any = constructorZone1.run(() => { - return Rx.Observable.of(1).toPromise(); + return of(1).toPromise(); }); subscriptionZone.run(() => { @@ -60,4 +66,4 @@ describe('Observable.timeout', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.window.spec.ts b/test/rxjs/rxjs.Observable.window.spec.ts index b252b15fb..0daa28459 100644 --- a/test/rxjs/rxjs.Observable.window.spec.ts +++ b/test/rxjs/rxjs.Observable.window.spec.ts @@ -5,14 +5,16 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable, timer} from 'rxjs'; +import {mergeAll, take, window, windowCount, windowToggle, windowWhen} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; // @JiaLiPassion, in Safari 9(iOS 9), the case is not // stable because of the timer, try to fix it later xdescribe('Observable.window', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -23,9 +25,9 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.timer(0, 10).take(6); - const window = source.window(Rx.Observable.interval(30)); - return window.mergeAll(); + const source = timer(0, 10).pipe(take(6)); + const w = source.pipe(window(interval(30))); + return w.pipe(mergeAll()); }); subscriptionZone.run(() => { @@ -51,9 +53,9 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.timer(0, 10).take(10); - const window = source.windowCount(4); - return window.mergeAll(); + const source = timer(0, 10).pipe(take(10)); + const window = source.pipe(windowCount(4)); + return window.pipe(mergeAll()); }); subscriptionZone.run(() => { @@ -80,18 +82,14 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.timer(0, 10).take(10); + return timer(0, 10).pipe(take(10)); }); windowZone1.run(() => { - return observable1 - .windowToggle( - Rx.Observable.interval(30), - (val: any) => { - expect(Zone.current.name).toEqual(windowZone1.name); - return Rx.Observable.interval(15); - }) - .mergeAll(); + return observable1.pipe(windowToggle(interval(30), (val: any) => { + expect(Zone.current.name).toEqual(windowZone1.name); + return interval(15); + }), mergeAll()); }); subscriptionZone.run(() => { @@ -118,16 +116,16 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.timer(0, 10).take(10); + return timer(0, 10).pipe(take(10)); }); windowZone1.run(() => { - return observable1 - .windowWhen((val: any) => { + return observable1.pipe( + windowWhen(() => { expect(Zone.current.name).toEqual(windowZone1.name); - return Rx.Observable.interval(15); - }) - .mergeAll(); + return interval(15); + }), + mergeAll()); }); subscriptionZone.run(() => { diff --git a/test/rxjs/rxjs.asap.spec.ts b/test/rxjs/rxjs.asap.spec.ts index 1931bab8e..984628174 100644 --- a/test/rxjs/rxjs.asap.spec.ts +++ b/test/rxjs/rxjs.asap.spec.ts @@ -6,46 +6,65 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, of} from 'rxjs'; +import {map, observeOn} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Scheduler.asap', () => { let log: string[]; let errorCallback: Function; - const constructorZone: Zone = Zone.root.fork({ - name: 'Constructor Zone', - onHandleError: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: Error) => { - log.push('error' + error.message); - const result = delegate.handleError(targetZone, error); - errorCallback && errorCallback(); - return false; - } - }); + const constructorZone: Zone = Zone.root.fork({name: 'Constructor Zone'}); beforeEach(() => { log = []; }); - it('scheduler asap error should run in correct zone', asyncTest((done: any) => { + it('scheduler asap should run in correct zone', asyncTest((done: any) => { let observable: any; constructorZone.run(() => { - observable = Rx.Observable.of(1, 2, 3).observeOn(Rx.Scheduler.asap); + observable = of(1, 2, 3).pipe(observeOn(asapScheduler)); }); - errorCallback = () => { - expect(log).toEqual(['erroroops']); - setTimeout(done, 0); - }; + const zone = Zone.current.fork({name: 'subscribeZone'}); + + zone.run(() => { + observable + .pipe(map((value: number) => { + return value; + })) + .subscribe( + (value: number) => { + expect(Zone.current.name).toEqual(zone.name); + if (value === 3) { + setTimeout(done); + } + }, + (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)); + }); Zone.root.run(() => { observable - .map((value: number) => { + .pipe(map((value: number) => { if (value === 3) { throw new Error('oops'); } return value; - }) - .subscribe((value: number) => {}); + })) + .subscribe((value: number) => {}, (err: any) => { + expect(err.message).toEqual('oops'); + expect(Zone.current.name).toEqual(''); + done(); + }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.bindCallback.spec.ts b/test/rxjs/rxjs.bindCallback.spec.ts index ca0cb708e..4de564aad 100644 --- a/test/rxjs/rxjs.bindCallback.spec.ts +++ b/test/rxjs/rxjs.bindCallback.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, bindCallback} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.bindCallback', () => { @@ -27,7 +28,7 @@ describe('Observable.bindCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg0); }; - boundFunc = Rx.Observable.bindCallback(func); + boundFunc = bindCallback(func); observable = boundFunc('test'); }); @@ -47,7 +48,7 @@ describe('Observable.bindCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg0); }; - boundFunc = Rx.Observable.bindCallback(func, (arg: any) => { + boundFunc = bindCallback(func, (arg: any) => { expect(Zone.current.name).toEqual(constructorZone.name); return 'selector' + arg; }); @@ -70,7 +71,7 @@ describe('Observable.bindCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg0); }; - boundFunc = Rx.Observable.bindCallback(func, undefined, Rx.Scheduler.asap); + boundFunc = bindCallback(func, () => true, asapScheduler); observable = boundFunc('test'); }); @@ -84,4 +85,4 @@ describe('Observable.bindCallback', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.bindNodeCallback.spec.ts b/test/rxjs/rxjs.bindNodeCallback.spec.ts index 5bcc0b023..ec8fb933f 100644 --- a/test/rxjs/rxjs.bindNodeCallback.spec.ts +++ b/test/rxjs/rxjs.bindNodeCallback.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, bindCallback, bindNodeCallback, Observable} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.bindNodeCallback', () => { @@ -27,7 +28,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(null, arg); }; - boundFunc = Rx.Observable.bindNodeCallback(func); + boundFunc = bindNodeCallback(func); observable = boundFunc('test'); }); @@ -47,7 +48,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(null, arg); }; - boundFunc = Rx.Observable.bindNodeCallback(func, (arg: any) => { + boundFunc = bindNodeCallback(func, (arg: any) => { expect(Zone.current.name).toEqual(constructorZone.name); return 'selector' + arg; }); @@ -70,7 +71,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(null, arg); }; - boundFunc = Rx.Observable.bindCallback(func, undefined, Rx.Scheduler.asap); + boundFunc = bindCallback(func, () => true, asapScheduler); observable = boundFunc('test'); }); @@ -91,7 +92,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg, null); }; - boundFunc = Rx.Observable.bindCallback(func); + boundFunc = bindCallback(func); observable = boundFunc('test'); }); @@ -108,4 +109,4 @@ describe('Observable.bindNodeCallback', () => { expect(log).toEqual(['nexttest,']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.combineLatest.spec.ts b/test/rxjs/rxjs.combineLatest.spec.ts index 07406fc43..385b411c8 100644 --- a/test/rxjs/rxjs.combineLatest.spec.ts +++ b/test/rxjs/rxjs.combineLatest.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {combineLatest, Observable} from 'rxjs'; describe('Observable.combineLatest', () => { let log: string[]; @@ -14,7 +14,7 @@ describe('Observable.combineLatest', () => { 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'}); - let observable1: any; + let observable1: Observable; let observable2: any; let subscriber1: any; let subscriber2: any; @@ -26,19 +26,19 @@ describe('Observable.combineLatest', () => { }); it('combineLatest func should run in the correct zone', () => { - observable1 = constructorZone1.run(() => new Rx.Observable((_subscriber) => { - subscriber1 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone1.name); - log.push('setup1'); - })); - observable2 = constructorZone2.run(() => new Rx.Observable((_subscriber) => { - subscriber2 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone2.name); - log.push('setup2'); - })); + observable1 = constructorZone1.run(() => new Observable((_subscriber) => { + subscriber1 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone1.name); + log.push('setup1'); + })); + observable2 = constructorZone2.run(() => new Observable((_subscriber) => { + subscriber2 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone2.name); + log.push('setup2'); + })); constructorZone3.run(() => { - combinedObservable = Rx.Observable.combineLatest(observable1, observable2); + combinedObservable = combineLatest(observable1, observable2); }); subscriptionZone.run(() => { @@ -56,23 +56,22 @@ describe('Observable.combineLatest', () => { }); it('combineLatest func with project function should run in the correct zone', () => { - observable1 = constructorZone1.run(() => new Rx.Observable((_subscriber) => { - subscriber1 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone1.name); - log.push('setup1'); - })); - observable2 = constructorZone2.run(() => new Rx.Observable((_subscriber) => { - subscriber2 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone2.name); - log.push('setup2'); - })); + observable1 = constructorZone1.run(() => new Observable((_subscriber) => { + subscriber1 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone1.name); + log.push('setup1'); + })); + observable2 = constructorZone2.run(() => new Observable((_subscriber) => { + subscriber2 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone2.name); + log.push('setup2'); + })); constructorZone3.run(() => { - combinedObservable = - Rx.Observable.combineLatest(observable1, observable2, (x: number, y: number) => { - expect(Zone.current.name).toEqual(constructorZone3.name); - return x + y; - }); + combinedObservable = combineLatest(observable1, observable2, (x: number, y: number) => { + expect(Zone.current.name).toEqual(constructorZone3.name); + return x + y; + }); }); subscriptionZone.run(() => { @@ -88,4 +87,4 @@ describe('Observable.combineLatest', () => { expect(log).toEqual(['setup1', 'setup2', 3, 4]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.common.spec.ts b/test/rxjs/rxjs.common.spec.ts index eba01e333..f0ee5e9a9 100644 --- a/test/rxjs/rxjs.common.spec.ts +++ b/test/rxjs/rxjs.common.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {Observable, Subject} from 'rxjs'; +import {map} from 'rxjs/operators'; /** * The point of these tests, is to ensure that all callbacks execute in the Zone which was active @@ -26,15 +27,16 @@ describe('Zone interaction', () => { const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); let subscriber: any = null; - const observable: any = constructorZone.run(() => new Rx.Observable((_subscriber: any) => { - subscriber = _subscriber; - log.push('setup'); - expect(Zone.current.name).toEqual(constructorZone.name); - return () => { - expect(Zone.current.name).toEqual(constructorZone.name); - log.push('cleanup'); - }; - })); + const observable: any = + constructorZone.run(() => new Observable((_subscriber: any) => { + subscriber = _subscriber; + log.push('setup'); + expect(Zone.current.name).toEqual(constructorZone.name); + return () => { + expect(Zone.current.name).toEqual(constructorZone.name); + log.push('cleanup'); + }; + })); subscriptionZone.run( () => observable.subscribe( () => { @@ -67,19 +69,20 @@ describe('Zone interaction', () => { const rootZone: Zone = Zone.current; const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - const observable: any = constructorZone.run(() => new Rx.Observable((subscriber: any) => { - // Execute the `next`/`complete` in different zone, and assert that - // correct zone - // is restored. - rootZone.run(() => { - subscriber.next('MyValue'); - subscriber.complete(); - }); - return () => { - expect(Zone.current.name).toEqual(constructorZone.name); - log.push('cleanup'); - }; - })); + const observable: any = + constructorZone.run(() => new Observable((subscriber: any) => { + // Execute the `next`/`complete` in different zone, and assert that + // correct zone + // is restored. + rootZone.run(() => { + subscriber.next('MyValue'); + subscriber.complete(); + }); + return () => { + expect(Zone.current.name).toEqual(constructorZone.name); + log.push('cleanup'); + }; + })); subscriptionZone.run( () => observable.subscribe( @@ -102,25 +105,26 @@ describe('Zone interaction', () => { const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); const operatorZone: Zone = Zone.current.fork({name: 'Operator Zone'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable: any = constructorZone.run(() => new Rx.Observable((subscriber: any) => { - // Execute the `next`/`complete` in different zone, and assert that - // correct zone - // is restored. - rootZone.run(() => { - subscriber.next('MyValue'); - subscriber.complete(); - }); - return () => { - expect(Zone.current.name).toEqual(constructorZone.name); - log.push('cleanup'); - }; - })); - - observable = operatorZone.run(() => observable.map((value: any) => { + let observable: any = + constructorZone.run(() => new Observable((subscriber: any) => { + // Execute the `next`/`complete` in different zone, and assert that + // correct zone + // is restored. + rootZone.run(() => { + subscriber.next('MyValue'); + subscriber.complete(); + }); + return () => { + expect(Zone.current.name).toEqual(constructorZone.name); + log.push('cleanup'); + }; + })); + + observable = operatorZone.run(() => observable.pipe(map((value: any) => { expect(Zone.current.name).toEqual(operatorZone.name); log.push('map: ' + value); return value; - })); + }))); subscriptionZone.run( () => observable.subscribe( @@ -143,7 +147,7 @@ describe('Zone interaction', () => { it('should run subscribe in zone of declaration with Observable.create', () => { const log: string[] = []; const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); - let observable: any = constructorZone.run(() => Rx.Observable.create((subscriber: any) => { + let observable: any = constructorZone.run(() => Observable.create((subscriber: any) => { expect(Zone.current.name).toEqual(constructorZone.name); subscriber.next(1); subscriber.complete(); @@ -169,7 +173,7 @@ describe('Zone interaction', () => { let subject: any; constructorZone.run(() => { - subject = new Rx.Subject(); + subject = new Subject(); }); let subscription1: any; @@ -206,4 +210,4 @@ describe('Zone interaction', () => { expect(log).toEqual(['next1', 'next2', 'complete1', 'complete2']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.concat.spec.ts b/test/rxjs/rxjs.concat.spec.ts index da7c5c8f1..afe072fe2 100644 --- a/test/rxjs/rxjs.concat.spec.ts +++ b/test/rxjs/rxjs.concat.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, concat, Observable, range} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.concat', () => { @@ -15,7 +16,7 @@ describe('Observable.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'}); - let observable1: any; + let observable1: Observable; let observable2: any; let concatObservable: any; @@ -26,7 +27,7 @@ describe('Observable.concat', () => { it('concat func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -35,11 +36,11 @@ describe('Observable.concat', () => { }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = Rx.Observable.concat(observable1, observable2); + concatObservable = concat(observable1, observable2); }); subscriptionZone.run(() => { @@ -59,7 +60,7 @@ describe('Observable.concat', () => { const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -68,11 +69,11 @@ describe('Observable.concat', () => { }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = Rx.Observable.concat(observable1, observable2, Rx.Scheduler.asap); + concatObservable = concat(observable1, observable2, asapScheduler); }); subscriptionZone.run(() => { @@ -93,4 +94,4 @@ describe('Observable.concat', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.defer.spec.ts b/test/rxjs/rxjs.defer.spec.ts index 348f87117..4e5bd4458 100644 --- a/test/rxjs/rxjs.defer.spec.ts +++ b/test/rxjs/rxjs.defer.spec.ts @@ -6,13 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {defer, Observable} from 'rxjs'; describe('Observable.defer', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,8 +20,8 @@ describe('Observable.defer', () => { it('defer func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.defer(() => { - return new Rx.Observable(subscribe => { + return defer(() => { + return new Observable(subscribe => { log.push('setup'); expect(Zone.current.name).toEqual(constructorZone1.name); subscribe.next(1); @@ -43,4 +43,4 @@ describe('Observable.defer', () => { expect(log).toEqual(['setup', 1, 'cleanup']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.empty.spec.ts b/test/rxjs/rxjs.empty.spec.ts index 4f4e2c8a4..dfb6d7994 100644 --- a/test/rxjs/rxjs.empty.spec.ts +++ b/test/rxjs/rxjs.empty.spec.ts @@ -5,13 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; +import {empty, Observable} from 'rxjs'; describe('Observable.empty', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +19,7 @@ describe('Observable.empty', () => { it('empty func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.empty(); + return empty(); }); subscriptionZone.run(() => { @@ -35,4 +35,4 @@ describe('Observable.empty', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.forkjoin.spec.ts b/test/rxjs/rxjs.forkjoin.spec.ts index a02a79fde..0f60c352c 100644 --- a/test/rxjs/rxjs.forkjoin.spec.ts +++ b/test/rxjs/rxjs.forkjoin.spec.ts @@ -6,13 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {forkJoin, from, Observable, range} from 'rxjs'; describe('Observable.forkjoin', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +20,7 @@ describe('Observable.forkjoin', () => { it('forkjoin func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.forkJoin(Rx.Observable.range(1, 2), Rx.Observable.from([4, 5])); + return forkJoin(range(1, 2), from([4, 5])); }); subscriptionZone.run(() => { @@ -43,11 +43,10 @@ describe('Observable.forkjoin', () => { it('forkjoin func callback with selector should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.forkJoin( - Rx.Observable.range(1, 2), Rx.Observable.from([4, 5]), function(x, y) { - expect(Zone.current.name).toEqual(constructorZone1.name); - return x + y; - }); + return forkJoin(range(1, 2), from([4, 5]), (x: number, y: number) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + return x + y; + }); }); subscriptionZone.run(() => { @@ -67,4 +66,4 @@ describe('Observable.forkjoin', () => { expect(log).toEqual([7, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.from.spec.ts b/test/rxjs/rxjs.from.spec.ts index 027f4af54..189925d7f 100644 --- a/test/rxjs/rxjs.from.spec.ts +++ b/test/rxjs/rxjs.from.spec.ts @@ -5,14 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; +import {from, Observable} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.from', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +21,7 @@ describe('Observable.from', () => { it('from array should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.from([1, 2]); + return from([1, 2]); }); subscriptionZone.run(() => { @@ -43,7 +44,7 @@ describe('Observable.from', () => { it('from array like object should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.from('foo'); + return from('foo'); }); subscriptionZone.run(() => { @@ -68,7 +69,7 @@ describe('Observable.from', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.from(new Promise((resolve, reject) => { + return from(new Promise((resolve, reject) => { resolve(1); })); }); @@ -92,4 +93,4 @@ describe('Observable.from', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.fromEvent.spec.ts b/test/rxjs/rxjs.fromEvent.spec.ts index e7cb8272e..52cf6a991 100644 --- a/test/rxjs/rxjs.fromEvent.spec.ts +++ b/test/rxjs/rxjs.fromEvent.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {fromEvent, fromEventPattern, Observable} from 'rxjs'; import {isBrowser} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; @@ -22,7 +22,7 @@ describe('Observable.fromEvent', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const triggerZone: Zone = Zone.current.fork({name: 'Trigger Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -31,7 +31,7 @@ describe('Observable.fromEvent', () => { it('fromEvent EventTarget func callback should run in the correct zone', ifEnvSupports(isEventTarget, () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEvent(document, 'click'); + return fromEvent(document, 'click'); }); const clickEvent = document.createEvent('Event'); @@ -64,7 +64,7 @@ describe('Observable.fromEvent', () => { const button = document.createElement('button'); document.body.appendChild(button); observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEventPattern( + return fromEventPattern( (handler: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); button.addEventListener('click', handler); diff --git a/test/rxjs/rxjs.fromPromise.spec.ts b/test/rxjs/rxjs.fromPromise.spec.ts index eba29e643..2727142fa 100644 --- a/test/rxjs/rxjs.fromPromise.spec.ts +++ b/test/rxjs/rxjs.fromPromise.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {from} from 'rxjs'; import {asyncTest} from '../test-util'; describe('Observable.fromPromise', () => { @@ -28,7 +28,7 @@ describe('Observable.fromPromise', () => { }); }); observable1 = constructorZone1.run(() => { - return Rx.Observable.fromPromise(promise); + return from(promise); }); subscriptionZone.run(() => { @@ -48,4 +48,4 @@ describe('Observable.fromPromise', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.interval.spec.ts b/test/rxjs/rxjs.interval.spec.ts index 39bd5244f..1aa683029 100644 --- a/test/rxjs/rxjs.interval.spec.ts +++ b/test/rxjs/rxjs.interval.spec.ts @@ -5,12 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.interval', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +21,7 @@ describe('Observable.interval', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10); + return interval(10); }); subscriptionZone.run(() => { @@ -29,7 +30,7 @@ describe('Observable.interval', () => { log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); if (result >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); expect(log).toEqual([0, 1, 2, 3]); done(); } @@ -40,4 +41,4 @@ describe('Observable.interval', () => { () => {}); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.merge.spec.ts b/test/rxjs/rxjs.merge.spec.ts index 144528d77..2ac9818bb 100644 --- a/test/rxjs/rxjs.merge.spec.ts +++ b/test/rxjs/rxjs.merge.spec.ts @@ -5,7 +5,9 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, merge, Observable} from 'rxjs'; +import {map, take} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.merge', () => { @@ -21,15 +23,15 @@ describe('Observable.merge', () => { const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const observable1: any = constructorZone1.run(() => { - return Rx.Observable.interval(8).map(v => 'observable1' + v).take(1); + return interval(8).pipe(map(v => 'observable1' + v), take(1)); }); const observable2: any = constructorZone2.run(() => { - return Rx.Observable.interval(10).map(v => 'observable2' + v).take(1); + return interval(10).pipe(map(v => 'observable2' + v), take(1)); }); const observable3: any = constructorZone3.run(() => { - return Rx.Observable.merge(observable1, observable2); + return merge(observable1, observable2); }); subscriptionZone.run(() => { @@ -49,4 +51,4 @@ describe('Observable.merge', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.never.spec.ts b/test/rxjs/rxjs.never.spec.ts index e4c6721b9..43b734d07 100644 --- a/test/rxjs/rxjs.never.spec.ts +++ b/test/rxjs/rxjs.never.spec.ts @@ -5,13 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {NEVER, Observable} from 'rxjs'; +import {startWith} from 'rxjs/operators'; describe('Observable.never', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +20,7 @@ describe('Observable.never', () => { it('never func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.never().startWith(7); + return NEVER.pipe(startWith(7)); }); subscriptionZone.run(() => { @@ -38,4 +39,4 @@ describe('Observable.never', () => { expect(log).toEqual([7]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.of.spec.ts b/test/rxjs/rxjs.of.spec.ts index 929036ac5..ea35f2726 100644 --- a/test/rxjs/rxjs.of.spec.ts +++ b/test/rxjs/rxjs.of.spec.ts @@ -5,13 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; describe('Observable.of', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +19,7 @@ describe('Observable.of', () => { it('of func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); subscriptionZone.run(() => { @@ -39,4 +39,4 @@ describe('Observable.of', () => { expect(log).toEqual([1, 2, 3, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.range.spec.ts b/test/rxjs/rxjs.range.spec.ts index 0aa826f7a..73f6eecf9 100644 --- a/test/rxjs/rxjs.range.spec.ts +++ b/test/rxjs/rxjs.range.spec.ts @@ -5,14 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; +import {asapScheduler, Observable, range} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.range', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +21,7 @@ describe('Observable.range', () => { it('range func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.range(1, 3); + return range(1, 3); }); subscriptionZone.run(() => { @@ -45,7 +46,7 @@ describe('Observable.range', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.range(1, 3, Rx.Scheduler.asap); + return range(1, 3, asapScheduler); }); subscriptionZone.run(() => { @@ -67,4 +68,4 @@ describe('Observable.range', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.spec.ts b/test/rxjs/rxjs.spec.ts index 8a42b0fe2..a1feb0930 100644 --- a/test/rxjs/rxjs.spec.ts +++ b/test/rxjs/rxjs.spec.ts @@ -5,6 +5,10 @@ * 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 */ +(Object as any).setPrototypeOf = (Object as any).setPrototypeOf || function(obj: any, proto: any) { + obj.__proto__ = proto; + return obj; +}; import '../../lib/rxjs/rxjs'; import './rxjs.common.spec'; import './rxjs.asap.spec'; @@ -39,7 +43,7 @@ import './rxjs.Observable.notification.spec'; import './rxjs.Observable.distinct.spec'; import './rxjs.Observable.do.spec'; import './rxjs.Observable.collection.spec'; -// TODO: @JiaLiPassion, add exhaust test +// // TODO: @JiaLiPassion, add exhaust test import './rxjs.Observable.merge.spec'; import './rxjs.Observable.multicast.spec'; import './rxjs.Observable.map.spec'; diff --git a/test/rxjs/rxjs.throw.spec.ts b/test/rxjs/rxjs.throw.spec.ts index 28555c358..bae55a856 100644 --- a/test/rxjs/rxjs.throw.spec.ts +++ b/test/rxjs/rxjs.throw.spec.ts @@ -5,14 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; +import {asapScheduler, Observable, throwError} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.throw', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -21,7 +22,7 @@ describe('Observable.throw', () => { it('throw func callback should run in the correct zone', () => { let error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.throw(error); + return throwError(error); }); subscriptionZone.run(() => { @@ -46,7 +47,7 @@ describe('Observable.throw', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); let error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.throw(error, Rx.Scheduler.asap); + return throwError(error, asapScheduler); }); subscriptionZone.run(() => { @@ -67,4 +68,4 @@ describe('Observable.throw', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.timer.spec.ts b/test/rxjs/rxjs.timer.spec.ts index 45d4b1b66..a00423597 100644 --- a/test/rxjs/rxjs.timer.spec.ts +++ b/test/rxjs/rxjs.timer.spec.ts @@ -5,12 +5,12 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, timer} from 'rxjs'; import {asyncTest} from '../test-util'; describe('Observable.timer', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +20,7 @@ describe('Observable.timer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.timer(10, 20); + return timer(10, 20); }); subscriptionZone.run(() => { @@ -29,19 +29,18 @@ describe('Observable.timer', () => { log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); if (result >= 3) { - subscriber.complete(); + // subscriber.complete(); + subscriber.unsubscribe(); + log.push('completed'); + expect(Zone.current.name).toEqual(subscriptionZone.name); + expect(log).toEqual([0, 1, 2, 3, 'completed']); + done(); } }, () => { fail('should not call error'); - }, - () => { - log.push('completed'); - expect(Zone.current.name).toEqual(subscriptionZone.name); - expect(log).toEqual([0, 1, 2, 3, 'completed']); - done(); }); + expect(log).toEqual([]); }); - expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.util.ts b/test/rxjs/rxjs.util.ts new file mode 100644 index 000000000..02523f942 --- /dev/null +++ b/test/rxjs/rxjs.util.ts @@ -0,0 +1,14 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * 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 + */ + +export function supportFeature(Observable: any, method: string) { + const func = function() { + return !!Observable.prototype[method]; + }; + (func as any).message = `Observable.${method} not support`; +} diff --git a/test/rxjs/rxjs.zip.spec.ts b/test/rxjs/rxjs.zip.spec.ts index 20ecd0f07..e768089b9 100644 --- a/test/rxjs/rxjs.zip.spec.ts +++ b/test/rxjs/rxjs.zip.spec.ts @@ -5,7 +5,8 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {of, range, zip} from 'rxjs'; describe('Observable.zip', () => { let log: string[]; @@ -18,14 +19,14 @@ describe('Observable.zip', () => { it('zip func callback should run in the correct zone', () => { const observable1: any = constructorZone1.run(() => { - return Rx.Observable.range(1, 3); + return range(1, 3); }); const observable2: any = constructorZone1.run(() => { - return Rx.Observable.of('foo', 'bar', 'beer'); + return of('foo', 'bar', 'beer'); }); const observable3: any = constructorZone1.run(() => { - return Rx.Observable.zip(observable1, observable2, function(n: number, str: string) { + return zip(observable1, observable2, function(n: number, str: string) { expect(Zone.current.name).toEqual(constructorZone1.name); return {n: n, str: str}; }); @@ -48,4 +49,4 @@ describe('Observable.zip', () => { expect(log).toEqual([{n: 1, str: 'foo'}, {n: 2, str: 'bar'}, {n: 3, str: 'beer'}, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/test-util.ts b/test/test-util.ts index 46a28c699..1a9179725 100644 --- a/test/test-util.ts +++ b/test/test-util.ts @@ -21,6 +21,8 @@ * * ifEnvSupports(supportsOnClick, function() { ... }); */ +import {isNode} from '../lib/common/utils'; + declare const global: any; export function ifEnvSupports(test: any, block: Function): () => void { return _ifEnvSupports(test, block); @@ -132,3 +134,11 @@ export function getEdgeVersion() { } return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); } + +export function isPhantomJS() { + if (isNode) { + return false; + } + const ua = navigator.userAgent.toLowerCase(); + return ua.indexOf('phantomjs') !== -1; +} diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 21a2be440..c58109ccd 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import 'rxjs/add/operator/delay'; import '../../lib/rxjs/rxjs-fake-async'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; +import {delay} from 'rxjs/operators'; import {isNode, patchMacroTask} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; @@ -1146,7 +1146,7 @@ describe('FakeAsyncTestZoneSpec', () => { subscribe.next('hello'); subscribe.complete(); }); - observable.delay(1000).subscribe(v => { + observable.pipe(delay(1000)).subscribe(v => { result = v; }); expect(result).toBe(null); diff --git a/yarn.lock b/yarn.lock index 4047760fe..f589dbb95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1072,6 +1072,10 @@ core-js@^2.1.0, core-js@^2.4.0: version "2.5.3" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" +core-js@^2.5.7: + version "2.5.7" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" + core-js@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.3.0.tgz#fab83fbb0b2d8dc85fa636c4b9d34c75420c6d65" @@ -4716,11 +4720,11 @@ rx@2.3.24: version "2.3.24" resolved "https://registry.yarnpkg.com/rx/-/rx-2.3.24.tgz#14f950a4217d7e35daa71bbcbe58eff68ea4b2b7" -rxjs@^5.5.3: - version "5.5.6" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.6.tgz#e31fb96d6fd2ff1fd84bcea8ae9c02d007179c02" +rxjs@^6.2.1: + version "6.2.2" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.2.2.tgz#eb75fa3c186ff5289907d06483a77884586e1cf9" dependencies: - symbol-observable "1.0.1" + tslib "^1.9.0" safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" @@ -5173,10 +5177,6 @@ supports-color@~5.0.0: dependencies: has-flag "^2.0.0" -symbol-observable@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" - systemjs@^0.19.37: version "0.19.47" resolved "https://registry.yarnpkg.com/systemjs/-/systemjs-0.19.47.tgz#c8c93937180f3f5481c769cd2720763fb4a31c6f" @@ -5458,6 +5458,10 @@ ts-loader@^0.6.0: object-assign "^2.0.0" semver "^5.0.1" +tslib@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" + tslint-eslint-rules@^3.1.0: version "3.5.1" resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-3.5.1.tgz#e43efdcdd760d6285600031720f972c92f4a058a" @@ -5507,9 +5511,9 @@ typedarray@^0.0.6, typedarray@~0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript@2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.2.tgz#038a95f7d9bbb420b1bf35ba31d4c5c1dd3ffe34" +typescript@2.9.2: + version "2.9.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c" uglify-js@2.6.4: version "2.6.4"