From 3f18563a83deac1eb4d3efd53884d54759c5ecb5 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 19 Feb 2016 00:16:16 -0800 Subject: [PATCH] style(test): update specs lint, hint friendly --- karma.conf.js | 1 + package.json | 3 +- spec/Notification-spec.ts | 2 +- spec/Observable-spec.ts | 39 +-- spec/Subject-spec.ts | 43 +-- spec/helpers/ajax-helper.ts | 9 +- spec/observables/bindCallback-spec.ts | 2 +- spec/observables/bindNodeCallback-spec.ts | 1 - spec/observables/dom/webSocket-spec.ts | 2 +- spec/observables/zip-spec.ts | 4 +- spec/operators/buffer-spec.ts | 8 +- spec/operators/bufferTime-spec.ts | 8 +- spec/operators/bufferToggle-spec.ts | 26 +- spec/operators/bufferWhen-spec.ts | 36 +-- spec/operators/cache-spec.ts | 6 +- spec/operators/catch-spec.ts | 8 +- spec/operators/combineLatest-spec.ts | 1 - spec/operators/concatAll-spec.ts | 2 +- spec/operators/concatMap-spec.ts | 28 +- spec/operators/concatMapTo-spec.ts | 12 +- spec/operators/debounce-spec.ts | 8 +- spec/operators/delayWhen-spec.ts | 1 - spec/operators/do-spec.ts | 8 +- spec/operators/elementAt-spec.ts | 2 +- spec/operators/every-spec.ts | 2 +- spec/operators/exhaust-spec.ts | 1 - spec/operators/exhaustMap-spec.ts | 327 +++++++++++----------- spec/operators/groupBy-spec.ts | 5 +- spec/operators/inspect-spec.ts | 9 +- spec/operators/inspectTime-spec.ts | 1 - spec/operators/let-spec.ts | 2 +- spec/operators/map-spec.ts | 6 +- spec/operators/mergeMap-spec.ts | 36 +-- spec/operators/mergeMapTo-spec.ts | 16 +- spec/operators/multicast-spec.ts | 12 +- spec/operators/observeOn-spec.ts | 4 +- spec/operators/pairwise-spec.ts | 3 - spec/operators/pluck-spec.ts | 4 +- spec/operators/publish-spec.ts | 1 - spec/operators/publishLast-spec.ts | 1 - spec/operators/race-spec.ts | 2 +- spec/operators/refCount-spec.ts | 20 +- spec/operators/repeat-spec.ts | 14 +- spec/operators/sample-spec.ts | 2 +- spec/operators/single-spec.ts | 2 +- spec/operators/startWith-spec.ts | 6 +- spec/operators/subscribeOn-spec.ts | 2 +- spec/operators/switch-spec.ts | 4 +- spec/operators/switchMap-spec.ts | 3 +- spec/operators/switchMapTo-spec.ts | 3 +- spec/operators/take-spec.ts | 2 +- spec/operators/takeLast-spec.ts | 2 +- spec/operators/throttle-spec.ts | 8 +- spec/operators/throttleTime-spec.ts | 1 - spec/operators/toPromise-spec.ts | 7 +- spec/operators/windowToggle-spec.ts | 2 +- spec/operators/windowWhen-spec.ts | 1 - spec/operators/withLatestFrom-spec.ts | 10 +- spec/operators/zip-spec.ts | 48 ++-- spec/operators/zipAll-spec.ts | 52 ++-- spec/subjects/AsyncSubject-spec.ts | 2 +- spec/subjects/ReplaySubject-spec.ts | 6 +- spec/util/Immediate-spec.ts | 89 ++++-- spec/util/MapPolyfill-spec.ts | 1 - spec/util/SymbolShim-spec.ts | 10 +- 65 files changed, 518 insertions(+), 471 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index fd7b93cc862..34bb30e0308 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -139,6 +139,7 @@ module.exports = function (config) { // list of files / patterns to load in the browser files: [ + 'node_modules/babel-polyfill/dist/polyfill.js', 'tmp/helpers/marble-testing.js', 'tmp/helpers/test-helper.js', 'tmp/helpers/ajax-helper.js', diff --git a/package.json b/package.json index 9274a07ba87..30859de4112 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build_docs": "npm run build_es6 && npm run tests2png && esdoc -c esdoc.json", "publish_docs": "./publish_docs.sh", "lint_perf": "eslint perf/", - "lint_spec": "eslint spec/", + "lint_spec": "tslint -c tslint.json spec/*.ts spec/**/*.ts spec/**/**/*.ts", "lint_src": "tslint -c tslint.json src/*.ts src/**/*.ts src/**/**/*.ts", "lint": "npm run lint_src && npm run lint_spec && npm run lint_perf", "copy_src": "cp -r src/ dist/cjs/src && cp -r src/ dist/amd/src && cp -r src/ dist/es6/src", @@ -93,6 +93,7 @@ }, "homepage": "https://github.com/ReactiveX/RxJS", "devDependencies": { + "babel-polyfill": "6.5.0", "benchmark": "1.0.0", "benchpress": "2.0.0-beta.1", "browserify": "13.0.0", diff --git a/spec/Notification-spec.ts b/spec/Notification-spec.ts index 4e68619c0d0..2cf0d1c9724 100644 --- a/spec/Notification-spec.ts +++ b/spec/Notification-spec.ts @@ -1,6 +1,6 @@ import * as Rx from '../dist/cjs/Rx'; import {expectObservable} from './helpers/marble-testing'; -import {it, DoneSignature} from './helpers/test-helper'; +import {it} from './helpers/test-helper'; const Notification = Rx.Notification; diff --git a/spec/Observable-spec.ts b/spec/Observable-spec.ts index c77472d81de..afafcf0b3c5 100644 --- a/spec/Observable-spec.ts +++ b/spec/Observable-spec.ts @@ -1,11 +1,10 @@ import * as Rx from '../dist/cjs/Rx'; -import {hot, cold, expectObservable, expectSubscriptions} from './helpers/marble-testing'; import {it, DoneSignature} from './helpers/test-helper'; const Subscriber = Rx.Subscriber; const Observable = Rx.Observable; -declare var __root__: any; +declare const __root__: any; function expectFullObserver(val) { expect(typeof val).toBe('object'); @@ -28,8 +27,8 @@ describe('Observable', () => { describe('forEach', () => { it('should iterate and return a Promise', (done: DoneSignature) => { - const expected = [1,2,3]; - const result = Observable.of(1,2,3).forEach(function (x) { + const expected = [1, 2, 3]; + const result = Observable.of(1, 2, 3).forEach(function (x) { expect(x).toBe(expected.shift()); }, null, Promise) .then(done); @@ -67,9 +66,9 @@ describe('Observable', () => { }); it('should accept a thisArg argument', (done: DoneSignature) => { - const expected = [1,2,3]; + const expected = [1, 2, 3]; const thisArg = {}; - const result = Observable.of(1,2,3).forEach(function (x) { + const result = Observable.of(1, 2, 3).forEach(function (x) { expect(this).toBe(thisArg); expect(x).toBe(expected.shift()); }, thisArg, Promise) @@ -80,7 +79,7 @@ describe('Observable', () => { it('should reject promise if nextHandler throws', (done: DoneSignature) => { const results = []; - Observable.of(1,2,3).forEach((x: number) => { + Observable.of(1, 2, 3).forEach((x: number) => { if (x === 3) { throw new Error('NO THREES!'); } @@ -88,7 +87,7 @@ describe('Observable', () => { }, null) .then(done.fail, function (err) { expect(err).toEqual(new Error('NO THREES!')); - expect(results).toEqual([1,2]); + expect(results).toEqual([1, 2]); }) .then(done); }); @@ -142,7 +141,9 @@ describe('Observable', () => { }; }); - const sub = source.subscribe(() => { }); + const sub = source.subscribe(() => { + //noop + }); expect(sub instanceof Rx.Subscription).toBe(true); expect(unsubscribeCalled).toBe(false); expect(typeof sub.unsubscribe).toBe('function'); @@ -209,7 +210,7 @@ describe('Observable', () => { it('should accept an anonymous observer with just a next function and call the next function in the context' + ' of the anonymous observer', (done: DoneSignature) => { //intentionally not using lambda to avoid typescript's this context capture - var o = { + const o = { next: function next(x) { expect(this).toBe(o); expect(x).toBe(1); @@ -223,7 +224,7 @@ describe('Observable', () => { it('should accept an anonymous observer with just an error function and call the error function in the context' + ' of the anonymous observer', (done: DoneSignature) => { //intentionally not using lambda to avoid typescript's this context capture - var o = { + const o = { error: function error(err) { expect(this).toBe(o); expect(err).toBe('bad'); @@ -237,7 +238,7 @@ describe('Observable', () => { it('should accept an anonymous observer with just a complete function and call the complete function in the' + ' context of the anonymous observer', (done: DoneSignature) => { //intentionally not using lambda to avoid typescript's this context capture - var o = { + const o = { complete: function complete() { expect(this).toBe(o); done(); @@ -260,7 +261,7 @@ describe('Observable', () => { let unsubscribeCalled = false; //intentionally not using lambda to avoid typescript's this context capture - var o = { + const o = { next: function next(x) { expect(this).toBe(o); throw x; @@ -293,7 +294,9 @@ describe('Observable', () => { describe('Observable.create', () => { it('should create an Observable', () => { - const result = Observable.create(() => { }); + const result = Observable.create(() => { + //noop + }); expect(result instanceof Observable).toBe(true); }); @@ -306,14 +309,16 @@ describe('Observable.create', () => { }); expect(called).toBe(false); - result.subscribe(() => { }); + result.subscribe(() => { + //noop + }); expect(called).toBe(true); }); }); describe('Observable.lift', () => { it('should be overrideable in a custom Observable type that composes', (done: DoneSignature) => { - class MyCustomObservable extends Rx.Observable{ + class MyCustomObservable extends Rx.Observable { lift(operator: Rx.Operator): Rx.Observable { const observable = new MyCustomObservable(); (observable).source = this; @@ -357,7 +362,7 @@ describe('Observable.lift', () => { // The custom Operator class LogOperator extends Rx.Operator { - constructor(private childOperator: Rx.Operator) { + constructor(private childOperator: Rx.Operator) { super(); } diff --git a/spec/Subject-spec.ts b/spec/Subject-spec.ts index 6db731037e2..8f3a722599e 100644 --- a/spec/Subject-spec.ts +++ b/spec/Subject-spec.ts @@ -1,9 +1,8 @@ import * as Rx from '../dist/cjs/Rx'; -import {hot, cold, expectObservable, expectSubscriptions} from './helpers/marble-testing'; +import {hot, expectObservable} from './helpers/marble-testing'; import {it, DoneSignature} from './helpers/test-helper'; const Subject = Rx.Subject; -const asap = Rx.Scheduler.asap; const Observable = Rx.Observable; describe('Subject', () => { @@ -94,8 +93,8 @@ describe('Subject', () => { subscription3.unsubscribe(); - expect(results1).toEqual([5,6,7]); - expect(results2).toEqual([6,7,8]); + expect(results1).toEqual([5, 6, 7]); + expect(results2).toEqual([6, 7, 8]); expect(results3).toEqual([11]); }); @@ -142,8 +141,8 @@ describe('Subject', () => { subscription3.unsubscribe(); - expect(results1).toEqual([5,6,7]); - expect(results2).toEqual([6,7,'C']); + expect(results1).toEqual([5, 6, 7]); + expect(results2).toEqual([6, 7, 'C']); expect(results3).toEqual(['C']); }); @@ -190,8 +189,8 @@ describe('Subject', () => { subscription3.unsubscribe(); - expect(results1).toEqual([5,6,7]); - expect(results2).toEqual([6,7,'E']); + expect(results1).toEqual([5, 6, 7]); + expect(results2).toEqual([6, 7, 'E']); expect(results3).toEqual(['E']); }); @@ -263,15 +262,15 @@ describe('Subject', () => { subject.unsubscribe(); expect(() => { - const subscription3 = subject.subscribe( + subject.subscribe( function (x) { results3.push(x); }, function (e) { results3.push('E'); }, () => { results3.push('C'); } ); }).toThrow(); - expect(results1).toEqual([1,2,3,4,5]); - expect(results2).toEqual([3,4,5]); + expect(results1).toEqual([1, 2, 3, 4, 5]); + expect(results2).toEqual([3, 4, 5]); expect(results3).toEqual([]); }); @@ -307,9 +306,9 @@ describe('Subject', () => { auxSubject.next('c'); auxSubject.next('d'); - expect(results1).toEqual([1,2,3]); + expect(results1).toEqual([1, 2, 3]); expect(subscription2.isUnsubscribed).toBe(true); - expect(results2).toEqual(['a','b']); + expect(results2).toEqual(['a', 'b']); }); it('should allow ad-hoc subscription to be removed from itself', () => { @@ -345,9 +344,9 @@ describe('Subject', () => { auxSubject.next('c'); auxSubject.next('d'); - expect(results1).toEqual([1,2,3]); + expect(results1).toEqual([1, 2, 3]); expect(subscription2.isUnsubscribed).toBe(false); - expect(results2).toEqual(['a','b','c','d']); + expect(results2).toEqual(['a', 'b', 'c', 'd']); }); it('should not allow values to be nexted after a return', (done: DoneSignature) => { @@ -367,9 +366,11 @@ describe('Subject', () => { const subject = new Subject(); const sub1 = subject.subscribe(function (x) { + //noop }); const sub2 = subject.subscribe(function (x) { + //noop }); expect(subject.observers.length).toBe(2); @@ -382,7 +383,7 @@ describe('Subject', () => { it('should have a static create function that works', () => { expect(typeof Subject.create).toBe('function'); - const source = Observable.of(1,2,3,4,5); + const source = Observable.of(1, 2, 3, 4, 5); const nexts = []; const output = []; @@ -418,17 +419,17 @@ describe('Subject', () => { sub.next('c'); sub.complete(); - expect(nexts).toEqual(['a','b','c']); + expect(nexts).toEqual(['a', 'b', 'c']); expect(complete).toBe(true); expect(error).toBe(undefined); - expect(output).toEqual([1,2,3,4,5]); + expect(output).toEqual([1, 2, 3, 4, 5]); expect(outputComplete).toBe(true); }); it('should have a static create function that works also to raise errors', () => { expect(typeof Subject.create).toBe('function'); - const source = Observable.of(1,2,3,4,5); + const source = Observable.of(1, 2, 3, 4, 5); const nexts = []; const output = []; @@ -464,11 +465,11 @@ describe('Subject', () => { sub.next('c'); sub.error('boom'); - expect(nexts).toEqual(['a','b','c']); + expect(nexts).toEqual(['a', 'b', 'c']); expect(complete).toBe(false); expect(error).toBe('boom'); - expect(output).toEqual([1,2,3,4,5]); + expect(output).toEqual([1, 2, 3, 4, 5]); expect(outputComplete).toBe(true); }); diff --git a/spec/helpers/ajax-helper.ts b/spec/helpers/ajax-helper.ts index 4bb943ffb3f..3d32f5d01ae 100644 --- a/spec/helpers/ajax-helper.ts +++ b/spec/helpers/ajax-helper.ts @@ -30,7 +30,7 @@ export class MockWebSocket { const sent = this.sent; const length = sent.length; - return length > 0 ? sent[length -1] : undefined; + return length > 0 ? sent[length - 1] : undefined; } triggerClose(e: any): void { @@ -75,8 +75,8 @@ export class MockWebSocket { removeEventListener(name: string, handler: any): void { const lookup = this.handlers[name]; - if(lookup) { - for (let i = lookup.length - 1; i--;) { + if (lookup) { + for (let i = lookup.length - 1; i--; ) { if (lookup[i] === handler) { lookup.splice(i, 1); } @@ -121,7 +121,6 @@ export class MockXMLHttpRequest { private eventHandlers: Array = []; private readyState: number = 0; - private async: any; private user: any; private password: any; @@ -163,7 +162,7 @@ export class MockXMLHttpRequest { } removeEventListener(name: string, handler: any): void { - for (let i = this.eventHandlers.length - 1; i--;) { + for (let i = this.eventHandlers.length - 1; i--; ) { let eh = this.eventHandlers[i]; if (eh.name === name && eh.handler === handler) { this.eventHandlers.splice(i, 1); diff --git a/spec/observables/bindCallback-spec.ts b/spec/observables/bindCallback-spec.ts index 3c7ad5d1504..5e77ba93c78 100644 --- a/spec/observables/bindCallback-spec.ts +++ b/spec/observables/bindCallback-spec.ts @@ -233,7 +233,7 @@ describe('Observable.bindCallback', () => { results1.push('done'); }); - source.subscribe((x: number) =>{ + source.subscribe((x: number) => { results2.push(x); }, null, () => { results2.push('done'); diff --git a/spec/observables/bindNodeCallback-spec.ts b/spec/observables/bindNodeCallback-spec.ts index c1d88ad703f..b2720a422fe 100644 --- a/spec/observables/bindNodeCallback-spec.ts +++ b/spec/observables/bindNodeCallback-spec.ts @@ -1,5 +1,4 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it, DoneSignature} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; diff --git a/spec/observables/dom/webSocket-spec.ts b/spec/observables/dom/webSocket-spec.ts index 608c8966817..6f9b7e3d290 100644 --- a/spec/observables/dom/webSocket-spec.ts +++ b/spec/observables/dom/webSocket-spec.ts @@ -5,7 +5,7 @@ import {it} from '../../helpers/test-helper'; declare const __root__: any; const Observable = Rx.Observable; -var __ws: any; +let __ws: any; function setupMockWebSocket() { MockWebSocket.clearSockets(); diff --git a/spec/observables/zip-spec.ts b/spec/observables/zip-spec.ts index b1600a6e109..5bf25085890 100644 --- a/spec/observables/zip-spec.ts +++ b/spec/observables/zip-spec.ts @@ -535,7 +535,7 @@ describe('Observable.zip', () => { const bsubs = '^ !'; const expected = '-----x--#'; - expectObservable(Observable.zip(a,b)).toBe(expected, { x: [1, 2] }, 'too bad'); + expectObservable(Observable.zip(a, b)).toBe(expected, { x: [1, 2] }, 'too bad'); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); }); @@ -570,7 +570,7 @@ describe('Observable.zip', () => { const r = [[1, 4], [2, 5], [3, 6]]; let i = 0; - Observable.zip(a, b).subscribe((vals:Array) => { + Observable.zip(a, b).subscribe((vals: Array) => { (expect(vals)).toDeepEqual(r[i++]); }, null, done); }); diff --git a/spec/operators/buffer-spec.ts b/spec/operators/buffer-spec.ts index 372dcb4377f..54dda60d323 100644 --- a/spec/operators/buffer-spec.ts +++ b/spec/operators/buffer-spec.ts @@ -10,9 +10,9 @@ describe('Observable.prototype.buffer()', () => { const b = hot('-----B-----B-----B-|'); const expected = '-----x-----y-----z-|'; const expectedValues = { - x: ['a','b','c'], - y: ['d','e','f'], - z: ['g','h','i'] + x: ['a', 'b', 'c'], + y: ['d', 'e', 'f'], + z: ['g', 'h', 'i'] }; expectObservable(a.buffer(b)).toBe(expected, expectedValues); }); @@ -213,7 +213,7 @@ describe('Observable.prototype.buffer()', () => { const bsubs = '^ !'; const expected = '-----(x|)'; const expectedValues = { - x: ['a','b','c'], + x: ['a', 'b', 'c'], }; expectObservable(a.buffer(b).take(1)).toBe(expected, expectedValues); diff --git a/spec/operators/bufferTime-spec.ts b/spec/operators/bufferTime-spec.ts index 5fe1964de70..299e7b69780 100644 --- a/spec/operators/bufferTime-spec.ts +++ b/spec/operators/bufferTime-spec.ts @@ -12,8 +12,8 @@ describe('Observable.prototype.bufferTime', () => { const t = time( '----------|'); const expected = '----------w---------x---------y--(z|)'; const values = { - w: ['a','b'], - x: ['c','d','e'], + w: ['a', 'b'], + x: ['c', 'd', 'e'], y: ['f', 'g'], z: [] }; @@ -29,7 +29,7 @@ describe('Observable.prototype.bufferTime', () => { const t = time( '--------------------------------|'); const expected = '--------------------------------x-------------------------------y---(z|)'; const values = { - x: ['a','b','c'], + x: ['a', 'b', 'c'], y: ['d', 'e', 'g'], z: [] }; @@ -197,7 +197,7 @@ describe('Observable.prototype.bufferTime', () => { const t = time( '----------|'); const expected = '----------w----#'; const values = { - w: ['a','b'] + w: ['a', 'b'] }; const result = e1.bufferTime(t, null, rxTestScheduler); diff --git a/spec/operators/bufferToggle-spec.ts b/spec/operators/bufferToggle-spec.ts index 5a5b7fab881..3d7ca860806 100644 --- a/spec/operators/bufferToggle-spec.ts +++ b/spec/operators/bufferToggle-spec.ts @@ -11,7 +11,7 @@ describe('Observable.prototype.bufferToggle', () => { const e3 = hot('---------c---------------c-----|'); const expected = '---------x---------------y-----|'; const values = { - x: ['a','b'], + x: ['a', 'b'], y: ['f'], }; @@ -31,8 +31,8 @@ describe('Observable.prototype.bufferToggle', () => { const expected = '----------------------------q-------------r-------(s|)'; const values = { - q: ['c','d','e'], - r: ['f','g','h'], + q: ['c', 'd', 'e'], + r: ['f', 'g', 'h'], s: ['i'] }; const innerVals = ['x', 'y', 'z']; @@ -56,9 +56,9 @@ describe('Observable.prototype.bufferToggle', () => { ' ^ ! ']; const expected = '-----------------ij----------------(k|) '; const values = { - i: ['b','c','d','e'], + i: ['b', 'c', 'd', 'e'], j: ['e'], - k: ['g','h'] + k: ['g', 'h'] }; let i = 0; @@ -84,9 +84,9 @@ describe('Observable.prototype.bufferToggle', () => { sub: ' ^ ! '}]; // eslint-disable-line key-spacing const expected = '-----------------ij----------------(k|)'; const values = { - i: ['b','c','d','e'], + i: ['b', 'c', 'd', 'e'], j: ['e'], - k: ['g','h'] + k: ['g', 'h'] }; let i = 0; @@ -109,9 +109,9 @@ describe('Observable.prototype.bufferToggle', () => { cold( '---------------|')]; const expected = '-----------------ij----------------(k|)'; const values = { - i: ['b','c','d','e'], + i: ['b', 'c', 'd', 'e'], j: ['e'], - k: ['g','h'] + k: ['g', 'h'] }; let i = 0; @@ -133,7 +133,7 @@ describe('Observable.prototype.bufferToggle', () => { const expected = '----------- '; const unsub = ' ! '; const values = { - i: ['b','c','d','e'] + i: ['b', 'c', 'd', 'e'] }; let i = 0; @@ -157,7 +157,7 @@ describe('Observable.prototype.bufferToggle', () => { const expected = '-----------------i- '; const unsub = ' ! '; const values = { - i: ['b','c','d','e'] + i: ['b', 'c', 'd', 'e'] }; let i = 0; @@ -227,7 +227,7 @@ describe('Observable.prototype.bufferToggle', () => { ' ^ ! ']; const expected = '-----------------i-# '; const values = { - i: ['b','c','d','e'] + i: ['b', 'c', 'd', 'e'] }; let i = 0; @@ -250,7 +250,7 @@ describe('Observable.prototype.bufferToggle', () => { ' ^ ! ']; const expected = '-----------------i-# '; const values = { - i: ['b','c','d','e'] + i: ['b', 'c', 'd', 'e'] }; let i = 0; diff --git a/spec/operators/bufferWhen-spec.ts b/spec/operators/bufferWhen-spec.ts index 8d93c92f17e..225173be169 100644 --- a/spec/operators/bufferWhen-spec.ts +++ b/spec/operators/bufferWhen-spec.ts @@ -11,8 +11,8 @@ describe('Observable.prototype.bufferWhen', () => { // --------------(s|) const expected = '--------------x-------------y-----(z|)'; const values = { - x: ['b','c','d'], - y: ['e','f','g'], + x: ['b', 'c', 'd'], + y: ['e', 'f', 'g'], z: [] }; @@ -28,8 +28,8 @@ describe('Observable.prototype.bufferWhen', () => { cold( '-------------(s|)')]; const expected = '---------------x---------y---------(z|) '; const values = { - x: ['b','c','d'], - y: ['e','f','g'], + x: ['b', 'c', 'd'], + y: ['e', 'f', 'g'], z: ['h'] }; @@ -52,8 +52,8 @@ describe('Observable.prototype.bufferWhen', () => { sub: ' ^ ! '}]; // eslint-disable-line key-spacing const expected = '---------------x---------y---------(z|)'; const values = { - x: ['b','c','d'], - y: ['e','f','g'], + x: ['b', 'c', 'd'], + y: ['e', 'f', 'g'], z: ['h'] }; @@ -79,8 +79,8 @@ describe('Observable.prototype.bufferWhen', () => { ' ^ ! ']; const expected = '---------------x---------y---------(z|)'; const values = { - x: ['b','c','d'], - y: ['e','f','g'], + x: ['b', 'c', 'd'], + y: ['e', 'f', 'g'], z: ['h'] }; @@ -106,7 +106,7 @@ describe('Observable.prototype.bufferWhen', () => { ' ^ ! ']; const expected = '---------------x--- '; const values = { - x: ['b','c','d'] + x: ['b', 'c', 'd'] }; let i = 0; @@ -131,7 +131,7 @@ describe('Observable.prototype.bufferWhen', () => { const expected = '---------------x--- '; const unsub = ' ! '; const values = { - x: ['b','c','d'] + x: ['b', 'c', 'd'] }; let i = 0; @@ -156,7 +156,7 @@ describe('Observable.prototype.bufferWhen', () => { cold( '-------------(s|)')]; const closeSubs0 = '^ ! '; const expected = '---------------(x#) '; - const values = { x: ['b','c','d'] }; + const values = { x: ['b', 'c', 'd'] }; let i = 0; const result = e1.bufferWhen(() => { @@ -180,7 +180,7 @@ describe('Observable.prototype.bufferWhen', () => { const closeSubs = ['^ ! ', ' (^!) ']; const expected = '---------------(x#) '; - const values = { x: ['b','c','d'] }; + const values = { x: ['b', 'c', 'd'] }; let i = 0; const result = e1.bufferWhen(() => closings[i++]); @@ -200,7 +200,7 @@ describe('Observable.prototype.bufferWhen', () => { const closeSubs = ['^ ! ', ' ^ ! ']; const expected = '---------------x-----# '; - const values = { x: ['b','c','d'] }; + const values = { x: ['b', 'c', 'd'] }; let i = 0; const result = e1.bufferWhen(() => closings[i++]); @@ -219,7 +219,7 @@ describe('Observable.prototype.bufferWhen', () => { ' ^ !']; const expected = '---------------x--------#'; const values = { - x: ['b','c','d'] + x: ['b', 'c', 'd'] }; const result = e1.bufferWhen(() => e2); @@ -286,7 +286,7 @@ describe('Observable.prototype.bufferWhen', () => { const e2 = cold('-'); const expected = '-----------------------------------(x|)'; const values = { - x: ['b','c','d','e','f','g','h'] + x: ['b', 'c', 'd', 'e', 'f', 'g', 'h'] }; expectObservable(e1.bufferWhen(() => e2)).toBe(expected, values); @@ -319,7 +319,7 @@ describe('Observable.prototype.bufferWhen', () => { const e2subs = '(^!)'; const expected = '#'; const values = { - x: ['b','c','d','e','f','g','h'] + x: ['b', 'c', 'd', 'e', 'f', 'g', 'h'] }; const result = e1.bufferWhen(() => e2); @@ -337,8 +337,8 @@ describe('Observable.prototype.bufferWhen', () => { // ---------------(s|) const expected = '---------------x-----'; const values = { - x: ['b','c','d'], - y: ['e','f','g','h'], + x: ['b', 'c', 'd'], + y: ['e', 'f', 'g', 'h'], z: [] }; diff --git a/spec/operators/cache-spec.ts b/spec/operators/cache-spec.ts index 8ad316e014a..de2bc0977be 100644 --- a/spec/operators/cache-spec.ts +++ b/spec/operators/cache-spec.ts @@ -1,10 +1,8 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; -import {hot, cold, time, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, asDiagram} from '../helpers/test-helper'; +import {hot, cold, time, expectObservable} from '../helpers/marble-testing'; +import {it} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; -const Observable = Rx.Observable; -const asap = Rx.Scheduler.asap; describe('Observable.prototype.cache', () => { it('should replay values upon subscription', () => { diff --git a/spec/operators/catch-spec.ts b/spec/operators/catch-spec.ts index 4a31278737b..96547bddbfe 100644 --- a/spec/operators/catch-spec.ts +++ b/spec/operators/catch-spec.ts @@ -218,10 +218,10 @@ describe('Observable.prototype.catch()', () => { expect(err).toBe('bad'); return Observable.empty(); }) - .subscribe(() => { }, - (err: any) => { + .subscribe(() => { + //noop + }, (err: any) => { done.fail('should not be called'); - }, - done); + }, done); }); }); diff --git a/spec/operators/combineLatest-spec.ts b/spec/operators/combineLatest-spec.ts index 214a0f48748..460fda786ed 100644 --- a/spec/operators/combineLatest-spec.ts +++ b/spec/operators/combineLatest-spec.ts @@ -3,7 +3,6 @@ import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marbl import {it, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; -const queueScheduler = Rx.Scheduler.queue; describe('Observable.prototype.combineLatest', () => { asDiagram('combineLatest')('should combine events from two cold observables', () => { diff --git a/spec/operators/concatAll-spec.ts b/spec/operators/concatAll-spec.ts index b070517cbf4..526b902e09a 100644 --- a/spec/operators/concatAll-spec.ts +++ b/spec/operators/concatAll-spec.ts @@ -31,7 +31,7 @@ describe('Observable.prototype.concatAll()', () => { (x: number) => { res.push(x); }, (err: any) => { done.fail('should not be called.'); }, () => { - expect(res).toEqual([0,1,2,3]); + expect(res).toEqual([0, 1, 2, 3]); done(); }); }, 2000); diff --git a/spec/operators/concatMap-spec.ts b/spec/operators/concatMap-spec.ts index 80e4178e382..7f9f5d0ef10 100644 --- a/spec/operators/concatMap-spec.ts +++ b/spec/operators/concatMap-spec.ts @@ -40,7 +40,7 @@ describe('Observable.prototype.concatMap()', () => { ' ^ !']; const expected = '---i-j-k-l---i-j-k-l---i-j-k-l---i-j-k-l-|'; - const result = e1.concatMap((value: any) =>inner); + const result = e1.concatMap((value: any) => inner); expectObservable(result).toBe(expected, values); expectSubscriptions(inner.subscriptions).toBe(innersubs); @@ -637,7 +637,7 @@ describe('Observable.prototype.concatMap()', () => { }); it('should map values to constant resolved promises and concatenate', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = (value: any) => Observable.from(Promise.resolve(42)); const results = []; @@ -647,13 +647,13 @@ describe('Observable.prototype.concatMap()', () => { }, (err: any) => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([42,42,42,42]); + expect(results).toEqual([42, 42, 42, 42]); done(); }); }); it('should map values to constant rejected promises and concatenate', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = (value: any) => Observable.from(Promise.reject(42)); source.concatMap(project).subscribe( @@ -668,7 +668,7 @@ describe('Observable.prototype.concatMap()', () => { }); it('should map values to resolved promises and concatenate', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = (value: number, index: number) => Observable.from(Promise.resolve(value + index)); const results = []; @@ -678,13 +678,13 @@ describe('Observable.prototype.concatMap()', () => { }, (err: any) => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([4,4,4,4]); + expect(results).toEqual([4, 4, 4, 4]); done(); }); }); it('should map values to rejected promises and concatenate', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = (value: number, index: number) => Observable.from(Promise.reject('' + value + '-' + index)); source.concatMap(project).subscribe( @@ -699,7 +699,7 @@ describe('Observable.prototype.concatMap()', () => { }); it('should concatMap values to resolved promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const resultSelectorCalledWith = []; const project = (value: number, index: number) => Observable.from((Promise.resolve([value, index]))); @@ -710,10 +710,10 @@ describe('Observable.prototype.concatMap()', () => { const results = []; const expectedCalls = [ - [4, [4,0], 0, 0], - [3, [3,1], 1, 0], - [2, [2,2], 2, 0], - [1, [1,3], 3, 0] + [4, [4, 0], 0, 0], + [3, [3, 1], 1, 0], + [2, [2, 2], 2, 0], + [1, [1, 3], 3, 0] ]; source.concatMap(project, resultSelector).subscribe( (x: any) => { @@ -721,14 +721,14 @@ describe('Observable.prototype.concatMap()', () => { }, (err: any) => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([8,8,8,8]); + expect(results).toEqual([8, 8, 8, 8]); (expect(resultSelectorCalledWith)).toDeepEqual(expectedCalls); done(); }); }); it('should concatMap values to rejected promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = (value: number, index: number) => Observable.from(Promise.reject('' + value + '-' + index)); const resultSelector = () => { diff --git a/spec/operators/concatMapTo-spec.ts b/spec/operators/concatMapTo-spec.ts index 2016b7ee52d..51096a0b8c5 100644 --- a/spec/operators/concatMapTo-spec.ts +++ b/spec/operators/concatMapTo-spec.ts @@ -300,7 +300,7 @@ describe('Observable.prototype.concatMapTo()', () => { }); it('should map values to constant resolved promises and concatenate', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const results = []; source.concatMapTo(Observable.from(Promise.resolve(42))).subscribe( @@ -311,13 +311,13 @@ describe('Observable.prototype.concatMapTo()', () => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([42,42,42,42]); + expect(results).toEqual([42, 42, 42, 42]); done(); }); }); it('should map values to constant rejected promises and concatenate', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); source.concatMapTo(Observable.from(Promise.reject(42))).subscribe( (x: any) => { @@ -333,7 +333,7 @@ describe('Observable.prototype.concatMapTo()', () => { }); it('should concatMapTo values to resolved promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const resultSelectorCalledWith = []; const inner = Observable.from(Promise.resolve(42)); const resultSelector = function (outerVal, innerVal, outerIndex, innerIndex) { @@ -356,14 +356,14 @@ describe('Observable.prototype.concatMapTo()', () => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([8,8,8,8]); + expect(results).toEqual([8, 8, 8, 8]); (expect(resultSelectorCalledWith)).toDeepEqual(expectedCalls); done(); }); }); it('should concatMapTo values to rejected promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const inner = Observable.from(Promise.reject(42)); const resultSelector = () => { throw 'this should not be called'; diff --git a/spec/operators/debounce-spec.ts b/spec/operators/debounce-spec.ts index 2583334f100..bb385ba6843 100644 --- a/spec/operators/debounce-spec.ts +++ b/spec/operators/debounce-spec.ts @@ -353,7 +353,7 @@ describe('Observable.prototype.debounce()', () => { Observable.timer(10).mapTo(3), Observable.timer(100).mapTo(4) ); - const expected = [1,2,3,4]; + const expected = [1, 2, 3, 4]; e1.debounce(() => { return new Promise((resolve: any) => { resolve(42); }); @@ -372,14 +372,14 @@ describe('Observable.prototype.debounce()', () => { Observable.timer(10).mapTo(3), Observable.timer(100).mapTo(4) ); - const expected = [1,2]; + const expected = [1, 2]; const error = new Error('error'); e1.debounce((x: number) => { if (x === 3) { - return new Promise((resolve: any, reject: any) => {reject(error);}); + return new Promise((resolve: any, reject: any) => { reject(error); }); } else { - return new Promise((resolve: any) => {resolve(42);}); + return new Promise((resolve: any) => { resolve(42); }); } }).subscribe((x: number) => { expect(x).toEqual(expected.shift()); }, diff --git a/spec/operators/delayWhen-spec.ts b/spec/operators/delayWhen-spec.ts index 6cd77adac5a..d56dae56cae 100644 --- a/spec/operators/delayWhen-spec.ts +++ b/spec/operators/delayWhen-spec.ts @@ -3,7 +3,6 @@ import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marbl import {it, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; -const Observable = Rx.Observable; describe('Observable.prototype.delayWhen()', () => { asDiagram('delay(durationSelector)')('should delay by duration selector', () => { diff --git a/spec/operators/do-spec.ts b/spec/operators/do-spec.ts index 8e277a99b6c..c292b1f6acc 100644 --- a/spec/operators/do-spec.ts +++ b/spec/operators/do-spec.ts @@ -39,10 +39,10 @@ describe('Observable.prototype.do()', () => { }); it('should handle everything with an observer', () => { - const expected = [1,2,3]; + const expected = [1, 2, 3]; const results = []; let completeCalled = false; - Observable.of(1,2,3) + Observable.of(1, 2, 3) .do({ next: (x: number) => { results.push(x); @@ -61,7 +61,7 @@ describe('Observable.prototype.do()', () => { }); it('should handle everything with a Subject', () => { - const expected = [1,2,3]; + const expected = [1, 2, 3]; const results = []; let completeCalled = false; const subject = new Subject(); @@ -78,7 +78,7 @@ describe('Observable.prototype.do()', () => { } }); - Observable.of(1,2,3) + Observable.of(1, 2, 3) .do(subject) .subscribe(); diff --git a/spec/operators/elementAt-spec.ts b/spec/operators/elementAt-spec.ts index ff44e4f564e..0ba8565fe4e 100644 --- a/spec/operators/elementAt-spec.ts +++ b/spec/operators/elementAt-spec.ts @@ -96,7 +96,7 @@ describe('Observable.prototype.elementAt', () => { }); it('should throw if index is smaller than zero', () => { - expect(() => { (Observable.range(0,10)).elementAt(-1); }) + expect(() => { (Observable.range(0, 10)).elementAt(-1); }) .toThrow(new Rx.ArgumentOutOfRangeError()); }); diff --git a/spec/operators/every-spec.ts b/spec/operators/every-spec.ts index d8eea2810e3..febaa971c51 100644 --- a/spec/operators/every-spec.ts +++ b/spec/operators/every-spec.ts @@ -35,7 +35,7 @@ describe('Observable.prototype.every()', () => { it('should accept thisArg with array observables', () => { const thisArg = {}; - Observable.of(1,2,3,4).every(function (value: number, index: number) { + Observable.of(1, 2, 3, 4).every(function (value: number, index: number) { expect(this).toBe(thisArg); return true; }, thisArg).subscribe(); diff --git a/spec/operators/exhaust-spec.ts b/spec/operators/exhaust-spec.ts index 4452aba1285..a5954ed134b 100644 --- a/spec/operators/exhaust-spec.ts +++ b/spec/operators/exhaust-spec.ts @@ -3,7 +3,6 @@ import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marbl import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; -const queueScheduler = Rx.Scheduler.queue; describe('Observable.prototype.exhaust()', () => { asDiagram('exhaust')('should handle a hot observable of hot observables', () => { diff --git a/spec/operators/exhaustMap-spec.ts b/spec/operators/exhaustMap-spec.ts index c2454d15a5e..634cc46edf6 100644 --- a/spec/operators/exhaustMap-spec.ts +++ b/spec/operators/exhaustMap-spec.ts @@ -1,19 +1,18 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, asDiagram} from '../helpers/test-helper'; +import {it} from '../helpers/test-helper'; const Observable = Rx.Observable; -const queueScheduler = Rx.Scheduler.queue; describe('Observable.prototype.exhaustMap()', () => { it('should handle outer throw', () => { - var x = cold('--a--b--c--|'); - var xsubs = []; - var e1 = cold('#'); - var e1subs = '(^!)'; - var expected = '#'; + const x = cold('--a--b--c--|'); + const xsubs = []; + const e1 = cold('#'); + const e1subs = '(^!)'; + const expected = '#'; - var result = (e1).exhaustMap(() => x); + const result = (e1).exhaustMap(() => x); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -21,26 +20,26 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should handle outer empty', () => { - var x = cold('--a--b--c--|'); - var xsubs = []; - var e1 = cold('|'); - var e1subs = '(^!)'; - var expected = '|'; + const x = cold('--a--b--c--|'); + const xsubs = []; + const e1 = cold('|'); + const e1subs = '(^!)'; + const expected = '|'; - var result = (e1).exhaustMap(() => x); + const result = (e1).exhaustMap(() => x); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); expectSubscriptions(e1.subscriptions).toBe(e1subs); }); it('should handle outer never', () => { - var x = cold('--a--b--c--|'); - var xsubs = []; - var e1 = cold('-'); - var e1subs = '^'; - var expected = '-'; + const x = cold('--a--b--c--|'); + const xsubs = []; + const e1 = cold('-'); + const e1subs = '^'; + const expected = '-'; - var result = (e1).exhaustMap(() => x); + const result = (e1).exhaustMap(() => x); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -48,11 +47,11 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should raise error if project throws', () => { - var e1 = hot('---x---------y-----------------z-------------|'); - var e1subs = '^ !'; - var expected = '---#'; + const e1 = hot('---x---------y-----------------z-------------|'); + const e1subs = '^ !'; + const expected = '---#'; - var result = (e1).exhaustMap((value: any) => { + const result = (e1).exhaustMap((value: any) => { throw 'error'; }); @@ -61,13 +60,13 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should raise error if selector throws', () => { - var x = cold( '--a--b--c--| '); - var xsubs = ' ^ ! '; - var e1 = hot('---x---------y----z----|'); - var e1subs = '^ ! '; - var expected = '-----# '; + const x = cold( '--a--b--c--| '); + const xsubs = ' ^ ! '; + const e1 = hot('---x---------y----z----|'); + const e1subs = '^ ! '; + const expected = '-----# '; - var result = (e1).exhaustMap((value: any) => x, + const result = (e1).exhaustMap((value: any) => x, () => { throw 'error'; }); @@ -78,19 +77,19 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch with a selector function', () => { - var x = cold( '--a--b--c--| '); - var xsubs = ' ^ ! '; - var y = cold( '--d--e--f--| '); - var ysubs = []; - var z = cold( '--g--h--i--| '); - var zsubs = ' ^ ! '; - var e1 = hot('---x---------y-----------------z-------------|'); - var e1subs = '^ !'; - var expected = '-----a--b--c---------------------g--h--i-----|'; + const x = cold( '--a--b--c--| '); + const xsubs = ' ^ ! '; + const y = cold( '--d--e--f--| '); + const ysubs = []; + const z = cold( '--g--h--i--| '); + const zsubs = ' ^ ! '; + const e1 = hot('---x---------y-----------------z-------------|'); + const e1subs = '^ !'; + const expected = '-----a--b--c---------------------g--h--i-----|'; - var observableLookup = { x: x, y: y, z: z }; + const observableLookup = { x: x, y: y, z: z }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -100,20 +99,20 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch inner cold observables, outer is unsubscribed early', () => { - var x = cold( '--a--b--c--| '); - var xsubs = ' ^ ! '; - var y = cold( '--d--e--f--| '); - var ysubs = []; - var z = cold( '--g--h--i--| '); - var zsubs = ' ^ ! '; - var e1 = hot('---x---------y-----------------z-------------|'); - var unsub = ' ! '; - var e1subs = '^ ! '; - var expected = '-----a--b--c---------------------g- '; + const x = cold( '--a--b--c--| '); + const xsubs = ' ^ ! '; + const y = cold( '--d--e--f--| '); + const ysubs = []; + const z = cold( '--g--h--i--| '); + const zsubs = ' ^ ! '; + const e1 = hot('---x---------y-----------------z-------------|'); + const unsub = ' ! '; + const e1subs = '^ ! '; + const expected = '-----a--b--c---------------------g- '; - var observableLookup = { x: x, y: y, z: z }; + const observableLookup = { x: x, y: y, z: z }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result, unsub).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -123,20 +122,20 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should not break unsubscription chains when result is unsubscribed explicitly', () => { - var x = cold( '--a--b--c--| '); - var xsubs = ' ^ ! '; - var y = cold( '--d--e--f--| '); - var ysubs = []; - var z = cold( '--g--h--i--| '); - var zsubs = ' ^ ! '; - var e1 = hot('---x---------y-----------------z-------------|'); - var e1subs = '^ ! '; - var expected = '-----a--b--c---------------------g- '; - var unsub = ' ! '; - - var observableLookup = { x: x, y: y, z: z }; - - var result = (e1) + const x = cold( '--a--b--c--| '); + const xsubs = ' ^ ! '; + const y = cold( '--d--e--f--| '); + const ysubs = []; + const z = cold( '--g--h--i--| '); + const zsubs = ' ^ ! '; + const e1 = hot('---x---------y-----------------z-------------|'); + const e1subs = '^ ! '; + const expected = '-----a--b--c---------------------g- '; + const unsub = ' ! '; + + const observableLookup = { x: x, y: y, z: z }; + + const result = (e1) .mergeMap((x: any) => Observable.of(x)) .exhaustMap((value: any) => observableLookup[value]) .mergeMap((x: any) => Observable.of(x)); @@ -149,19 +148,19 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch inner cold observables, inner never completes', () => { - var x = cold( '--a--b--c--| '); - var xsubs = ' ^ ! '; - var y = cold( '--d--e--f--| '); - var ysubs = []; - var z = cold( '--g--h--i-----'); - var zsubs = ' ^ '; - var e1 = hot('---x---------y-----------------z---------| '); - var e1subs = '^ '; - var expected = '-----a--b--c---------------------g--h--i-----'; + const x = cold( '--a--b--c--| '); + const xsubs = ' ^ ! '; + const y = cold( '--d--e--f--| '); + const ysubs = []; + const z = cold( '--g--h--i-----'); + const zsubs = ' ^ '; + const e1 = hot('---x---------y-----------------z---------| '); + const e1subs = '^ '; + const expected = '-----a--b--c---------------------g--h--i-----'; - var observableLookup = { x: x, y: y, z: z }; + const observableLookup = { x: x, y: y, z: z }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -171,17 +170,17 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should handle a synchronous switch an stay on the first inner observable', () => { - var x = cold( '--a--b--c--d--e--| '); - var xsubs = ' ^ ! '; - var y = cold( '---f---g---h---i--| '); - var ysubs = []; - var e1 = hot('---------(xy)----------------|'); - var e1subs = '^ !'; - var expected = '-----------a--b--c--d--e-----|'; + const x = cold( '--a--b--c--d--e--| '); + const xsubs = ' ^ ! '; + const y = cold( '---f---g---h---i--| '); + const ysubs = []; + const e1 = hot('---------(xy)----------------|'); + const e1subs = '^ !'; + const expected = '-----------a--b--c--d--e-----|'; - var observableLookup = { x: x, y: y }; + const observableLookup = { x: x, y: y }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -190,17 +189,17 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch inner cold observables, one inner throws', () => { - var x = cold( '--a--b--c--d--# '); - var xsubs = ' ^ ! '; - var y = cold( '---f---g---h---i--'); - var ysubs = []; - var e1 = hot('---------x---------y---------| '); - var e1subs = '^ ! '; - var expected = '-----------a--b--c--d--# '; + const x = cold( '--a--b--c--d--# '); + const xsubs = ' ^ ! '; + const y = cold( '---f---g---h---i--'); + const ysubs = []; + const e1 = hot('---------x---------y---------| '); + const e1subs = '^ ! '; + const expected = '-----------a--b--c--d--# '; - var observableLookup = { x: x, y: y }; + const observableLookup = { x: x, y: y }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -209,19 +208,19 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch inner hot observables', () => { - var x = hot('-----a--b--c--d--e--| '); - var xsubs = ' ^ ! '; - var y = hot('--p-o-o-p-------f---g---h---i--| '); - var ysubs = []; - var z = hot('---z-o-o-m-------------j---k---l---m--|'); - var zsubs = ' ^ !'; - var e1 = hot('---------x----y-----z--------| '); - var e1subs = '^ !'; - var expected = '-----------c--d--e-----j---k---l---m--|'; + const x = hot('-----a--b--c--d--e--| '); + const xsubs = ' ^ ! '; + const y = hot('--p-o-o-p-------f---g---h---i--| '); + const ysubs = []; + const z = hot('---z-o-o-m-------------j---k---l---m--|'); + const zsubs = ' ^ !'; + const e1 = hot('---------x----y-----z--------| '); + const e1subs = '^ !'; + const expected = '-----------c--d--e-----j---k---l---m--|'; - var observableLookup = { x: x, y: y, z: z }; + const observableLookup = { x: x, y: y, z: z }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -231,17 +230,17 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch inner empty and empty', () => { - var x = cold('|'); - var y = cold('|'); - var xsubs = ' (^!) '; - var ysubs = ' (^!) '; - var e1 = hot('---------x---------y---------|'); - var e1subs = '^ !'; - var expected = '-----------------------------|'; + const x = cold('|'); + const y = cold('|'); + const xsubs = ' (^!) '; + const ysubs = ' (^!) '; + const e1 = hot('---------x---------y---------|'); + const e1subs = '^ !'; + const expected = '-----------------------------|'; - var observableLookup = { x: x, y: y }; + const observableLookup = { x: x, y: y }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -250,17 +249,17 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch inner empty and never', () => { - var x = cold('|'); - var y = cold('-'); - var xsubs = ' (^!) '; - var ysubs = ' ^ '; - var e1 = hot('---------x---------y---------|'); - var e1subs = '^ '; - var expected = '------------------------------'; + const x = cold('|'); + const y = cold('-'); + const xsubs = ' (^!) '; + const ysubs = ' ^ '; + const e1 = hot('---------x---------y---------|'); + const e1subs = '^ '; + const expected = '------------------------------'; - var observableLookup = { x: x, y: y }; + const observableLookup = { x: x, y: y }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -269,17 +268,17 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should never switch inner never', () => { - var x = cold('-'); - var y = cold('#'); - var xsubs = ' ^ '; - var ysubs = []; - var e1 = hot('---------x---------y----------|'); - var e1subs = '^ '; - var expected = '-------------------------------'; + const x = cold('-'); + const y = cold('#'); + const xsubs = ' ^ '; + const ysubs = []; + const e1 = hot('---------x---------y----------|'); + const e1subs = '^ '; + const expected = '-------------------------------'; - var observableLookup = { x: x, y: y }; + const observableLookup = { x: x, y: y }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -288,17 +287,17 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch inner empty and throw', () => { - var x = cold('|'); - var y = cold('#'); - var xsubs = ' (^!) '; - var ysubs = ' (^!) '; - var e1 = hot('---------x---------y---------|'); - var e1subs = '^ ! '; - var expected = '-------------------# '; + const x = cold('|'); + const y = cold('#'); + const xsubs = ' (^!) '; + const ysubs = ' (^!) '; + const e1 = hot('---------x---------y---------|'); + const e1subs = '^ ! '; + const expected = '-------------------# '; - var observableLookup = { x: x, y: y }; + const observableLookup = { x: x, y: y }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -307,15 +306,15 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should handle outer error', () => { - var x = cold( '--a--b--c--d--e--|'); - var xsubs = ' ^ ! '; - var e1 = hot('---------x---------# '); - var e1subs = '^ ! '; - var expected = '-----------a--b--c-# '; + const x = cold( '--a--b--c--d--e--|'); + const xsubs = ' ^ ! '; + const e1 = hot('---------x---------# '); + const e1subs = '^ ! '; + const expected = '-----------a--b--c-# '; - var observableLookup = { x: x }; + const observableLookup = { x: x }; - var result = (e1).exhaustMap((value: any) => observableLookup[value]); + const result = (e1).exhaustMap((value: any) => observableLookup[value]); expectObservable(result).toBe(expected); expectSubscriptions(x.subscriptions).toBe(xsubs); @@ -323,19 +322,19 @@ describe('Observable.prototype.exhaustMap()', () => { }); it('should switch with resultSelector goodness', () => { - var x = cold( '--a--b--c--d--e-| '); - var xsubs = ' ^ ! '; - var y = cold( '---f---g---h---i--| '); - var ysubs = []; - var z = cold( '---k---l---m---n--|'); - var zsubs = ' ^ !'; - var e1 = hot('--x---------y------z-| '); - var e1subs = '^ !'; - var expected = '----a--b--c--d--e-----k---l---m---n--|'; - - var observableLookup = { x: x, y: y, z: z }; - - var expectedValues = { + const x = cold( '--a--b--c--d--e-| '); + const xsubs = ' ^ ! '; + const y = cold( '---f---g---h---i--| '); + const ysubs = []; + const z = cold( '---k---l---m---n--|'); + const zsubs = ' ^ !'; + const e1 = hot('--x---------y------z-| '); + const e1subs = '^ !'; + const expected = '----a--b--c--d--e-----k---l---m---n--|'; + + const observableLookup = { x: x, y: y, z: z }; + + const expectedValues = { a: ['x', 'a', 0, 0], b: ['x', 'b', 0, 1], c: ['x', 'c', 0, 2], @@ -347,7 +346,7 @@ describe('Observable.prototype.exhaustMap()', () => { n: ['z', 'n', 1, 3], }; - var result = (e1).exhaustMap((value: any) => observableLookup[value], + const result = (e1).exhaustMap((value: any) => observableLookup[value], (innerValue, outerValue, innerIndex, outerIndex) => [innerValue, outerValue, innerIndex, outerIndex]); expectObservable(result).toBe(expected, expectedValues); diff --git a/spec/operators/groupBy-spec.ts b/spec/operators/groupBy-spec.ts index 480be27f26b..84c1647fbe5 100644 --- a/spec/operators/groupBy-spec.ts +++ b/spec/operators/groupBy-spec.ts @@ -100,7 +100,6 @@ describe('Observable.prototype.groupBy()', () => { const source = e1 .groupBy((val: string) => val.toLowerCase().trim()); - expectObservable(source).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); }); @@ -608,7 +607,9 @@ describe('Observable.prototype.groupBy()', () => { rxTestScheduler.schedule(() => { expectObservable(group).toBe(expected); }, 260); - }, () => {}); + }, () => { + //noop + }); expectSubscriptions(e1.subscriptions).toBe(subs); }); diff --git a/spec/operators/inspect-spec.ts b/spec/operators/inspect-spec.ts index 116e1ddc69a..0bf3782ef46 100644 --- a/spec/operators/inspect-spec.ts +++ b/spec/operators/inspect-spec.ts @@ -3,7 +3,6 @@ import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marbl import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; -const Scheduler = Rx.Scheduler; describe('Observable.prototype.inspect()', () => { asDiagram('inspect')('should emit the last value in each time window', () => { @@ -286,7 +285,7 @@ describe('Observable.prototype.inspect()', () => { it('should inspect by promise resolves', (done: DoneSignature) => { const e1 = Observable.interval(10).take(5); - const expected = [0,1,2,3]; + const expected = [0, 1, 2, 3]; e1.inspect(() => { return new Promise((resolve: any) => { resolve(42); }); @@ -305,14 +304,14 @@ describe('Observable.prototype.inspect()', () => { it('should raise error when promise rejects', (done: DoneSignature) => { const e1 = Observable.interval(10).take(10); - const expected = [0,1,2]; + const expected = [0, 1, 2]; const error = new Error('error'); e1.inspect((x: number) => { if (x === 3) { - return new Promise((resolve: any, reject: any) => {reject(error);}); + return new Promise((resolve: any, reject: any) => { reject(error); }); } else { - return new Promise((resolve: any) => {resolve(42);}); + return new Promise((resolve: any) => { resolve(42); }); } }).subscribe( (x: number) => { diff --git a/spec/operators/inspectTime-spec.ts b/spec/operators/inspectTime-spec.ts index c226e62be6d..793d1829a71 100644 --- a/spec/operators/inspectTime-spec.ts +++ b/spec/operators/inspectTime-spec.ts @@ -4,7 +4,6 @@ import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; const Observable = Rx.Observable; -const Scheduler = Rx.Scheduler; describe('Observable.prototype.inspectTime()', () => { asDiagram('inspectTime(50)')('should emit the last value in each time window', () => { diff --git a/spec/operators/let-spec.ts b/spec/operators/let-spec.ts index 01477498781..950d81750ad 100644 --- a/spec/operators/let-spec.ts +++ b/spec/operators/let-spec.ts @@ -9,7 +9,7 @@ describe('let', () => { const foo = (observable: Rx.Observable) => observable.map((x: string) => x + x); Rx.Observable - .fromArray(['a','b']) + .fromArray(['a', 'b']) .let(foo) .subscribe(function (x) { expect(x).toBe(expected[i++]); diff --git a/spec/operators/map-spec.ts b/spec/operators/map-spec.ts index ca1de2af781..85b496e07fa 100644 --- a/spec/operators/map-spec.ts +++ b/spec/operators/map-spec.ts @@ -229,9 +229,9 @@ describe('Observable.prototype.map()', () => { const filterer = new Filterer(); const r = a - .map(function (x) { return this.selector1(x);}, filterer) - .map(function (x) { return this.selector2(x);}, filterer) - .map(function (x) { return this.selector1(x);}, filterer); + .map(function (x) { return this.selector1(x); }, filterer) + .map(function (x) { return this.selector2(x); }, filterer) + .map(function (x) { return this.selector1(x); }, filterer); expectObservable(r).toBe(expected, values); expectSubscriptions(a.subscriptions).toBe(asubs); diff --git a/spec/operators/mergeMap-spec.ts b/spec/operators/mergeMap-spec.ts index 2a2efa899ca..ef00fa64f5a 100644 --- a/spec/operators/mergeMap-spec.ts +++ b/spec/operators/mergeMap-spec.ts @@ -22,7 +22,7 @@ describe('Observable.prototype.mergeMap()', () => { }); it('should map values to constant resolved promises and merge', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = (value: any) => Observable.from(Promise.resolve(42)); const results = []; @@ -34,13 +34,13 @@ describe('Observable.prototype.mergeMap()', () => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([42,42,42,42]); + expect(results).toEqual([42, 42, 42, 42]); done(); }); }); it('should map values to constant rejected promises and merge', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = function (value) { return Observable.from(Promise.reject(42)); }; @@ -59,7 +59,7 @@ describe('Observable.prototype.mergeMap()', () => { }); it('should map values to resolved promises and merge', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = function (value, index) { return Observable.from(Promise.resolve(value + index)); }; @@ -73,13 +73,13 @@ describe('Observable.prototype.mergeMap()', () => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([4,4,4,4]); + expect(results).toEqual([4, 4, 4, 4]); done(); }); }); it('should map values to rejected promises and merge', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = function (value, index) { return Observable.from(Promise.reject('' + value + '-' + index)); }; @@ -98,7 +98,7 @@ describe('Observable.prototype.mergeMap()', () => { }); it('should mergeMap values to resolved promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const resultSelectorCalledWith = []; const project = function (value, index) { return Observable.from(Promise.resolve([value, index])); @@ -110,10 +110,10 @@ describe('Observable.prototype.mergeMap()', () => { const results = []; const expectedCalls = [ - [4, [4,0], 0, 0], - [3, [3,1], 1, 0], - [2, [2,2], 2, 0], - [1, [1,3], 3, 0], + [4, [4, 0], 0, 0], + [3, [3, 1], 1, 0], + [2, [2, 2], 2, 0], + [1, [1, 3], 3, 0], ]; source.mergeMap(project, resultSelector).subscribe( (x: number) => { @@ -123,14 +123,14 @@ describe('Observable.prototype.mergeMap()', () => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([8,8,8,8]); + expect(results).toEqual([8, 8, 8, 8]); (expect(resultSelectorCalledWith)).toDeepEqual(expectedCalls); done(); }); }); it('should mergeMap values to rejected promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const project = function (value, index) { return Observable.from(Promise.reject('' + value + '-' + index)); }; @@ -522,7 +522,7 @@ describe('Observable.prototype.mergeMap()', () => { const expected = '(44)--(8888)---(666)----(44)----|'; const source = e1.mergeMap((value: any) => arrayRepeat(value, value), - (x: string, y: string) =>String(parseInt(x) + parseInt(y))); + (x: string, y: string) => String(parseInt(x) + parseInt(y))); expectObservable(source).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); @@ -545,7 +545,7 @@ describe('Observable.prototype.mergeMap()', () => { const expected = '(44)--(8888)---(666)----(44)----#'; const source = e1.mergeMap((value: any) => arrayRepeat(value, value), - (x: string, y: string) =>String(parseInt(x) + parseInt(y))); + (x: string, y: string) => String(parseInt(x) + parseInt(y))); expectObservable(source).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); @@ -570,7 +570,7 @@ describe('Observable.prototype.mergeMap()', () => { const expected = '(44)--(8888)-- '; const source = e1.mergeMap((value: any) => arrayRepeat(value, value), - (x: string, y: string) =>String(parseInt(x) + parseInt(y))); + (x: string, y: string) => String(parseInt(x) + parseInt(y))); expectObservable(source, unsub).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); @@ -637,7 +637,7 @@ describe('Observable.prototype.mergeMap()', () => { const expected = ['1!', '2!', '3!', '4!']; let completed = false; - const sub = source.subscribe((x: string) => { + source.subscribe((x: string) => { expect(x).toBe(expected.shift()); }, null, () => { expect(expected.length).toBe(0); @@ -653,7 +653,7 @@ describe('Observable.prototype.mergeMap()', () => { const expected = ['1!', '2!', '3!', '4!']; let completed = false; - const sub = source.subscribe((x: string) => { + source.subscribe((x: string) => { expect(x).toBe(expected.shift()); }, null, () => { expect(expected.length).toBe(0); diff --git a/spec/operators/mergeMapTo-spec.ts b/spec/operators/mergeMapTo-spec.ts index 28eadd9c6be..ce2eec50844 100644 --- a/spec/operators/mergeMapTo-spec.ts +++ b/spec/operators/mergeMapTo-spec.ts @@ -26,7 +26,7 @@ describe('Observable.prototype.mergeMapTo()', () => { }); it('should map values to constant resolved promises and merge', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const results = []; source.mergeMapTo(Observable.from(Promise.resolve(42))).subscribe( @@ -37,13 +37,13 @@ describe('Observable.prototype.mergeMapTo()', () => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([42,42,42,42]); + expect(results).toEqual([42, 42, 42, 42]); done(); }); }); it('should map values to constant rejected promises and merge', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); source.mergeMapTo(Observable.from(Promise.reject(42))).subscribe( (x: any) => { @@ -59,7 +59,7 @@ describe('Observable.prototype.mergeMapTo()', () => { }); it('should mergeMapTo values to resolved promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const resultSelectorCalledWith = []; const inner = Observable.from(Promise.resolve(42)); const resultSelector = function (outerVal, innerVal, outerIndex, innerIndex) { @@ -82,14 +82,14 @@ describe('Observable.prototype.mergeMapTo()', () => { done.fail('Subscriber error handler not supposed to be called.'); }, () => { - expect(results).toEqual([8,8,8,8]); + expect(results).toEqual([8, 8, 8, 8]); (expect(resultSelectorCalledWith)).toDeepEqual(expectedCalls); done(); }); }); it('should mergeMapTo values to rejected promises with resultSelector', (done: DoneSignature) => { - const source = Rx.Observable.from([4,3,2,1]); + const source = Rx.Observable.from([4, 3, 2, 1]); const inner = Observable.from(Promise.reject(42)); const resultSelector = () => { throw 'this should not be called'; @@ -376,7 +376,7 @@ describe('Observable.prototype.mergeMapTo()', () => { const expected = ['!', '!', '!', '!']; let completed = false; - const sub = source.subscribe((x: string) => { + source.subscribe((x: string) => { expect(x).toBe(expected.shift()); }, null, () => { expect(expected.length).toBe(0); @@ -392,7 +392,7 @@ describe('Observable.prototype.mergeMapTo()', () => { const expected = ['!', '!', '!', '!']; let completed = false; - const sub = source.subscribe((x: string) => { + source.subscribe((x: string) => { expect(x).toBe(expected.shift()); }, null, () => { expect(expected.length).toBe(0); diff --git a/spec/operators/multicast-spec.ts b/spec/operators/multicast-spec.ts index 91a69e76ff8..40a021ed2ca 100644 --- a/spec/operators/multicast-spec.ts +++ b/spec/operators/multicast-spec.ts @@ -19,9 +19,9 @@ describe('Observable.prototype.multicast()', () => { }); it('should accept Subjects', (done: DoneSignature) => { - const expected = [1,2,3,4]; + const expected = [1, 2, 3, 4]; - const connectable = Observable.of(1,2,3,4).multicast(new Subject()); + const connectable = Observable.of(1, 2, 3, 4).multicast(new Subject()); connectable.subscribe((x: number) => { expect(x).toBe(expected.shift()); }, done.fail, @@ -31,9 +31,9 @@ describe('Observable.prototype.multicast()', () => { }); it('should accept Subject factory functions', (done: DoneSignature) => { - const expected = [1,2,3,4]; + const expected = [1, 2, 3, 4]; - const connectable = Observable.of(1,2,3,4).multicast(() => { + const connectable = Observable.of(1, 2, 3, 4).multicast(() => { return new Subject(); }); @@ -514,7 +514,7 @@ describe('Observable.prototype.multicast()', () => { const expected = ['a1', 'a2', 'a3', 'b1', 'b2', 'b3', 'c1', 'c2', 'c3']; Observable.of('a', 'b', 'c') - .switchMap((letter: string) => source.map((n :number) => String(letter + n))) + .switchMap((letter: string) => source.map((n: number) => String(letter + n))) .subscribe((x: string) => { expect(x).toBe(expected.shift()); }, done.fail, () => { @@ -555,7 +555,7 @@ describe('Observable.prototype.multicast()', () => { const expected = ['a1', 'a2', 'a3']; Observable.of('a', 'b', 'c') - .switchMap((letter: string) => source.map((n :number) => String(letter + n))) + .switchMap((letter: string) => source.map((n: number) => String(letter + n))) .subscribe((x: string) => { expect(x).toBe(expected.shift()); }, done.fail, () => { diff --git a/spec/operators/observeOn-spec.ts b/spec/operators/observeOn-spec.ts index f80ec64e800..edeb99b7a90 100644 --- a/spec/operators/observeOn-spec.ts +++ b/spec/operators/observeOn-spec.ts @@ -1,5 +1,5 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; +import {hot, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; @@ -72,7 +72,7 @@ describe('Observable.prototype.observeOn()', () => { const result = e1 .mergeMap((x: string) => Observable.of(x)) .observeOn(rxTestScheduler) - .mergeMap((x: string) => Observable.of(x)) + .mergeMap((x: string) => Observable.of(x)); expectObservable(result, unsub).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(sub); diff --git a/spec/operators/pairwise-spec.ts b/spec/operators/pairwise-spec.ts index 5f2a39fa344..cf47fa0f9a7 100644 --- a/spec/operators/pairwise-spec.ts +++ b/spec/operators/pairwise-spec.ts @@ -1,9 +1,6 @@ -import * as Rx from '../../dist/cjs/Rx.KitchenSink'; import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it} from '../helpers/test-helper'; -const Observable = Rx.Observable; - describe('Observable.prototype.pairwise()', () => { it('should pairwise things', () => { const e1 = hot('--a--^--b--c--d--e--f--g--|'); diff --git a/spec/operators/pluck-spec.ts b/spec/operators/pluck-spec.ts index e5c183dfaf4..3d8f2fc7a2a 100644 --- a/spec/operators/pluck-spec.ts +++ b/spec/operators/pluck-spec.ts @@ -1,5 +1,5 @@ import * as Rx from '../../dist/cjs/Rx'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; +import {cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it} from '../helpers/test-helper'; const Observable = Rx.Observable; @@ -146,7 +146,7 @@ describe('Observable.prototype.pluck()', () => { const r = a .mergeMap((x: string) => Observable.of(x)) .pluck('prop') - .mergeMap((x: string) => Observable.of(x)) + .mergeMap((x: string) => Observable.of(x)); expectObservable(r, unsub).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); diff --git a/spec/operators/publish-spec.ts b/spec/operators/publish-spec.ts index 80d370d2a65..5fd8b4e8d3e 100644 --- a/spec/operators/publish-spec.ts +++ b/spec/operators/publish-spec.ts @@ -3,7 +3,6 @@ import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marbl import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; -const Subject = Rx.Subject; describe('Observable.prototype.publish()', () => { asDiagram('publish')('should mirror a simple source Observable', () => { diff --git a/spec/operators/publishLast-spec.ts b/spec/operators/publishLast-spec.ts index 624838627b0..e336206533f 100644 --- a/spec/operators/publishLast-spec.ts +++ b/spec/operators/publishLast-spec.ts @@ -3,7 +3,6 @@ import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marbl import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; -const Subject = Rx.Subject; describe('Observable.prototype.publishLast()', () => { asDiagram('publishLast')('should emit last notification of a simple source Observable', () => { diff --git a/spec/operators/race-spec.ts b/spec/operators/race-spec.ts index dfa7222839d..57bed6b5226 100644 --- a/spec/operators/race-spec.ts +++ b/spec/operators/race-spec.ts @@ -101,7 +101,7 @@ describe('...race(observables)', () => { const result = e1 .mergeMap((x: string) => Observable.of(x)) .race(e2) - .mergeMap((x: string) => Observable.of(x)) + .mergeMap((x: string) => Observable.of(x)); expectObservable(result, unsub).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); diff --git a/spec/operators/refCount-spec.ts b/spec/operators/refCount-spec.ts index 6c4c95c9331..52bdbe312cf 100644 --- a/spec/operators/refCount-spec.ts +++ b/spec/operators/refCount-spec.ts @@ -1,9 +1,8 @@ import * as Rx from '../../dist/cjs/Rx'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; +import {cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; -const Subject = Rx.Subject; describe('Observable.prototype.publish().refCount()', () => { asDiagram('refCount')('should turn a multicasted Observable an automatically ' + @@ -21,9 +20,12 @@ describe('Observable.prototype.publish().refCount()', () => { it('should count references', () => { const source = Observable.never().publish().refCount(); - const sub1 = source.subscribe({ next: () => { } }); - const sub2 = source.subscribe({ next: () => { } }); - const sub3 = source.subscribe({ next: () => { } }); + const sub1 = source.subscribe({ next: function () { //noop + } }); + const sub2 = source.subscribe({ next: function () { //noop + } }); + const sub3 = source.subscribe({ next: function () { //noop + } }); expect((source).refCount).toBe(3); @@ -42,8 +44,12 @@ describe('Observable.prototype.publish().refCount()', () => { }; }).publish().refCount(); - const sub1 = source.subscribe(() => {}); - const sub2 = source.subscribe(() => {}); + const sub1 = source.subscribe(() => { + //noop + }); + const sub2 = source.subscribe(() => { + //noop + }); const sub3 = source.subscribe((x: any) => { expect((source).refCount).toBe(1); }); diff --git a/spec/operators/repeat-spec.ts b/spec/operators/repeat-spec.ts index 739cbde7289..7c6cd81511e 100644 --- a/spec/operators/repeat-spec.ts +++ b/spec/operators/repeat-spec.ts @@ -1,5 +1,5 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; +import {cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; @@ -222,7 +222,11 @@ describe('Observable.prototype.repeat()', () => { it('should terminate repeat and throw if source subscription to _complete throws', () => { const e1 = Observable.of(1, 2, rxTestScheduler); - e1.subscribe(() => {}, () => {}, () => { throw new Error('error'); }); + e1.subscribe(() => { + //noop + }, () => { + //noop + }, () => { throw new Error('error'); }); expect(() => { e1.repeat(3); @@ -242,7 +246,11 @@ describe('Observable.prototype.repeat()', () => { it('should terminate repeat and throw if source subscription to _complete throws when repeating infinitely', () => { const e1 = Observable.of(1, 2, rxTestScheduler); - e1.subscribe(() => {}, () => {}, () => { throw new Error('error'); }); + e1.subscribe(() => { + //noop + }, () => { + //noop + }, () => { throw new Error('error'); }); expect(() => { e1.repeat(); diff --git a/spec/operators/sample-spec.ts b/spec/operators/sample-spec.ts index 48cf5858933..2c192fbea8a 100644 --- a/spec/operators/sample-spec.ts +++ b/spec/operators/sample-spec.ts @@ -1,5 +1,5 @@ import * as Rx from '../../dist/cjs/Rx'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; +import {hot, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; diff --git a/spec/operators/single-spec.ts b/spec/operators/single-spec.ts index d758c99ecd2..d3fb594bcaa 100644 --- a/spec/operators/single-spec.ts +++ b/spec/operators/single-spec.ts @@ -1,5 +1,5 @@ import * as Rx from '../../dist/cjs/Rx'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; +import {hot, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it, asDiagram} from '../helpers/test-helper'; const Observable = Rx.Observable; diff --git a/spec/operators/startWith-spec.ts b/spec/operators/startWith-spec.ts index cb23c0b4ff4..cf07f2493d2 100644 --- a/spec/operators/startWith-spec.ts +++ b/spec/operators/startWith-spec.ts @@ -1,6 +1,6 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; +import {it, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; const Observable = Rx.Observable; @@ -76,7 +76,7 @@ describe('Observable.prototype.startWith()', () => { const e1subs = '^ !'; const expected = '(yz)-a--|'; - expectObservable((e1).startWith('y','z')).toBe(expected); + expectObservable((e1).startWith('y', 'z')).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); }); @@ -150,7 +150,7 @@ describe('Observable.prototype.startWith()', () => { const e1subs = '^ !'; const expected = '(yz)-a--|'; - expectObservable((e1).startWith('y','z', rxTestScheduler)).toBe(expected); + expectObservable((e1).startWith('y', 'z', rxTestScheduler)).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); }); }); diff --git a/spec/operators/subscribeOn-spec.ts b/spec/operators/subscribeOn-spec.ts index b26bd0dfabf..2b5df4074ca 100644 --- a/spec/operators/subscribeOn-spec.ts +++ b/spec/operators/subscribeOn-spec.ts @@ -1,5 +1,5 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; +import {hot, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; import {it, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; diff --git a/spec/operators/switch-spec.ts b/spec/operators/switch-spec.ts index 4c736222db2..7b9b0ae8525 100644 --- a/spec/operators/switch-spec.ts +++ b/spec/operators/switch-spec.ts @@ -201,10 +201,10 @@ describe('Observable.prototype.switch()', () => { }); it('should handle an observable with Arrays in it', () => { - const expected = [1,2,3,4]; + const expected = [1, 2, 3, 4]; let completed = false; - Observable.of(Observable.never(), Observable.never(), [1,2,3,4]) + Observable.of(Observable.never(), Observable.never(), [1, 2, 3, 4]) .switch() .subscribe((x: number) => { expect(x).toBe(expected.shift()); diff --git a/spec/operators/switchMap-spec.ts b/spec/operators/switchMap-spec.ts index 17f031bca34..6e92a22e5e1 100644 --- a/spec/operators/switchMap-spec.ts +++ b/spec/operators/switchMap-spec.ts @@ -1,9 +1,8 @@ import * as Rx from '../../dist/cjs/Rx'; import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; +import {it, DoneSignature} from '../helpers/test-helper'; const Observable = Rx.Observable; -const queueScheduler = Rx.Scheduler.queue; describe('Observable.prototype.switchMap()', () => { it('should switch with a selector function', (done: DoneSignature) => { diff --git a/spec/operators/switchMapTo-spec.ts b/spec/operators/switchMapTo-spec.ts index eb36dfba84b..6a13a8227ee 100644 --- a/spec/operators/switchMapTo-spec.ts +++ b/spec/operators/switchMapTo-spec.ts @@ -1,9 +1,8 @@ import * as Rx from '../../dist/cjs/Rx'; import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; +import {it, DoneSignature} from '../helpers/test-helper'; const Observable = Rx.Observable; -const queueScheduler = Rx.Scheduler.queue; describe('Observable.prototype.switchMapTo()', () => { it('should switch a synchronous many outer to a synchronous many inner', (done: DoneSignature) => { diff --git a/spec/operators/take-spec.ts b/spec/operators/take-spec.ts index bfcb84059bc..15fb52b4031 100644 --- a/spec/operators/take-spec.ts +++ b/spec/operators/take-spec.ts @@ -106,7 +106,7 @@ describe('Observable.prototype.take()', () => { }); it('should throw if total is less than zero', () => { - expect(() => { Observable.range(0,10).take(-1); }) + expect(() => { Observable.range(0, 10).take(-1); }) .toThrow(new Rx.ArgumentOutOfRangeError()); }); diff --git a/spec/operators/takeLast-spec.ts b/spec/operators/takeLast-spec.ts index 52ba35fbcec..a1922212502 100644 --- a/spec/operators/takeLast-spec.ts +++ b/spec/operators/takeLast-spec.ts @@ -106,7 +106,7 @@ describe('Observable.prototype.takeLast()', () => { }); it('should throw if total is less than zero', () => { - expect(() => { Observable.range(0,10).takeLast(-1); }) + expect(() => { Observable.range(0, 10).takeLast(-1); }) .toThrow(new Rx.ArgumentOutOfRangeError()); }); diff --git a/spec/operators/throttle-spec.ts b/spec/operators/throttle-spec.ts index 6d1a9bb36b7..e4643dffd84 100644 --- a/spec/operators/throttle-spec.ts +++ b/spec/operators/throttle-spec.ts @@ -285,7 +285,7 @@ describe('Observable.prototype.throttle()', () => { Observable.timer(10).mapTo(3), Observable.timer(50).mapTo(4) ); - const expected = [1,2,3,4]; + const expected = [1, 2, 3, 4]; e1.throttle(() => { return new Promise((resolve: any) => { resolve(42); }); @@ -308,14 +308,14 @@ describe('Observable.prototype.throttle()', () => { Observable.timer(10).mapTo(3), Observable.timer(50).mapTo(4) ); - const expected = [1,2,3]; + const expected = [1, 2, 3]; const error = new Error('error'); e1.throttle((x: number) => { if (x === 3) { - return new Promise((resolve: any, reject: any) => {reject(error);}); + return new Promise((resolve: any, reject: any) => { reject(error); }); } else { - return new Promise((resolve: any) => {resolve(42);}); + return new Promise((resolve: any) => { resolve(42); }); } }).subscribe( (x: number) => { diff --git a/spec/operators/throttleTime-spec.ts b/spec/operators/throttleTime-spec.ts index b22763af272..bc1ee2d16ec 100644 --- a/spec/operators/throttleTime-spec.ts +++ b/spec/operators/throttleTime-spec.ts @@ -4,7 +4,6 @@ import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; const Observable = Rx.Observable; -const Scheduler = Rx.Scheduler; describe('Observable.prototype.throttleTime()', () => { asDiagram('throttleTime(50)')('should immediately emit the first value in each time window', () => { diff --git a/spec/operators/toPromise-spec.ts b/spec/operators/toPromise-spec.ts index f5b5fbaad4e..af3c371162b 100644 --- a/spec/operators/toPromise-spec.ts +++ b/spec/operators/toPromise-spec.ts @@ -1,6 +1,5 @@ import * as Rx from '../../dist/cjs/Rx'; -import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; +import {it, DoneSignature} from '../helpers/test-helper'; declare const __root__: any; const Observable = Rx.Observable; @@ -16,14 +15,14 @@ describe('Observable.prototype.toPromise()', () => { it('should handle errors properly', (done: DoneSignature) => { Observable.throw('bad').toPromise(Promise).then(() => { done.fail('should not be called'); - }, function (err) { + }, (err: any) => { expect(err).toBe('bad'); done(); }); }); it('should allow for global config via Rx.config.Promise', (done: DoneSignature) => { - var wasCalled = false; + let wasCalled = false; __root__.Rx = {}; __root__.Rx.config = {}; __root__.Rx.config.Promise = function MyPromise(callback) { diff --git a/spec/operators/windowToggle-spec.ts b/spec/operators/windowToggle-spec.ts index 2078a16a2e3..3d6ebc4a830 100644 --- a/spec/operators/windowToggle-spec.ts +++ b/spec/operators/windowToggle-spec.ts @@ -1,6 +1,6 @@ import * as Rx from '../../dist/cjs/Rx.KitchenSink'; import {hot, cold, time, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; +import {it, asDiagram} from '../helpers/test-helper'; declare const rxTestScheduler: Rx.TestScheduler; const Observable = Rx.Observable; diff --git a/spec/operators/windowWhen-spec.ts b/spec/operators/windowWhen-spec.ts index cc75e937d4d..7c15f235b1a 100644 --- a/spec/operators/windowWhen-spec.ts +++ b/spec/operators/windowWhen-spec.ts @@ -155,7 +155,6 @@ describe('Observable.prototype.windowWhen', () => { it('should dispose window Subjects if the outer is unsubscribed early', () => { const source = hot('--a--b--c--d--e--f--g--h--|'); - const open = cold('o-------------------------|'); const sourceSubs = '^ ! '; const expected = 'x--------- '; const x = cold( '--a--b--c- '); diff --git a/spec/operators/withLatestFrom-spec.ts b/spec/operators/withLatestFrom-spec.ts index 7464b74e1d5..90b816676dc 100644 --- a/spec/operators/withLatestFrom-spec.ts +++ b/spec/operators/withLatestFrom-spec.ts @@ -172,7 +172,7 @@ describe('Observable.prototype.withLatestFrom()', () => { const e3subs = '^ !'; const expected = '----x---#'; // throw const values = { - x: ['b','f','j'] + x: ['b', 'f', 'j'] }; const result = e1.withLatestFrom(e2, e3); @@ -241,21 +241,21 @@ describe('Observable.prototype.withLatestFrom()', () => { it('should handle promises', (done: DoneSignature) => { Observable.of(1).delay(1).withLatestFrom(Promise.resolve(2), Promise.resolve(3)) .subscribe((x: any) => { - expect(x).toEqual([1,2,3]); + expect(x).toEqual([1, 2, 3]); }, null, done); }); it('should handle arrays', () => { - Observable.of(1).delay(1).withLatestFrom([2,3,4], [4,5,6]) + Observable.of(1).delay(1).withLatestFrom([2, 3, 4], [4, 5, 6]) .subscribe((x: any) => { - expect(x).toEqual([1,4,6]); + expect(x).toEqual([1, 4, 6]); }); }); it('should handle lowercase-o observables', () => { Observable.of(1).delay(1).withLatestFrom(lowerCaseO(2, 3, 4), lowerCaseO(4, 5, 6)) .subscribe((x: any) => { - expect(x).toEqual([1,4,6]); + expect(x).toEqual([1, 4, 6]); }); }); }); \ No newline at end of file diff --git a/spec/operators/zip-spec.ts b/spec/operators/zip-spec.ts index bdc4e30af83..36d401c54fe 100644 --- a/spec/operators/zip-spec.ts +++ b/spec/operators/zip-spec.ts @@ -1,6 +1,6 @@ import * as Rx from '../../dist/cjs/Rx'; import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, DoneSignature, asDiagram} from '../helpers/test-helper'; +import {it, DoneSignature} from '../helpers/test-helper'; declare const Symbol: any; const Observable = Rx.Observable; @@ -24,8 +24,8 @@ describe('zip', () => { const expected = ['a1', 'b2', 'c3']; let i = 0; - Observable.fromArray(['a','b','c']).zip( - Observable.fromArray([1,2,3]), + Observable.fromArray(['a', 'b', 'c']).zip( + Observable.fromArray([1, 2, 3]), function (a, b) { return a + b; } @@ -44,12 +44,12 @@ describe('zip', () => { const e3subs = '^ ! '; const expected = '--------x----y----(z|) '; // e1 complete and buffer empty const values = { - x: ['a','d','h'], - y: ['b','e','i'], - z: ['c','f','j'] + x: ['a', 'd', 'h'], + y: ['b', 'e', 'i'], + z: ['c', 'f', 'j'] }; - expectObservable(e1.zip(e2,e3)).toBe(expected, values); + expectObservable(e1.zip(e2, e3)).toBe(expected, values); expectSubscriptions(e1.subscriptions).toBe(e1subs); expectSubscriptions(e2.subscriptions).toBe(e2subs); expectSubscriptions(e3.subscriptions).toBe(e3subs); @@ -65,12 +65,12 @@ describe('zip', () => { const e3subs = '^ ! '; const expected = '--------x----y----(z|) '; // e2 buffer empty and signaled complete const values = { - x: ['a','d','h'], - y: ['b','e','i'], - z: ['c','f','j'] + x: ['a', 'd', 'h'], + y: ['b', 'e', 'i'], + z: ['c', 'f', 'j'] }; - expectObservable(e1.zip(e2,e3)).toBe(expected, values); + expectObservable(e1.zip(e2, e3)).toBe(expected, values); expectSubscriptions(e1.subscriptions).toBe(e1subs); expectSubscriptions(e2.subscriptions).toBe(e2subs); expectSubscriptions(e3.subscriptions).toBe(e3subs); @@ -112,7 +112,7 @@ describe('zip', () => { }; myIterator[Symbol.iterator] = function () { return this; }; - Observable.of(1,2,3).zip(myIterator) + Observable.of(1, 2, 3).zip(myIterator) .subscribe(); // since zip will call `next()` in advance, total calls when @@ -223,7 +223,7 @@ describe('zip', () => { } else { return x + y; }}; - expectObservable(a.zip(b,selector)).toBe(expected, + expectObservable(a.zip(b, selector)).toBe(expected, { x: '14' }, new Error('too bad')); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -236,7 +236,7 @@ describe('zip', () => { const bsubs = '^'; const expected = '---x---y---z'; - expectObservable(a.zip(b, function (e1,e2) { return e1 + e2; })) + expectObservable(a.zip(b, function (e1, e2) { return e1 + e2; })) .toBe(expected, { x: '14', y: '25', z: '36' }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); @@ -250,8 +250,8 @@ describe('zip', () => { const c = hot('---1-^---3---6-| '); const expected = '----x---y-| '; - expectObservable(a.zip(b,c)).toBe(expected, - { x: ['1','2','3'], y: ['4','5','6'] }); + expectObservable(a.zip(b, c)).toBe(expected, + { x: ['1', '2', '3'], y: ['4', '5', '6'] }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); }); @@ -264,10 +264,10 @@ describe('zip', () => { const c = hot('---1-^---3---6-| '); const expected = '----x---y-| '; - const observable = a.zip(b,c, + const observable = a.zip(b, c, function (r0, r1, r2) { return [r0, r1, r2]; }); expectObservable(observable).toBe(expected, - { x: ['1','2','3'], y: ['4','5','6'] }); + { x: ['1', '2', '3'], y: ['4', '5', '6'] }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); }); @@ -280,10 +280,10 @@ describe('zip', () => { const c = hot('---1-^---3---6-| '); const expected = '----x---y-| '; - const observable = a.zip(b,c, + const observable = a.zip(b, c, function (r0, r1, r2) { return [r0, r1, r2]; }); expectObservable(observable).toBe(expected, - { x: ['1','2','3'], y: ['4','5','6'] }); + { x: ['1', '2', '3'], y: ['4', '5', '6'] }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); }); @@ -295,7 +295,7 @@ describe('zip', () => { const bsubs = '^ ! '; const expected = '---a--b--c--d--e--| '; - expectObservable(a.zip(b, function (r1,r2) { return r1 + r2; })) + expectObservable(a.zip(b, function (r1, r2) { return r1 + r2; })) .toBe(expected, { a: '12', b: '34', c: '56', d: '78', e: '90' }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); @@ -308,7 +308,7 @@ describe('zip', () => { const bsubs = '^ ! '; const expected = '---a--b--c--d--e--| '; - expectObservable(a.zip(b, function (r1,r2) { return r1 + r2; })) + expectObservable(a.zip(b, function (r1, r2) { return r1 + r2; })) .toBe(expected, { a: '21', b: '43', c: '65', d: '87', e: '09' }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); @@ -321,7 +321,7 @@ describe('zip', () => { const bsubs = '^ ! '; const expected = '---a--b--c--d--e-| '; - expectObservable(a.zip(b, function (r1,r2) { return r1 + r2; })) + expectObservable(a.zip(b, function (r1, r2) { return r1 + r2; })) .toBe(expected, { a: '12', b: '34', c: '56', d: '78', e: '90' }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); @@ -340,7 +340,7 @@ describe('zip', () => { } else { return x + y; }}; - const observable = a.zip(b,selector); + const observable = a.zip(b, selector); expectObservable(observable).toBe(expected, { x: '23' }, new Error('too bad')); expectSubscriptions(a.subscriptions).toBe(asubs); diff --git a/spec/operators/zipAll-spec.ts b/spec/operators/zipAll-spec.ts index 80608008637..f9adb7905d5 100644 --- a/spec/operators/zipAll-spec.ts +++ b/spec/operators/zipAll-spec.ts @@ -35,8 +35,8 @@ describe('Observable.prototype.zipAll', () => { const expected = ['a1', 'b2', 'c3']; let i = 0; Observable.of( - Observable.of('a','b','c'), - Observable.of(1,2,3) + Observable.of('a', 'b', 'c'), + Observable.of(1, 2, 3) ) .zipAll((a: any, b: any) => a + b) .subscribe((x: any) => { @@ -53,12 +53,12 @@ describe('Observable.prototype.zipAll', () => { const e3subs = '^ ! '; const expected = '--------x----y----(z|) '; // e1 complete and buffer empty const values = { - x: ['a','d','h'], - y: ['b','e','i'], - z: ['c','f','j'] + x: ['a', 'd', 'h'], + y: ['b', 'e', 'i'], + z: ['c', 'f', 'j'] }; - expectObservable(Observable.of(e1,e2,e3).zipAll()).toBe(expected, values); + expectObservable(Observable.of(e1, e2, e3).zipAll()).toBe(expected, values); expectSubscriptions(e1.subscriptions).toBe(e1subs); expectSubscriptions(e2.subscriptions).toBe(e2subs); expectSubscriptions(e3.subscriptions).toBe(e3subs); @@ -74,12 +74,12 @@ describe('Observable.prototype.zipAll', () => { const e3subs = '^ ! '; const expected = '--------x----y----(z|) '; // e2 buffer empty and signaled complete const values = { - x: ['a','d','h'], - y: ['b','e','i'], - z: ['c','f','j'] + x: ['a', 'd', 'h'], + y: ['b', 'e', 'i'], + z: ['c', 'f', 'j'] }; - expectObservable(Observable.of(e1,e2,e3).zipAll()).toBe(expected, values); + expectObservable(Observable.of(e1, e2, e3).zipAll()).toBe(expected, values); expectSubscriptions(e1.subscriptions).toBe(e1subs); expectSubscriptions(e2.subscriptions).toBe(e2subs); expectSubscriptions(e3.subscriptions).toBe(e3subs); @@ -121,7 +121,7 @@ describe('Observable.prototype.zipAll', () => { }; myIterator[Symbol.iterator] = function () { return this; }; - Observable.of(Observable.of(1,2,3), myIterator).zipAll() + Observable.of(Observable.of(1, 2, 3), myIterator).zipAll() .subscribe(); // since zip will call `next()` in advance, total calls when @@ -135,7 +135,7 @@ describe('Observable.prototype.zipAll', () => { const b = []; const expected = '-'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -145,7 +145,7 @@ describe('Observable.prototype.zipAll', () => { const b = []; const expected = '|'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -155,7 +155,7 @@ describe('Observable.prototype.zipAll', () => { const b = [1]; const expected = '|'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -165,7 +165,7 @@ describe('Observable.prototype.zipAll', () => { const b = []; const expected = '--------|'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -175,7 +175,7 @@ describe('Observable.prototype.zipAll', () => { const b = [1]; const expected = '-'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -185,7 +185,7 @@ describe('Observable.prototype.zipAll', () => { const b = [2]; const expected = '-----(x|)'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected, { x: ['1', 2] }); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected, { x: ['1', 2] }); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -195,7 +195,7 @@ describe('Observable.prototype.zipAll', () => { const b = []; const expected = '-----#'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -205,7 +205,7 @@ describe('Observable.prototype.zipAll', () => { const b = [1]; const expected = '-----#'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected); + expectObservable(Observable.of(a, b).zipAll()).toBe(expected); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -215,7 +215,7 @@ describe('Observable.prototype.zipAll', () => { const b = [4, 5, 6]; const expected = '---x--y--(z|)'; - expectObservable(Observable.of(a,b).zipAll()).toBe(expected, + expectObservable(Observable.of(a, b).zipAll()).toBe(expected, { x: ['1', 4], y: ['2', 5], z: ['3', 6] }); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -232,7 +232,7 @@ describe('Observable.prototype.zipAll', () => { } else { return x + y; }}; - expectObservable(Observable.of(a,b).zipAll(selector)).toBe(expected, + expectObservable(Observable.of(a, b).zipAll(selector)).toBe(expected, { x: '14' }, new Error('too bad')); expectSubscriptions(a.subscriptions).toBe(asubs); }); @@ -260,7 +260,7 @@ describe('Observable.prototype.zipAll', () => { const expected = '----x---y-| '; expectObservable(Observable.of(a, b, c).zipAll()).toBe(expected, - { x: ['1','2','3'], y: ['4','5','6'] }); + { x: ['1', '2', '3'], y: ['4', '5', '6'] }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); }); @@ -275,7 +275,7 @@ describe('Observable.prototype.zipAll', () => { const observable = Observable.of(a, b, c).zipAll((r0, r1, r2) => [r0, r1, r2]); expectObservable(observable).toBe(expected, - { x: ['1','2','3'], y: ['4','5','6'] }); + { x: ['1', '2', '3'], y: ['4', '5', '6'] }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); }); @@ -290,7 +290,7 @@ describe('Observable.prototype.zipAll', () => { const observable = Observable.of(a, b, c).zipAll((r0, r1, r2) => [r0, r1, r2]); expectObservable(observable).toBe(expected, - { x: ['1','2','3'], y: ['4','5','6'] }); + { x: ['1', '2', '3'], y: ['4', '5', '6'] }); expectSubscriptions(a.subscriptions).toBe(asubs); expectSubscriptions(b.subscriptions).toBe(bsubs); }); @@ -370,8 +370,8 @@ describe('Observable.prototype.zipAll', () => { const expected = ['a1', 'b2']; let i = 0; Observable.of( - Observable.of('a','b','c'), - Observable.of(1,2) + Observable.of('a', 'b', 'c'), + Observable.of(1, 2) ) .zipAll((a: any, b: any) => a + b) .subscribe((x: any) => { diff --git a/spec/subjects/AsyncSubject-spec.ts b/spec/subjects/AsyncSubject-spec.ts index 0c1ca5a25db..152d6e90925 100644 --- a/spec/subjects/AsyncSubject-spec.ts +++ b/spec/subjects/AsyncSubject-spec.ts @@ -135,7 +135,7 @@ describe('AsyncSubject', () => { it('should keep emitting error to subsequent subscriptions', () => { const subject = new AsyncSubject(); const observer = new TestObserver(); - const subscription = subject.subscribe(observer); + subject.subscribe(observer); subject.next(1); expect(observer.results).toEqual([]); diff --git a/spec/subjects/ReplaySubject-spec.ts b/spec/subjects/ReplaySubject-spec.ts index 17fa2fe2677..f391c875543 100644 --- a/spec/subjects/ReplaySubject-spec.ts +++ b/spec/subjects/ReplaySubject-spec.ts @@ -167,9 +167,9 @@ describe('ReplaySubject', () => { subscription3.unsubscribe(); - expect(results1).toEqual([3,4,5,6,7]); - expect(results2).toEqual([4,5,6,7,8]); - expect(results3).toEqual([9,10,11]); + expect(results1).toEqual([3, 4, 5, 6, 7]); + expect(results2).toEqual([4, 5, 6, 7, 8]); + expect(results3).toEqual([9, 10, 11]); subject.complete(); }); diff --git a/spec/util/Immediate-spec.ts b/spec/util/Immediate-spec.ts index 76bb0c1e498..37fe7c127ba 100644 --- a/spec/util/Immediate-spec.ts +++ b/spec/util/Immediate-spec.ts @@ -27,7 +27,9 @@ describe('ImmediateDefinition', () => { const result = new ImmediateDefinition(root); - result.setImmediate(() => {}); + result.setImmediate(() => { + //noop + }); result.clearImmediate(null); expect(setImmediateCalled).toBeTruthy(); @@ -43,7 +45,9 @@ describe('ImmediateDefinition', () => { nextTick: jasmine.createSpy('nextTick') } }, - runIfPresent: () => {}, + runIfPresent: () => { + //noop + }, partiallyApplied: jasmine.createSpy('partiallyApplied'), addFromSetImmediateArguments: jasmine.createSpy('addFromSetImmediateArguments').and.returnValue(123456) }; @@ -52,7 +56,9 @@ describe('ImmediateDefinition', () => { expect(typeof setImmediateImpl).toBe('function'); - const action = () => {}; + const action = () => { + //noop + }; const handle = setImmediateImpl(action); expect(handle).toBe(123456); @@ -88,7 +94,9 @@ describe('ImmediateDefinition', () => { expect(instance.runIfPresent).toHaveBeenCalledWith(123456); - const action = () => {}; + const action = () => { + //noop + }; const handle = setImmediateImpl(action); expect(handle).toBe(123456); @@ -126,7 +134,9 @@ describe('ImmediateDefinition', () => { expect(instance.runIfPresent).toHaveBeenCalledWith('something'); - const action = () => {}; + const action = () => { + //noop + }; const handle = setImmediateImpl(action); expect(handle).toBe(123456); @@ -156,7 +166,9 @@ describe('ImmediateDefinition', () => { expect(typeof setImmediateImpl).toBe('function'); - const action = () => {}; + const action = () => { + //noop + }; const handle = setImmediateImpl(action); expect(handle).toBe(123456); @@ -175,7 +187,9 @@ describe('ImmediateDefinition', () => { describe('when setImmediate does *not* exist on root', () => { describe('when it can use process.nextTick', () => { it('should use the post message impl', () => { - const nextTickImpl = () => { }; + const nextTickImpl = () => { + //noop + }; spyOn(ImmediateDefinition.prototype, 'canUseProcessNextTick').and.returnValue(true); spyOn(ImmediateDefinition.prototype, 'canUsePostMessage').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUseMessageChannel').and.returnValue(false); @@ -194,7 +208,9 @@ describe('ImmediateDefinition', () => { describe('when it cannot use process.nextTick', () => { it('should use the post message impl', () => { - const postMessageImpl = () => { }; + const postMessageImpl = () => { + //noop + }; spyOn(ImmediateDefinition.prototype, 'canUseProcessNextTick').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUsePostMessage').and.returnValue(true); spyOn(ImmediateDefinition.prototype, 'canUseMessageChannel').and.returnValue(false); @@ -213,7 +229,9 @@ describe('ImmediateDefinition', () => { describe('when it cannot use process.nextTick or postMessage', () => { it('should use the readystatechange impl', () => { - const messageChannelImpl = () => { }; + const messageChannelImpl = () => { + //noop + }; spyOn(ImmediateDefinition.prototype, 'canUseProcessNextTick').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUsePostMessage').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUseMessageChannel').and.returnValue(true); @@ -232,7 +250,9 @@ describe('ImmediateDefinition', () => { describe('when it cannot use process.nextTick, postMessage or Message channels', () => { it('should use the readystatechange impl', () => { - const readyStateChangeImpl = () => { }; + const readyStateChangeImpl = () => { + //noop + }; spyOn(ImmediateDefinition.prototype, 'canUseProcessNextTick').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUsePostMessage').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUseMessageChannel').and.returnValue(false); @@ -251,7 +271,9 @@ describe('ImmediateDefinition', () => { describe('when no other methods to implement setImmediate are available', () => { it('should use the setTimeout impl', () => { - const setTimeoutImpl = () => { }; + const setTimeoutImpl = () => { + //noop + }; spyOn(ImmediateDefinition.prototype, 'canUseProcessNextTick').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUsePostMessage').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUseMessageChannel').and.returnValue(false); @@ -292,7 +314,7 @@ describe('ImmediateDefinition', () => { expect(typeof result).toBe('function'); - const calledWith = result(); + result(); expect(__root__.__wasCalled).toEqual(true); @@ -304,6 +326,7 @@ describe('ImmediateDefinition', () => { describe('prototype.identify', () => { it('should use Object.toString to return an identifier string', () => { function MockObject() { + //noop } MockObject.prototype.toString = jasmine.createSpy('Object.prototype.toString').and.returnValue('[object HEYO!]'); @@ -357,7 +380,9 @@ describe('ImmediateDefinition', () => { describe('when there is a global postMessage function', () => { describe('and importScripts does NOT exist', () => { it('should maintain any existing onmessage handler', () => { - const originalOnMessage = () => {}; + const originalOnMessage = () => { + //noop + }; const instance = { root: { onmessage: originalOnMessage @@ -410,8 +435,12 @@ describe('ImmediateDefinition', () => { it('should return false', () => { const instance = { root: { - postMessage: () => {}, - importScripts: () => {} + postMessage: function () { + //noop + }, + importScripts: function () { + //noop + } } }; @@ -438,7 +467,9 @@ describe('ImmediateDefinition', () => { it('should return true if MessageChannel exists', () => { const instance = { root: { - MessageChannel: () => {} + MessageChannel: function () { + //noop + } } }; @@ -518,7 +549,9 @@ describe('ImmediateDefinition', () => { partiallyApplied: jasmine.createSpy('partiallyApplied').and.returnValue(partiallyAppliedResult) }; - const args = [() => {}, 'foo', 'bar']; + const args = [() => { + //noop + }, 'foo', 'bar']; const handle = ImmediateDefinition.prototype.addFromSetImmediateArguments.call(instance, args); @@ -530,7 +563,9 @@ describe('ImmediateDefinition', () => { describe('clearImmediate', () => { it('should delete values from tasksByHandle', () => { - const setTimeoutImpl = () => { }; + const setTimeoutImpl = () => { + //noop + }; spyOn(ImmediateDefinition.prototype, 'canUseProcessNextTick').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUsePostMessage').and.returnValue(false); spyOn(ImmediateDefinition.prototype, 'canUseMessageChannel').and.returnValue(false); @@ -538,7 +573,9 @@ describe('ImmediateDefinition', () => { spyOn(ImmediateDefinition.prototype, 'createSetTimeoutSetImmediate').and.returnValue(setTimeoutImpl); const Immediate = new ImmediateDefinition({}); - Immediate.tasksByHandle[123456] = () => {}; + Immediate.tasksByHandle[123456] = () => { + //noop + }; expect('123456' in Immediate.tasksByHandle).toBe(true); @@ -550,7 +587,9 @@ describe('ImmediateDefinition', () => { describe('prototype.runIfPresent', () => { it('should delay running the task if it is currently running a task', () => { - const mockApplied = () => {}; + const mockApplied = () => { + //noop + }; const instance = { root: { @@ -606,14 +645,18 @@ describe('ImmediateDefinition', () => { describe('prototype.createSetTimeoutSetImmediate', () => { it('should create a proper setImmediate implementation that uses setTimeout', () => { - const mockApplied = () => {}; + const mockApplied = () => { + //noop + }; const instance = { root: { setTimeout: jasmine.createSpy('setTimeout') }, addFromSetImmediateArguments: jasmine.createSpy('addFromSetImmediateArguments').and.returnValue(123456), - runIfPresent: () => {}, + runIfPresent: function () { + //noop + }, partiallyApplied: jasmine.createSpy('partiallyApplied').and.returnValue(mockApplied) }; @@ -635,7 +678,7 @@ describe('ImmediateDefinition', () => { results.push(x); }, done.fail, () => { - expect(results).toEqual([1,2,3]); + expect(results).toEqual([1, 2, 3]); done(); }); }); diff --git a/spec/util/MapPolyfill-spec.ts b/spec/util/MapPolyfill-spec.ts index dfaa948585c..bf0bbdee2da 100644 --- a/spec/util/MapPolyfill-spec.ts +++ b/spec/util/MapPolyfill-spec.ts @@ -1,5 +1,4 @@ import {MapPolyfill} from '../../dist/cjs/util/MapPolyfill'; -import * as Rx from '../../dist/cjs/Rx'; import {it} from '../helpers/test-helper'; describe('MapPolyfill', () => { diff --git a/spec/util/SymbolShim-spec.ts b/spec/util/SymbolShim-spec.ts index 0f0403e8af7..36290d11122 100644 --- a/spec/util/SymbolShim-spec.ts +++ b/spec/util/SymbolShim-spec.ts @@ -1,7 +1,6 @@ -import {polyfillSymbol, ensureIterator} from '../../dist/cjs/util/SymbolShim'; +import {polyfillSymbol} from '../../dist/cjs/util/SymbolShim'; import {Map} from '../../dist/cjs/util/Map'; -import * as Rx from '../../dist/cjs/Rx'; -import {it, DoneSignature} from '../helpers/test-helper'; +import {it} from '../helpers/test-helper'; declare const __root__: any; @@ -96,8 +95,11 @@ describe('SymbolShim.polyfillSymbol', () => { it('should patch using Set for mozilla bug', () => { function Set() { + //noop } - Set.prototype['@@iterator'] = () => {}; + Set.prototype['@@iterator'] = () => { + //noop + }; const root = { Set: Set,