diff --git a/.prettierrc.json b/.prettierrc.json index 250c75e465..8d6959ce2e 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -4,16 +4,10 @@ "printWidth": 140, "overrides": [ { - "files": ["spec/**/*.ts", "spec-dtslint/**/*.ts"], + "files": ["packages/rxjs/spec-dtslint/**/*.ts"], "options": { "requirePragma": true } - }, - { - "files": ["spec/operators/**/*.ts", "spec/subjects/**/*.ts"], - "options": { - "requirePragma": false - } } ] } diff --git a/packages/rxjs/spec-dtslint/observables/onErrorResumeNext-spec.ts b/packages/rxjs/spec-dtslint/observables/onErrorResumeNext-spec.ts index 518bb51214..1884e57cc8 100644 --- a/packages/rxjs/spec-dtslint/observables/onErrorResumeNext-spec.ts +++ b/packages/rxjs/spec-dtslint/observables/onErrorResumeNext-spec.ts @@ -23,7 +23,8 @@ it('should handle non-observable inputs appropriately', () => { it('should handle observable inputs okay', () => { const o1 = onErrorResumeNext([1, 2, 3, 'test'], Promise.resolve(true)); // $ExpectType Observable - const o2 = onErrorResumeNext( // $ExpecType Observable + const o2 = onErrorResumeNext( + // $ExpecType Observable (function* () { return 'test'; })() diff --git a/packages/rxjs/spec/Observable-spec.ts b/packages/rxjs/spec/Observable-spec.ts index 54a53a706c..eceac75bce 100644 --- a/packages/rxjs/spec/Observable-spec.ts +++ b/packages/rxjs/spec/Observable-spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; import { TeardownLogic } from '../src/internal/types'; import { Observable, config, Subscription, Subscriber, Operator, NEVER, Subject, of, throwError, EMPTY } from 'rxjs'; -import { map, filter, count, tap, combineLatestWith, concatWith, mergeWith, raceWith, zipWith, catchError, share} from 'rxjs/operators'; +import { map, filter, count, tap, combineLatestWith, concatWith, mergeWith, raceWith, zipWith, catchError, share } from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { observableMatcher } from './helpers/observableMatcher'; import { result } from 'lodash'; @@ -30,11 +30,12 @@ describe('Observable', () => { observer.complete(); }); - source.subscribe( - { next: function (x) { + source.subscribe({ + next: function (x) { expect(x).to.equal(1); - }, complete: done } - ); + }, + complete: done, + }); }); it('should send errors thrown in the constructor down the error path', (done) => { @@ -70,7 +71,7 @@ describe('Observable', () => { }); it('should reject promise when in error', (done) => { - throwError(() => ('bad')) + throwError(() => 'bad') .forEach(() => { done(new Error('should not be called')); }) @@ -178,13 +179,17 @@ describe('Observable', () => { const results: any[] = []; const next = function (value: string) { results.push(value); - } - next.bind = () => { /* lol */}; + }; + next.bind = () => { + /* lol */ + }; const complete = function () { results.push('done'); - } - complete.bind = () => { /* lol */}; + }; + complete.bind = () => { + /* lol */ + }; source.subscribe({ next, complete }); expect(results).to.deep.equal(['Hi', 'done']); @@ -195,7 +200,7 @@ describe('Observable', () => { const results: any[] = []; const error = function (value: string) { results.push(value); - } + }; source.subscribe({ error }); expect(results).to.deep.equal(['an error']); @@ -218,15 +223,16 @@ describe('Observable', () => { let mutatedByNext = false; let mutatedByComplete = false; - source.subscribe( - { next: (x) => { + source.subscribe({ + next: (x) => { nexted = x; mutatedByNext = true; - }, complete: () => { + }, + complete: () => { completed = true; mutatedByComplete = true; - } } - ); + }, + }); expect(mutatedByNext).to.be.true; expect(mutatedByComplete).to.be.true; @@ -387,15 +393,16 @@ describe('Observable', () => { }; }) .pipe(tap(() => (times += 1))) - .subscribe( - { next: function () { + .subscribe({ + next: function () { if (times === 2) { subscription.unsubscribe(); } - }, error: function () { + }, + error: function () { errorCalled = true; - } } - ); + }, + }); }); it('should ignore complete messages after unsubscription', (done) => { @@ -419,15 +426,16 @@ describe('Observable', () => { }; }) .pipe(tap(() => (times += 1))) - .subscribe( - { next: function () { + .subscribe({ + next: function () { if (times === 2) { subscription.unsubscribe(); } - }, complete: function () { + }, + complete: function () { completeCalled = true; - } } - ); + }, + }); }); describe('when called with an anonymous observer', () => { @@ -463,7 +471,7 @@ describe('Observable', () => { }, }; - throwError(() => ('bad')).subscribe(o); + throwError(() => 'bad').subscribe(o); } ); @@ -592,13 +600,14 @@ describe('Observable', () => { }); badObservable.subscribe({ - error: () => { /* do nothing */ } + error: () => { + /* do nothing */ + }, }); expect(called).to.be.true; }); - it('should handle empty string sync errors', () => { const badObservable = new Observable(() => { throw ''; @@ -609,7 +618,7 @@ describe('Observable', () => { error: (err) => { caught = true; expect(err).to.equal(''); - } + }, }); expect(caught).to.be.true; }); @@ -627,11 +636,12 @@ describe('Observable', () => { map((x) => x + x), map((x) => x + '!!!') ) - .subscribe( - { next: (x) => { + .subscribe({ + next: (x) => { expect(x).to.equal('testtest!!!'); - }, complete: done } - ); + }, + complete: done, + }); }); it('should return the same observable if there are no arguments', () => { @@ -643,11 +653,11 @@ describe('Observable', () => { it('should allow any kind of piped function', () => { const source = of('test'); const result = source.pipe( - source => source instanceof Observable, - isObservable => isObservable ? 'Well hello, there.' : 'Huh?' + (source) => source instanceof Observable, + (isObservable) => (isObservable ? 'Well hello, there.' : 'Huh?') ); expect(result).to.equal('Well hello, there.'); - }) + }); }); it('should not swallow internal errors', (done) => { @@ -658,29 +668,29 @@ describe('Observable', () => { done(); }; - new Observable(subscriber => { + new Observable((subscriber) => { subscriber.error('test'); throw 'bad'; }).subscribe({ - error: err => { + error: (err) => { expect(err).to.equal('test'); - } + }, }); }); // Discussion here: https://github.com/ReactiveX/rxjs/issues/5370 it.skip('should handle sync errors within a test scheduler', () => { const observable = of(4).pipe( - map(n => { - if (n === 4) { - throw 'four!'; + map((n) => { + if (n === 4) { + throw 'four!'; } return n; }), - catchError((err, source) => source), + catchError((err, source) => source) ); - rxTestScheduler.run(helpers => { + rxTestScheduler.run((helpers) => { const { expectObservable } = helpers; expectObservable(observable).toBe('-'); }); @@ -694,14 +704,13 @@ describe('Observable', () => { let thrownError: any = undefined; source.subscribe({ - error: err => thrownError = err + error: (err) => (thrownError = err), }); expect(thrownError).to.be.an.instanceOf(RangeError); expect(thrownError.message).to.equal('Maximum call stack size exceeded'); }); - describe('As an async iterable', () => { it('should be able to be used with for-await-of', async () => { const source = new Observable((subscriber) => { @@ -727,13 +736,13 @@ describe('Observable', () => { subscriber.next(1); subscriber.next(2); - + // NOTE that we are NOT calling `subscriber.complete()` here. // therefore the teardown below would never be called naturally // by the observable unless it was unsubscribed. return () => { activeSubscriptions--; - } + }; }); const results: number[] = []; @@ -759,7 +768,7 @@ describe('Observable', () => { try { for await (const value of source) { results.push(value); - throw new Error('wee') + throw new Error('wee'); } } catch { // Ignore @@ -786,7 +795,7 @@ describe('Observable', () => { thrownError = err; } - expect(thrownError?.message).to.equal('wee') + expect(thrownError?.message).to.equal('wee'); expect(results).to.deep.equal([1, 2]); }); @@ -826,7 +835,7 @@ describe('Observable', () => { expect(results).to.deep.equal([1, 2, 3]); }); - it ('should handle situations where values from the observable are arriving faster than the are being consumed by the async iterator', async () => { + it('should handle situations where values from the observable are arriving faster than the are being consumed by the async iterator', async () => { const subject = new Subject(); const results: any[] = []; @@ -838,7 +847,7 @@ describe('Observable', () => { results.push(result.value); }); subject.next(1); - await first + await first; expect(results).to.deep.equal([1]); // push values through the observable that aren't yet consumed by the async iterator @@ -861,13 +870,9 @@ describe('Observable', () => { const asyncIterator = subject[Symbol.asyncIterator](); // Queue up three promises, but don't await them. - const allPending = Promise.all([ - asyncIterator.next(), - asyncIterator.next(), - asyncIterator.next(), - ]).then((allResults) => { - results.push(...allResults) - }) + const allPending = Promise.all([asyncIterator.next(), asyncIterator.next(), asyncIterator.next()]).then((allResults) => { + results.push(...allResults); + }); expect(results).to.deep.equal([]); @@ -893,7 +898,7 @@ describe('Observable', () => { asyncIterator.next().catch((err: any) => results.push(err)), asyncIterator.next().catch((err: any) => results.push(err)), asyncIterator.next().catch((err: any) => results.push(err)), - ]) + ]); expect(results).to.deep.equal([]); @@ -915,7 +920,7 @@ describe('Observable', () => { state = 'subscribed'; return () => { state = 'unsubscribed'; - } + }; }); const asyncIterator = source[Symbol.asyncIterator](); @@ -930,10 +935,10 @@ describe('Observable', () => { let state = 'idle'; const source = new Observable((subscriber) => { state = 'subscribed'; - subscriber.next(0) + subscriber.next(0); return () => { state = 'unsubscribed'; - } + }; }); const asyncIterator = source[Symbol.asyncIterator](); @@ -948,4 +953,4 @@ describe('Observable', () => { expect(state).to.equal('unsubscribed'); }); }); -}); \ No newline at end of file +}); diff --git a/packages/rxjs/spec/Scheduler-spec.ts b/packages/rxjs/spec/Scheduler-spec.ts index 0d0c1819fb..fa2e5474fc 100644 --- a/packages/rxjs/spec/Scheduler-spec.ts +++ b/packages/rxjs/spec/Scheduler-spec.ts @@ -22,13 +22,17 @@ describe('Scheduler.queue', () => { let call1 = false; let call2 = false; (queue as QueueScheduler)._active = false; - queue.schedule(function (state) { - call1 = state!.call1; - call2 = state!.call2; - if (!call2) { - this.schedule({ call1: true, call2: true }); - } - }, 0, { call1: true, call2: false }); + queue.schedule( + function (state) { + call1 = state!.call1; + call2 = state!.call2; + if (!call2) { + this.schedule({ call1: true, call2: true }); + } + }, + 0, + { call1: true, call2: false } + ); expect(call1).to.be.true; expect(call2).to.be.true; }); diff --git a/packages/rxjs/spec/Subject-spec.ts b/packages/rxjs/spec/Subject-spec.ts index d940338a6a..7c6e5b2b5c 100644 --- a/packages/rxjs/spec/Subject-spec.ts +++ b/packages/rxjs/spec/Subject-spec.ts @@ -15,11 +15,12 @@ describe('Subject', () => { it('should allow next with undefined or any when created with no type', (done) => { const subject = new Subject(); - subject.subscribe( - { next: (x) => { + subject.subscribe({ + next: (x) => { expect(x).to.be.a('undefined'); - }, complete: done } - ); + }, + complete: done, + }); const data: any = undefined; subject.next(undefined); @@ -29,11 +30,12 @@ describe('Subject', () => { it('should allow empty next when created with void type', (done) => { const subject = new Subject(); - subject.subscribe( - { next: (x) => { + subject.subscribe({ + next: (x) => { expect(x).to.be.a('undefined'); - }, complete: done } - ); + }, + complete: done, + }); subject.next(); subject.complete(); @@ -43,11 +45,12 @@ describe('Subject', () => { const subject = new Subject(); const expected = ['foo', 'bar']; - subject.subscribe( - { next: (x: string) => { + subject.subscribe({ + next: (x: string) => { expect(x).to.equal(expected.shift()); - }, complete: done } - ); + }, + complete: done, + }); subject.next('foo'); subject.next('bar'); @@ -65,11 +68,12 @@ describe('Subject', () => { expect(x).to.equal(expected[i++]); }); - subject.subscribe( - { next: function (x) { + subject.subscribe({ + next: function (x) { expect(x).to.equal(expected[j++]); - }, complete: done } - ); + }, + complete: done, + }); expect(subject.observers.length).to.equal(2); subject.next('foo'); @@ -88,27 +92,31 @@ describe('Subject', () => { subject.next(3); subject.next(4); - const subscription1 = subject.subscribe( - { next: function (x) { + const subscription1 = subject.subscribe({ + next: function (x) { results1.push(x); - }, error: function (e) { + }, + error: function (e) { results1.push('E'); - }, complete: () => { + }, + complete: () => { results1.push('C'); - } } - ); + }, + }); subject.next(5); - const subscription2 = subject.subscribe( - { next: function (x) { + const subscription2 = subject.subscribe({ + next: function (x) { results2.push(x); - }, error: function (e) { + }, + error: function (e) { results2.push('E'); - }, complete: () => { + }, + complete: () => { results2.push('C'); - } } - ); + }, + }); subject.next(6); subject.next(7); @@ -122,15 +130,17 @@ describe('Subject', () => { subject.next(9); subject.next(10); - const subscription3 = subject.subscribe( - { next: function (x) { + const subscription3 = subject.subscribe({ + next: function (x) { results3.push(x); - }, error: function (e) { + }, + error: function (e) { results3.push('E'); - }, complete: () => { + }, + complete: () => { results3.push('C'); - } } - ); + }, + }); subject.next(11); @@ -152,27 +162,31 @@ describe('Subject', () => { subject.next(3); subject.next(4); - const subscription1 = subject.subscribe( - { next: function (x) { + const subscription1 = subject.subscribe({ + next: function (x) { results1.push(x); - }, error: function (e) { + }, + error: function (e) { results1.push('E'); - }, complete: () => { + }, + complete: () => { results1.push('C'); - } } - ); + }, + }); subject.next(5); - const subscription2 = subject.subscribe( - { next: function (x) { + const subscription2 = subject.subscribe({ + next: function (x) { results2.push(x); - }, error: function (e) { + }, + error: function (e) { results2.push('E'); - }, complete: () => { + }, + complete: () => { results2.push('C'); - } } - ); + }, + }); subject.next(6); subject.next(7); @@ -183,15 +197,17 @@ describe('Subject', () => { subscription2.unsubscribe(); - const subscription3 = subject.subscribe( - { next: function (x) { + const subscription3 = subject.subscribe({ + next: function (x) { results3.push(x); - }, error: function (e) { + }, + error: function (e) { results3.push('E'); - }, complete: () => { + }, + complete: () => { results3.push('C'); - } } - ); + }, + }); subscription3.unsubscribe(); @@ -211,27 +227,31 @@ describe('Subject', () => { subject.next(3); subject.next(4); - const subscription1 = subject.subscribe( - { next: function (x) { + const subscription1 = subject.subscribe({ + next: function (x) { results1.push(x); - }, error: function (e) { + }, + error: function (e) { results1.push('E'); - }, complete: () => { + }, + complete: () => { results1.push('C'); - } } - ); + }, + }); subject.next(5); - const subscription2 = subject.subscribe( - { next: function (x) { + const subscription2 = subject.subscribe({ + next: function (x) { results2.push(x); - }, error: function (e) { + }, + error: function (e) { results2.push('E'); - }, complete: () => { + }, + complete: () => { results2.push('C'); - } } - ); + }, + }); subject.next(6); subject.next(7); @@ -242,15 +262,17 @@ describe('Subject', () => { subscription2.unsubscribe(); - const subscription3 = subject.subscribe( - { next: function (x) { + const subscription3 = subject.subscribe({ + next: function (x) { results3.push(x); - }, error: function (e) { + }, + error: function (e) { results3.push('E'); - }, complete: () => { + }, + complete: () => { results3.push('C'); - } } - ); + }, + }); subscription3.unsubscribe(); @@ -265,25 +287,29 @@ describe('Subject', () => { const results2: (number | string)[] = []; const results3: (number | string)[] = []; - const subscription1 = subject.subscribe( - { next: function (x) { + const subscription1 = subject.subscribe({ + next: function (x) { results1.push(x); - }, error: function (e) { + }, + error: function (e) { results1.push('E'); - }, complete: () => { + }, + complete: () => { results1.push('C'); - } } - ); + }, + }); - const subscription2 = subject.subscribe( - { next: function (x) { + const subscription2 = subject.subscribe({ + next: function (x) { results2.push(x); - }, error: function (e) { + }, + error: function (e) { results2.push('E'); - }, complete: () => { + }, + complete: () => { results2.push('C'); - } } - ); + }, + }); subscription1.unsubscribe(); @@ -291,15 +317,17 @@ describe('Subject', () => { subscription2.unsubscribe(); - const subscription3 = subject.subscribe( - { next: function (x) { + const subscription3 = subject.subscribe({ + next: function (x) { results3.push(x); - }, error: function (e) { + }, + error: function (e) { results3.push('E'); - }, complete: () => { + }, + complete: () => { results3.push('C'); - } } - ); + }, + }); subscription3.unsubscribe(); @@ -314,28 +342,32 @@ describe('Subject', () => { const results2: (number | string)[] = []; const results3: (number | string)[] = []; - const subscription1 = subject.subscribe( - { next: function (x) { + const subscription1 = subject.subscribe({ + next: function (x) { results1.push(x); - }, error: function (e) { + }, + error: function (e) { results1.push('E'); - }, complete: () => { + }, + complete: () => { results1.push('C'); - } } - ); + }, + }); subject.next(1); subject.next(2); - const subscription2 = subject.subscribe( - { next: function (x) { + const subscription2 = subject.subscribe({ + next: function (x) { results2.push(x); - }, error: function (e) { + }, + error: function (e) { results2.push('E'); - }, complete: () => { + }, + complete: () => { results2.push('C'); - } } - ); + }, + }); subject.next(3); subject.next(4); @@ -345,17 +377,14 @@ describe('Subject', () => { subscription2.unsubscribe(); subject.unsubscribe(); - - const subscription = subject.subscribe( - { - next: function (x) { - results3.push(x); - }, - error: function (err) { - expect(false).to.equal('should not throw error: ' + err.toString()); - } - } - ); + const subscription = subject.subscribe({ + next: function (x) { + results3.push(x); + }, + error: function (err) { + expect(false).to.equal('should not throw error: ' + err.toString()); + }, + }); expect(subscription.closed).to.be.true; @@ -366,12 +395,12 @@ describe('Subject', () => { it('should not allow values to be nexted after it is unsubscribed', () => { const subject = new Subject(); - const results: any[] = [] - subject.subscribe(x => results.push(x)); + const results: any[] = []; + subject.subscribe((x) => results.push(x)); subject.next('foo'); subject.unsubscribe(); - subject.next('bar') + subject.next('bar'); expect(results).to.deep.equal(['foo']); }); @@ -452,7 +481,7 @@ describe('Subject', () => { }, complete: () => { outputComplete = true; - } + }, }); sub.next('a'); @@ -501,7 +530,7 @@ describe('Subject', () => { }, complete: () => { outputComplete = true; - } + }, }); sub.next('a'); @@ -522,15 +551,17 @@ describe('Subject', () => { const subject = new Subject(); const expected = [1, 2, 3, 4, 5]; - subject.subscribe( - { next: function (x) { + subject.subscribe({ + next: function (x) { expect(x).to.equal(expected.shift()); - }, error: (x) => { + }, + error: (x) => { done(new Error('should not be called')); - }, complete: () => { + }, + complete: () => { done(); - } } - ); + }, + }); source.subscribe(subject); }); @@ -541,15 +572,17 @@ describe('Subject', () => { const expected = [1, 2, 3]; - subject.subscribe( - { next: function (x) { + subject.subscribe({ + next: function (x) { expect(x).to.equal(expected.shift()); - }, error: (x) => { + }, + error: (x) => { done(new Error('should not be called')); - }, complete: () => { + }, + complete: () => { done(); - } } - ); + }, + }); source.subscribe(subject); }); @@ -575,9 +608,7 @@ describe('Subject', () => { it('should not next after completed', () => { const subject = new Subject(); const results: string[] = []; - subject.subscribe( - { next: (x) => results.push(x), complete: () => results.push('C') } - ); + subject.subscribe({ next: (x) => results.push(x), complete: () => results.push('C') }); subject.next('a'); subject.complete(); subject.next('b'); @@ -588,9 +619,7 @@ describe('Subject', () => { const error = new Error('wut?'); const subject = new Subject(); const results: string[] = []; - subject.subscribe( - { next: (x) => results.push(x), error: (err) => results.push(err) } - ); + subject.subscribe({ next: (x) => results.push(x), error: (err) => results.push(err) }); subject.next('a'); subject.error(error); subject.next('b'); @@ -652,9 +681,7 @@ describe('Subject', () => { const observable = subject.asObservable(); - observable.subscribe( - { next: (x) => results.push(x), complete: () => results.push('done') } - ); + observable.subscribe({ next: (x) => results.push(x), complete: () => results.push('done') }); expect(results).to.deep.equal([42, 'done']); }); @@ -670,7 +697,7 @@ describe('Subject', () => { expect(err.message).to.equal('Boom!'); done(); }; - + const source = new Subject(); source.subscribe(); source.subscribe(() => { @@ -693,10 +720,12 @@ describe('Subject', () => { const allSubscriptions: Subscription[] = []; const source = new Subject(); const numSubscribers = 100000; - for (let index = 0 ; index !== numSubscribers ; ++index) { - allSubscriptions.push(source.subscribe(() => { - ++numResultsReceived; - })); + for (let index = 0; index !== numSubscribers; ++index) { + allSubscriptions.push( + source.subscribe(() => { + ++numResultsReceived; + }) + ); } expect(numResultsReceived).to.eq(0); expect(source.observed).to.be.true; @@ -717,7 +746,7 @@ describe('Subject', () => { const source = new Subject(); source.subscribe((value) => { seenValues.push(value); - source.subscribe(nestedValue => { + source.subscribe((nestedValue) => { seenValues.push(nestedValue); }); }); @@ -733,16 +762,16 @@ describe('Subject', () => { const destination = new Subscriber(); const results: any[] = []; const subscriber = operate({ - destination, + destination, next: (value) => { results.push(value); - }, + }, error: noop, complete: () => { results.push('complete'); - }, + }, }); - + subject.subscribe(subscriber); subject.subscribe(subscriber); subject.next(1); @@ -751,7 +780,6 @@ describe('Subject', () => { expect(results).to.deep.equal([1, 1, 2, 2, 'complete']); }); - }); describe('AnonymousSubject', () => { diff --git a/packages/rxjs/spec/Subscriber-spec.ts b/packages/rxjs/spec/Subscriber-spec.ts index a0124694f8..2ba8d9a465 100644 --- a/packages/rxjs/spec/Subscriber-spec.ts +++ b/packages/rxjs/spec/Subscriber-spec.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai'; +import { expect } from 'chai'; import { Subscriber, Observable, of, Observer, config, operate } from 'rxjs'; import * as sinon from 'sinon'; import { asInteropSubscriber } from './helpers/interop-helper'; @@ -10,7 +10,9 @@ describe('Subscriber', () => { let times = 0; const sub = new Subscriber({ - next() { times += 1; } + next() { + times += 1; + }, }); sub.next(); @@ -26,8 +28,12 @@ describe('Subscriber', () => { let errorCalled = false; const sub = new Subscriber({ - next() { times += 1; }, - error() { errorCalled = true; } + next() { + times += 1; + }, + error() { + errorCalled = true; + }, }); sub.next(); @@ -45,8 +51,12 @@ describe('Subscriber', () => { let completeCalled = false; const sub = new Subscriber({ - next() { times += 1; }, - complete() { completeCalled = true; } + next() { + times += 1; + }, + complete() { + completeCalled = true; + }, }); sub.next(); @@ -61,7 +71,9 @@ describe('Subscriber', () => { it('should not be closed when other subscriber with same observer instance completes', () => { const observer = { - next: function () { /*noop*/ } + next: function () { + /*noop*/ + }, }; const sub1 = new Subscriber(observer); @@ -79,7 +91,7 @@ describe('Subscriber', () => { const observer = { complete: (...args: Array) => { argument = args; - } + }, }; const sub1 = new Subscriber(observer); @@ -94,11 +106,11 @@ describe('Subscriber', () => { let subscriptionUnsubscribed = false; const subscriber = new Subscriber(); - subscriber.add(() => subscriberUnsubscribed = true); + subscriber.add(() => (subscriberUnsubscribed = true)); - const source = new Observable(() => () => observableUnsubscribed = true); + const source = new Observable(() => () => (observableUnsubscribed = true)); const subscription = source.subscribe(asInteropSubscriber(subscriber)); - subscription.add(() => subscriptionUnsubscribed = true); + subscription.add(() => (subscriptionUnsubscribed = true)); subscriber.unsubscribe(); expect(observableUnsubscribed).to.be.true; @@ -122,7 +134,7 @@ describe('Subscriber', () => { it('should close, unsubscribe, and unregister all finalizers after complete', () => { let isUnsubscribed = false; const subscriber = new Subscriber(); - subscriber.add(() => isUnsubscribed = true); + subscriber.add(() => (isUnsubscribed = true)); subscriber.complete(); expect(isUnsubscribed).to.be.true; expect(subscriber.closed).to.be.true; @@ -136,9 +148,9 @@ describe('Subscriber', () => { // Mischief managed! // Adding this handler here to prevent the call to error from // throwing, since it will have an error handler now. - } + }, }); - subscriber.add(() => isTornDown = true); + subscriber.add(() => (isTornDown = true)); subscriber.error(new Error('test')); expect(isTornDown).to.be.true; expect(subscriber.closed).to.be.true; @@ -148,7 +160,9 @@ describe('Subscriber', () => { it('should finalize and unregister all finalizers after complete', () => { let isTornDown = false; const subscriber = new Subscriber(); - subscriber.add(() => { isTornDown = true }); + subscriber.add(() => { + isTornDown = true; + }); subscriber.complete(); expect(isTornDown).to.be.true; expect(getRegisteredFinalizers(subscriber).length).to.equal(0); @@ -169,7 +183,7 @@ describe('Subscriber', () => { this.valuesProcessed.push(value); } } - }; + } const consumer = new CustomConsumer(); @@ -181,61 +195,61 @@ describe('Subscriber', () => { describe('error reporting for destination observers', () => { afterEach(() => { config.onUnhandledError = null; - }) + }); it('should report errors thrown from next', (done) => { config.onUnhandledError = (err) => { expect(err).to.be.an.instanceOf(Error); expect(err.message).to.equal('test'); - done() + done(); }; const subscriber = new Subscriber({ next() { throw new Error('test'); - } + }, }); - subscriber.next() + subscriber.next(); }); it('should report errors thrown from complete', (done) => { config.onUnhandledError = (err) => { expect(err).to.be.an.instanceOf(Error); expect(err.message).to.equal('test'); - done() + done(); }; const subscriber = new Subscriber({ complete() { throw new Error('test'); - } + }, }); - subscriber.complete() + subscriber.complete(); }); it('should report errors thrown from error', (done) => { config.onUnhandledError = (err) => { expect(err).to.be.an.instanceOf(Error); expect(err.message).to.equal('test'); - done() + done(); }; const subscriber = new Subscriber({ error() { throw new Error('test'); - } + }, }); - subscriber.error() + subscriber.error(); }); it('should report errors thrown from a full observer', (done) => { config.onUnhandledError = (err) => { expect(err).to.be.an.instanceOf(Error); expect(err.message).to.equal('thrown from next'); - done() + done(); }; const subscriber = new Subscriber({ @@ -247,17 +261,17 @@ describe('Subscriber', () => { }, complete() { throw new Error('thrown from complete'); - } + }, }); - subscriber.next() + subscriber.next(); }); it('should report errors thrown from a full observer even if it is also shaped like a subscription', (done) => { config.onUnhandledError = (err) => { expect(err).to.be.an.instanceOf(Error); expect(err.message).to.equal('thrown from next'); - done() + done(); }; const subscriber = new Subscriber({ @@ -282,18 +296,23 @@ describe('Subscriber', () => { closed: false, }); - subscriber.next() + subscriber.next(); }); - }) + }); const FinalizationRegistry = (global as any).FinalizationRegistry; if (FinalizationRegistry && global.gc) { - it('should not leak the destination', (done) => { let observer: Observer | undefined = { - next() { /* noop */ }, - error() { /* noop */ }, - complete() { /* noop */ } + next() { + /* noop */ + }, + error() { + /* noop */ + }, + complete() { + /* noop */ + }, }; const registry = new FinalizationRegistry((value: any) => { @@ -307,7 +326,6 @@ describe('Subscriber', () => { observer = undefined; global.gc?.(); }); - } else { console.warn(`No support for FinalizationRegistry in Node ${process.version}`); } @@ -322,7 +340,7 @@ describe('operate', () => { const subscriber = operate({ destination, - }) + }); subscriber.next('foo'); expect(next).to.have.been.calledOnceWithExactly('foo'); @@ -337,9 +355,9 @@ describe('operate', () => { const subscriber = operate({ destination, next() { - throw 'boop!' + throw 'boop!'; }, - }) + }); subscriber.next('foo'); expect(error).to.have.been.calledOnceWithExactly('boop!'); @@ -356,7 +374,7 @@ describe('operate', () => { const subscriber = operate({ destination, - }) + }); subscriber.error('boop!'); expect(error).to.have.been.calledOnceWithExactly('boop!'); @@ -375,8 +393,8 @@ describe('operate', () => { const subscriber = operate({ destination, error() { - throw 'boop!' - } + throw 'boop!'; + }, }); subscriber.error('no boop for you'); @@ -416,8 +434,8 @@ describe('operate', () => { const subscriber = operate({ destination, complete() { - throw 'boop!' - } + throw 'boop!'; + }, }); subscriber.complete(); @@ -438,4 +456,4 @@ describe('operate', () => { destination.unsubscribe(); expect(finalizer).to.have.been.calledOnce; }); -}); \ No newline at end of file +}); diff --git a/packages/rxjs/spec/Subscription-spec.ts b/packages/rxjs/spec/Subscription-spec.ts index 52ea7b7793..82b6a4b128 100644 --- a/packages/rxjs/spec/Subscription-spec.ts +++ b/packages/rxjs/spec/Subscription-spec.ts @@ -57,7 +57,7 @@ describe('Subscription', () => { main.add({ unsubscribe() { isCalled = true; - } + }, }); main.unsubscribe(); expect(isCalled).to.be.true; @@ -70,7 +70,7 @@ describe('Subscription', () => { main.add({ unsubscribe() { isCalled = true; - } + }, }); expect(isCalled).to.be.true; }); @@ -107,8 +107,8 @@ describe('Subscription', () => { const unsubscribable = { unsubscribe() { isCalled = true; - } - } + }, + }; main.add(unsubscribable); main.remove(unsubscribable); main.unsubscribe(); @@ -164,12 +164,12 @@ describe('Subscription', () => { const source2 = new Observable(() => { return () => { finalizers.push(2); - sub.add(({ + sub.add({ unsubscribe: () => { expect(sub.closed).to.be.true; throw new Error('Who is your daddy, and what does he do?'); - } - })); + }, + }); }; }); @@ -204,10 +204,18 @@ describe('Subscription', () => { it('should unsubscribe from all parents', () => { // https://github.com/ReactiveX/rxjs/issues/6351 - const a = new Subscription(() => { /* noop */}); - const b = new Subscription(() => { /* noop */}); - const c = new Subscription(() => { /* noop */}); - const d = new Subscription(() => { /* noop */}); + const a = new Subscription(() => { + /* noop */ + }); + const b = new Subscription(() => { + /* noop */ + }); + const c = new Subscription(() => { + /* noop */ + }); + const d = new Subscription(() => { + /* noop */ + }); a.add(d); b.add(d); c.add(d); @@ -237,11 +245,10 @@ describe('Subscription[Symbol.dispose] implementation', () => { // This is just a sanity check. const callback = sinon.spy(); const subscription = new Subscription(); - + subscription.add(callback); subscription[Symbol.dispose](); expect(callback).to.have.been.calledOnce; expect(subscription.closed).to.be.true; }); }); - diff --git a/packages/rxjs/spec/config-spec.ts b/packages/rxjs/spec/config-spec.ts index 6d4fc501fd..b048e50309 100644 --- a/packages/rxjs/spec/config-spec.ts +++ b/packages/rxjs/spec/config-spec.ts @@ -1,5 +1,3 @@ -/** @prettier */ - import { config } from '../src/internal/config'; import { expect } from 'chai'; import { Observable } from 'rxjs'; diff --git a/packages/rxjs/spec/firstValueFrom-spec.ts b/packages/rxjs/spec/firstValueFrom-spec.ts index 55b1fdd849..94580f14bf 100644 --- a/packages/rxjs/spec/firstValueFrom-spec.ts +++ b/packages/rxjs/spec/firstValueFrom-spec.ts @@ -61,7 +61,7 @@ describe('firstValueFrom', () => { it('should stop listening to a synchronous observable when resolved', async () => { const sideEffects: number[] = []; - const synchronousObservable = new Observable(subscriber => { + const synchronousObservable = new Observable((subscriber) => { // This will check to see if the subscriber was closed on each loop // when the unsubscribe hits (from the `take`), it should be closed for (let i = 0; !subscriber.closed && i < 10; i++) { diff --git a/packages/rxjs/spec/helpers/interop-helper-spec.ts b/packages/rxjs/spec/helpers/interop-helper-spec.ts index cc49b94f72..a4b061d686 100644 --- a/packages/rxjs/spec/helpers/interop-helper-spec.ts +++ b/packages/rxjs/spec/helpers/interop-helper-spec.ts @@ -14,4 +14,4 @@ describe('interop helper', () => { const subscriber: any = asInteropSubscriber(new Subscriber()); expect(subscriber).to.not.be.instanceOf(Subscriber); }); -}); \ No newline at end of file +}); diff --git a/packages/rxjs/spec/helpers/interop-helper.ts b/packages/rxjs/spec/helpers/interop-helper.ts index 1537843769..fd7a1537bc 100644 --- a/packages/rxjs/spec/helpers/interop-helper.ts +++ b/packages/rxjs/spec/helpers/interop-helper.ts @@ -19,9 +19,9 @@ export function asInteropObservable(observable: Observable): Observable const { lift, subscribe, ...rest } = Object.getPrototypeOf(target); return { ...rest, - subscribe: interopSubscribe(subscribe) + subscribe: interopSubscribe(subscribe), }; - } + }, }); } @@ -47,7 +47,7 @@ export function asInteropSubscriber(subscriber: Subscriber): Subscriber getPrototypeOf(target: Subscriber) { const { ...rest } = Object.getPrototypeOf(target); return rest; - } + }, }); } diff --git a/packages/rxjs/spec/helpers/marble-testing.ts b/packages/rxjs/spec/helpers/marble-testing.ts index 3ba9927f5a..56b1e06eac 100644 --- a/packages/rxjs/spec/helpers/marble-testing.ts +++ b/packages/rxjs/spec/helpers/marble-testing.ts @@ -7,8 +7,8 @@ import { observableToBeFn, subscriptionLogsToBeFn } from '../../src/internal/tes declare const global: any; export function hot(marbles: string, values?: void, error?: any): HotObservable; -export function hot(marbles: string, values?: { [index: string]: V; }, error?: any): HotObservable; -export function hot(marbles: string, values?: { [index: string]: V; } | void, error?: any): HotObservable { +export function hot(marbles: string, values?: { [index: string]: V }, error?: any): HotObservable; +export function hot(marbles: string, values?: { [index: string]: V } | void, error?: any): HotObservable { if (!global.rxTestScheduler) { throw 'tried to use hot() in async test'; } @@ -16,7 +16,7 @@ export function hot(marbles: string, values?: { [index: string]: V; } | void, } export function cold(marbles: string, values?: void, error?: any): ColdObservable; -export function cold(marbles: string, values?: { [index: string]: V; }, error?: any): ColdObservable; +export function cold(marbles: string, values?: { [index: string]: V }, error?: any): ColdObservable; export function cold(marbles: string, values?: any, error?: any): ColdObservable { if (!global.rxTestScheduler) { throw 'tried to use cold() in async test'; @@ -24,15 +24,14 @@ export function cold(marbles: string, values?: any, error?: any): ColdObservable return global.rxTestScheduler.createColdObservable.apply(global.rxTestScheduler, arguments); } -export function expectObservable(observable: Observable, - unsubscriptionMarbles: string | null = null): ({ toBe: observableToBeFn }) { +export function expectObservable(observable: Observable, unsubscriptionMarbles: string | null = null): { toBe: observableToBeFn } { if (!global.rxTestScheduler) { throw 'tried to use expectObservable() in async test'; } return global.rxTestScheduler.expectObservable.apply(global.rxTestScheduler, arguments); } -export function expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): ({ toBe: subscriptionLogsToBeFn }) { +export function expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): { toBe: subscriptionLogsToBeFn } { if (!global.rxTestScheduler) { throw 'tried to use expectSubscriptions() in async test'; } diff --git a/packages/rxjs/spec/helpers/observableMatcher.ts b/packages/rxjs/spec/helpers/observableMatcher.ts index f361d34e63..5d04af0870 100644 --- a/packages/rxjs/spec/helpers/observableMatcher.ts +++ b/packages/rxjs/spec/helpers/observableMatcher.ts @@ -4,16 +4,19 @@ import * as chai from 'chai'; function stringify(x: any): string { return JSON.stringify(x, function (key: string, value: any) { if (Array.isArray(value)) { - return '[' + value - .map(function (i) { + return ( + '[' + + value.map(function (i) { return '\n\t' + stringify(i); - }) + '\n]'; + }) + + '\n]' + ); } return value; }) - .replace(/\\"/g, '"') - .replace(/\\t/g, '\t') - .replace(/\\n/g, '\n'); + .replace(/\\"/g, '"') + .replace(/\\t/g, '\t') + .replace(/\\n/g, '\n'); } function deleteErrorNotificationStack(marble: any) { @@ -37,10 +40,10 @@ export function observableMatcher(actual: any, expected: any) { } let message = '\nExpected \n'; - actual.forEach((x: any) => message += `\t${stringify(x)}\n`); + actual.forEach((x: any) => (message += `\t${stringify(x)}\n`)); message += '\t\nto deep equal \n'; - expected.forEach((x: any) => message += `\t${stringify(x)}\n`); + expected.forEach((x: any) => (message += `\t${stringify(x)}\n`)); chai.assert(passed, message); } else { diff --git a/packages/rxjs/spec/helpers/setup.ts b/packages/rxjs/spec/helpers/setup.ts index 7ee559ce71..9c5cc52abb 100644 --- a/packages/rxjs/spec/helpers/setup.ts +++ b/packages/rxjs/spec/helpers/setup.ts @@ -7,8 +7,7 @@ import * as sinonChai from 'sinon-chai'; if (typeof Symbol !== 'function') { let id = 0; - const symbolFn: any = (description: string) => - `Symbol_${id++} ${description} (RxJS Testing Polyfill)`; + const symbolFn: any = (description: string) => `Symbol_${id++} ${description} (RxJS Testing Polyfill)`; Symbol = symbolFn; } @@ -25,39 +24,38 @@ if (!(Symbol as any).observable) { // MIT license -(function(this: any, window: any) { +(function (this: any, window: any) { window = window || this; let lastTime = 0; const vendors = ['ms', 'moz', 'webkit', 'o']; for (let x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] - || window[vendors[x] + 'CancelRequestAnimationFrame']; + window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) { - window.requestAnimationFrame = (callback: Function, element: any) => { - const currTime = new Date().getTime(); - const timeToCall = Math.max(0, 16 - (currTime - lastTime)); - const id = window.setTimeout(() => { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; + window.requestAnimationFrame = (callback: Function, element: any) => { + const currTime = new Date().getTime(); + const timeToCall = Math.max(0, 16 - (currTime - lastTime)); + const id = window.setTimeout(() => { + callback(currTime + timeToCall); + }, timeToCall); + lastTime = currTime + timeToCall; + return id; + }; } if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = (id: number) => { - clearTimeout(id); - }; + window.cancelAnimationFrame = (id: number) => { + clearTimeout(id); + }; } -}(global)); +})(global); // Polyfill Symbol.dispose for testing if (typeof Symbol.dispose !== 'symbol') { (Symbol as any).dispose = Symbol('dispose polyfill'); } - //setup sinon-chai chai.use(sinonChai); diff --git a/packages/rxjs/spec/helpers/subscription.ts b/packages/rxjs/spec/helpers/subscription.ts index 60abf24a0d..0663c5df01 100644 --- a/packages/rxjs/spec/helpers/subscription.ts +++ b/packages/rxjs/spec/helpers/subscription.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { TeardownLogic } from 'rxjs'; export function getRegisteredFinalizers(subscription: any): Exclude[] { diff --git a/packages/rxjs/spec/helpers/test-helper.ts b/packages/rxjs/spec/helpers/test-helper.ts index 0780fa1639..58d7ddc423 100644 --- a/packages/rxjs/spec/helpers/test-helper.ts +++ b/packages/rxjs/spec/helpers/test-helper.ts @@ -9,7 +9,7 @@ if (process && process.on) { * it handles the rejected promise where it does not notice * that the test failed. */ - process.on('unhandledRejection', err => { + process.on('unhandledRejection', (err) => { console.error(err); process.exit(1); }); @@ -18,12 +18,14 @@ if (process && process.on) { export function lowerCaseO(...args: Array): Observable { const o: any = { subscribe(observer: any) { - args.forEach(v => observer.next(v)); + args.forEach((v) => observer.next(v)); observer.complete(); return { - unsubscribe() { /* do nothing */ } + unsubscribe() { + /* do nothing */ + }, }; - } + }, }; o[observable] = function (this: any) { @@ -33,30 +35,28 @@ export function lowerCaseO(...args: Array): Observable { return o; } -export const createObservableInputs = (value: T) => of( - of(value), - scheduled([value], asyncScheduler), - [value], - Promise.resolve(value), - { - [iterator]: () => { - const iteratorResults = [ - { value, done: false }, - { done: true } - ]; - return { - next: () => { - return iteratorResults.shift(); - } - }; - } - } as any as Iterable, - { - [observable]: () => of(value) - } as any -) as Observable>; +export const createObservableInputs = (value: T) => + of( + of(value), + scheduled([value], asyncScheduler), + [value], + Promise.resolve(value), + { + [iterator]: () => { + const iteratorResults = [{ value, done: false }, { done: true }]; + return { + next: () => { + return iteratorResults.shift(); + }, + }; + }, + } as any as Iterable, + { + [observable]: () => of(value), + } as any + ) as Observable>; /** * Used to signify no subscriptions took place to `expectSubscriptions` assertions. */ -export const NO_SUBS: string[] = []; \ No newline at end of file +export const NO_SUBS: string[] = []; diff --git a/packages/rxjs/spec/index-spec.ts b/packages/rxjs/spec/index-spec.ts index c0fa93df13..6eaa5ef439 100644 --- a/packages/rxjs/spec/index-spec.ts +++ b/packages/rxjs/spec/index-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import * as index from '../src/index'; import { expect } from 'chai'; diff --git a/packages/rxjs/spec/module-test-spec.mjs b/packages/rxjs/spec/module-test-spec.mjs index 66a4924696..e547b557f3 100644 --- a/packages/rxjs/spec/module-test-spec.mjs +++ b/packages/rxjs/spec/module-test-spec.mjs @@ -5,7 +5,7 @@ If this fails node will error when running this with an error like node:internal/process/esm_loader:74 internalBinding('errors').triggerUncaughtException( */ -import {Observable} from 'rxjs'; +import { Observable } from 'rxjs'; import * as o from 'rxjs/operators'; import * as a from 'rxjs/ajax'; import * as f from 'rxjs/fetch'; diff --git a/packages/rxjs/spec/observables/bindCallback-spec.ts b/packages/rxjs/spec/observables/bindCallback-spec.ts index 9fa943e9fb..8ec7c625cc 100644 --- a/packages/rxjs/spec/observables/bindCallback-spec.ts +++ b/packages/rxjs/spec/observables/bindCallback-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { bindCallback } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/bindNodeCallback-spec.ts b/packages/rxjs/spec/observables/bindNodeCallback-spec.ts index 4f95fcbc45..5c68b96ba1 100644 --- a/packages/rxjs/spec/observables/bindNodeCallback-spec.ts +++ b/packages/rxjs/spec/observables/bindNodeCallback-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { bindNodeCallback } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/combineLatest-spec.ts b/packages/rxjs/spec/observables/combineLatest-spec.ts index 40e76430b0..b04e6f0c91 100644 --- a/packages/rxjs/spec/observables/combineLatest-spec.ts +++ b/packages/rxjs/spec/observables/combineLatest-spec.ts @@ -4,7 +4,6 @@ import { map, mergeMap } from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { observableMatcher } from '../helpers/observableMatcher'; - /** @test {combineLatest} */ describe('static combineLatest', () => { let rxTestScheduler: TestScheduler; @@ -17,11 +16,11 @@ describe('static combineLatest', () => { const results: string[] = []; combineLatest([]).subscribe({ next: () => { - throw new Error('should not emit') + throw new Error('should not emit'); }, complete: () => { results.push('done'); - } + }, }); expect(results).to.deep.equal(['done']); @@ -31,11 +30,11 @@ describe('static combineLatest', () => { const results: string[] = []; combineLatest({}).subscribe({ next: () => { - throw new Error('should not emit') + throw new Error('should not emit'); }, complete: () => { results.push('done'); - } + }, }); expect(results).to.deep.equal(['done']); @@ -55,15 +54,13 @@ describe('static combineLatest', () => { it('should accept a dictionary of observables', () => { rxTestScheduler.run(({ hot, expectObservable }) => { - const firstSource = hot('----a----b----c----|'); + const firstSource = hot('----a----b----c----|'); const secondSource = hot('--d--e--f--g--|'); const expected = ' ----uv--wx-y--z----|'; - const combined = combineLatest({a: firstSource, b: secondSource}).pipe( - map(({a, b}) => '' + a + b) - ); + const combined = combineLatest({ a: firstSource, b: secondSource }).pipe(map(({ a, b }) => '' + a + b)); - expectObservable(combined).toBe(expected, {u: 'ad', v: 'ae', w: 'af', x: 'bf', y: 'bg', z: 'cg'}); + expectObservable(combined).toBe(expected, { u: 'ad', v: 'ae', w: 'af', x: 'bf', y: 'bg', z: 'cg' }); }); }); @@ -547,10 +544,7 @@ describe('static combineLatest', () => { const unsub = ' ---------! '; const values = { x: 'bf', y: 'cf', z: 'cg' }; - const result = combineLatest([ - e1.pipe(mergeMap((x) => of(x))), - e2.pipe(mergeMap((x) => of(x))) - ], (x, y) => x + y).pipe( + const result = combineLatest([e1.pipe(mergeMap((x) => of(x))), e2.pipe(mergeMap((x) => of(x)))], (x, y) => x + y).pipe( mergeMap((x) => of(x)) ); diff --git a/packages/rxjs/spec/observables/concat-spec.ts b/packages/rxjs/spec/observables/concat-spec.ts index af45c95dd4..d0e5c275e3 100644 --- a/packages/rxjs/spec/observables/concat-spec.ts +++ b/packages/rxjs/spec/observables/concat-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { lowerCaseO } from '../helpers/test-helper'; import { asyncScheduler, queueScheduler, concat, of, scheduled, defer, Observable } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/connectable-spec.ts b/packages/rxjs/spec/observables/connectable-spec.ts index d0f25af648..ef297c1183 100644 --- a/packages/rxjs/spec/observables/connectable-spec.ts +++ b/packages/rxjs/spec/observables/connectable-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { connectable, of, ReplaySubject } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/observables/defer-spec.ts b/packages/rxjs/spec/observables/defer-spec.ts index 0574ad62b4..7197300514 100644 --- a/packages/rxjs/spec/observables/defer-spec.ts +++ b/packages/rxjs/spec/observables/defer-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { defer, of } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; diff --git a/packages/rxjs/spec/observables/dom/ajax-spec.ts b/packages/rxjs/spec/observables/dom/ajax-spec.ts index 5f105429de..8826e7a670 100644 --- a/packages/rxjs/spec/observables/dom/ajax-spec.ts +++ b/packages/rxjs/spec/observables/dom/ajax-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { ajax, AjaxConfig, AjaxResponse, AjaxError, AjaxTimeoutError } from 'rxjs/ajax'; diff --git a/packages/rxjs/spec/observables/dom/animationFrames-spec.ts b/packages/rxjs/spec/observables/dom/animationFrames-spec.ts index 3d040968d8..366dc84a4e 100644 --- a/packages/rxjs/spec/observables/dom/animationFrames-spec.ts +++ b/packages/rxjs/spec/observables/dom/animationFrames-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { animationFrames } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/dom/fetch-spec.ts b/packages/rxjs/spec/observables/dom/fetch-spec.ts index 97e97cb35f..6700bf1aba 100644 --- a/packages/rxjs/spec/observables/dom/fetch-spec.ts +++ b/packages/rxjs/spec/observables/dom/fetch-spec.ts @@ -1,9 +1,7 @@ import { fromFetch } from 'rxjs/fetch'; import { expect } from 'chai'; -const root: any = (typeof globalThis !== 'undefined' && globalThis) - || (typeof self !== 'undefined' && self) - || global; +const root: any = (typeof globalThis !== 'undefined' && globalThis) || (typeof self !== 'undefined' && self) || global; const OK_RESPONSE = { ok: true, @@ -82,7 +80,7 @@ class MockAbortSignal { interface MockFetch { (input: string | Request, init?: RequestInit): Promise; - calls: { input: string | Request, init: RequestInit | undefined }[]; + calls: { input: string | Request; init: RequestInit | undefined }[]; reset(): void; respondWith: Response; } @@ -120,7 +118,7 @@ describe('fromFetch', () => { expect(MockAbortController.created).to.equal(0); fetch$.subscribe({ - next: response => { + next: (response) => { expect(response).to.equal(OK_RESPONSE); }, error: done, @@ -135,7 +133,7 @@ describe('fromFetch', () => { expect(mockFetch.calls[0].init!.signal!.aborted).to.be.false; done(); }, 0); - } + }, }); }); @@ -143,7 +141,7 @@ describe('fromFetch', () => { mockFetch.respondWith = { ok: false, status: 400, - body: 'Bad stuff here' + body: 'Bad stuff here', } as any as Response; const fetch$ = fromFetch('/foo'); @@ -151,11 +149,11 @@ describe('fromFetch', () => { expect(MockAbortController.created).to.equal(0); fetch$.subscribe({ - next: response => { + next: (response) => { expect(response).to.equal(mockFetch.respondWith); }, complete: done, - error: done + error: done, }); expect(MockAbortController.created).to.equal(1); @@ -201,7 +199,7 @@ describe('fromFetch', () => { }); it('should allow passing of init object', (done) => { - const fetch$ = fromFetch('/foo', {method: 'HEAD'}); + const fetch$ = fromFetch('/foo', { method: 'HEAD' }); fetch$.subscribe({ error: done, complete: done, @@ -210,7 +208,7 @@ describe('fromFetch', () => { }); it('should add a signal to internal init object without mutating the passed init object', (done) => { - const myInit = {method: 'DELETE'}; + const myInit = { method: 'DELETE' }; const fetch$ = fromFetch('/bar', myInit); fetch$.subscribe({ error: done, @@ -226,10 +224,10 @@ describe('fromFetch', () => { const signal = controller.signal as any; const fetch$ = fromFetch('/foo', { signal }); const subscription = fetch$.subscribe({ - error: err => { + error: (err) => { expect(err).to.be.instanceof(MockDOMException); done(); - } + }, }); controller.abort(); expect(mockFetch.calls[0].init!.signal!.aborted).to.be.true; @@ -243,10 +241,10 @@ describe('fromFetch', () => { const signal = controller.signal as any; const fetch$ = fromFetch('/foo', { signal }); const subscription = fetch$.subscribe({ - error: err => { + error: (err) => { expect(err).to.be.instanceof(MockDOMException); done(); - } + }, }); expect(mockFetch.calls[0].init!.signal!.aborted).to.be.true; // The subscription will not be closed until the error fires when the promise resolves. @@ -271,16 +269,16 @@ describe('fromFetch', () => { it('should support a selector', (done) => { mockFetch.respondWith = { ...OK_RESPONSE, - text: () => Promise.resolve('bar') + text: () => Promise.resolve('bar'), }; const fetch$ = fromFetch('/foo', { - selector: response => response.text() + selector: (response) => response.text(), }); expect(mockFetch.calls.length).to.equal(0); expect(MockAbortController.created).to.equal(0); fetch$.subscribe({ - next: text => { + next: (text) => { expect(text).to.equal('bar'); }, error: done, @@ -295,17 +293,17 @@ describe('fromFetch', () => { expect(mockFetch.calls[0].init!.signal!.aborted).to.be.false; done(); }, 0); - } + }, }); }); it('should abort when unsubscribed and a selector is specified', () => { mockFetch.respondWith = { ...OK_RESPONSE, - text: () => Promise.resolve('bar') + text: () => Promise.resolve('bar'), }; const fetch$ = fromFetch('/foo', { - selector: response => response.text() + selector: (response) => response.text(), }); expect(mockFetch.calls.length).to.equal(0); expect(MockAbortController.created).to.equal(0); diff --git a/packages/rxjs/spec/observables/dom/webSocket-spec.ts b/packages/rxjs/spec/observables/dom/webSocket-spec.ts index 6b3e176d2d..86edcfb650 100644 --- a/packages/rxjs/spec/observables/dom/webSocket-spec.ts +++ b/packages/rxjs/spec/observables/dom/webSocket-spec.ts @@ -3,15 +3,13 @@ import * as sinon from 'sinon'; import { webSocket } from 'rxjs/webSocket'; import { map, retry, take, repeat, takeWhile } from 'rxjs/operators'; -const root: any = (typeof globalThis !== 'undefined' && globalThis) - || (typeof self !== 'undefined' && self) - || global; +const root: any = (typeof globalThis !== 'undefined' && globalThis) || (typeof self !== 'undefined' && self) || global; enum WebSocketState { CONNECTING = 0, OPEN = 1, CLOSING = 2, - CLOSED = 3 + CLOSED = 3, } /** @test {webSocket} */ @@ -43,7 +41,7 @@ describe('webSocket', () => { subject.next('ping'); - subject.subscribe(x => { + subject.subscribe((x) => { expect(x).to.equal('pong'); messageReceived = true; }); @@ -64,10 +62,7 @@ describe('webSocket', () => { const subject = webSocket('ws://mysocket'); const results: any[] = []; - subject.pipe( - map(x => x + '!'), - ) - .subscribe(x => results.push(x)); + subject.pipe(map((x) => x + '!')).subscribe((x) => results.push(x)); MockWebSocket.lastSocket.triggerMessage(JSON.stringify('ngconf 2018 bug')); @@ -79,7 +74,7 @@ describe('webSocket', () => { const results: string[] = []; const subject = webSocket('ws://mysocket'); - subject.subscribe(x => { + subject.subscribe((x) => { results.push(x); }); @@ -87,7 +82,7 @@ describe('webSocket', () => { socket.open(); - expected.forEach(x => { + expected.forEach((x) => { socket.triggerMessage(JSON.stringify(x)); }); @@ -100,7 +95,7 @@ describe('webSocket', () => { const expected = ['make', 'him', 'walk', 'the', 'plank']; const subject = webSocket('ws://mysocket'); - expected.forEach(x => { + expected.forEach((x) => { subject.next(x); }); @@ -226,7 +221,7 @@ describe('webSocket', () => { // Close socket after socket2 has opened socket2.open(); expect(socket2.readyState).to.equal(WebSocketState.OPEN); - socket.triggerClose({wasClean: true}); + socket.triggerClose({ wasClean: true }); expect(socket.readyState).to.equal(WebSocketState.CLOSED); expect(socket2.close).have.not.been.called; @@ -247,7 +242,7 @@ describe('webSocket', () => { sinon.spy(socket, 'close'); expect(socket.close).not.have.been.called; - subject.error({ code: 1337, reason: 'Too bad, so sad :('}); + subject.error({ code: 1337, reason: 'Too bad, so sad :(' }); expect(socket.close).have.been.calledWith(1337, 'Too bad, so sad :('); subject.unsubscribe(); @@ -310,7 +305,6 @@ describe('webSocket', () => { }); describe('with a config object', () => { - beforeEach(() => { setupMockWebSocket(); }); @@ -325,7 +319,7 @@ describe('webSocket', () => { subject.next('ping'); - subject.subscribe(x => { + subject.subscribe((x) => { expect(x).to.equal('pong'); messageReceived = true; }); @@ -345,7 +339,7 @@ describe('webSocket', () => { it('should take a protocol and set it properly on the web socket', () => { const subject = webSocket({ url: 'ws://mysocket', - protocol: 'someprotocol' + protocol: 'someprotocol', }); subject.subscribe(); @@ -359,7 +353,7 @@ describe('webSocket', () => { it('should take a binaryType and set it properly on the web socket', () => { const subject = webSocket({ url: 'ws://mysocket', - binaryType: 'blob' + binaryType: 'blob', }); subject.subscribe(); @@ -377,7 +371,7 @@ describe('webSocket', () => { url: 'ws://mysocket', deserializer: (e: any) => { return e.data + '!'; - } + }, }); subject.subscribe((x: any) => { @@ -400,14 +394,17 @@ describe('webSocket', () => { url: 'ws://mysocket', deserializer: (e: any) => { throw new Error('I am a bad error'); - } + }, }); - subject.subscribe({ next: (x: any) => { - expect(x).to.equal('this should not happen'); - }, error: (err: any) => { - expect(err).to.be.an('error', 'I am a bad error'); - } }); + subject.subscribe({ + next: (x: any) => { + expect(x).to.equal('this should not happen'); + }, + error: (err: any) => { + expect(err).to.be.an('error', 'I am a bad error'); + }, + }); const socket = MockWebSocket.lastSocket; socket.open(); @@ -424,8 +421,8 @@ describe('webSocket', () => { next(x: any) { calls++; expect(x).to.be.an('undefined'); - } - } + }, + }, }); subject.subscribe(); @@ -455,8 +452,8 @@ describe('webSocket', () => { closeObserver: { next(e: any) { closes.push(e); - } - } + }, + }, }); subject.subscribe(); @@ -468,9 +465,11 @@ describe('webSocket', () => { socket.triggerClose(expected[0]); expect(closes.length).to.equal(1); - subject.subscribe({ error: function (err) { - expect(err).to.equal(expected[1]); - } }); + subject.subscribe({ + error: function (err) { + expect(err).to.equal(expected[1]); + }, + }); socket = MockWebSocket.lastSocket; socket.open(); @@ -489,21 +488,23 @@ describe('webSocket', () => { url: 'bad_url', WebSocketCtor: (url: string, protocol?: string | string[]): WebSocket => { throw new Error(`connection refused`); - } + }, }); - subject.subscribe({ next: (x: any) => { - expect(x).to.equal('this should not happen'); - }, error: (err: any) => { - expect(err).to.be.an('error', 'connection refused'); - } }); + subject.subscribe({ + next: (x: any) => { + expect(x).to.equal('this should not happen'); + }, + error: (err: any) => { + expect(err).to.be.an('error', 'connection refused'); + }, + }); subject.unsubscribe(); }); }); describe('multiplex', () => { - beforeEach(() => { setupMockWebSocket(); }); @@ -514,20 +515,22 @@ describe('webSocket', () => { it('should be retryable', () => { const results = [] as string[]; - const subject = webSocket<{ name: string, value: string }>('ws://websocket'); + const subject = webSocket<{ name: string; value: string }>('ws://websocket'); const source = subject.multiplex( () => ({ sub: 'foo' }), () => ({ unsub: 'foo' }), - value => value.name === 'foo' + (value) => value.name === 'foo' ); - source.pipe( - retry(1), - map(x => x.value), - take(2), - ).subscribe(x => { - results.push(x); - }); + source + .pipe( + retry(1), + map((x) => x.value), + take(2) + ) + .subscribe((x) => { + results.push(x); + }); const socket = MockWebSocket.lastSocket; socket.open(); @@ -549,19 +552,19 @@ describe('webSocket', () => { it('should be repeatable', () => { const results = [] as string[]; - const subject = webSocket<{ name: string, value: string }>('ws://websocket'); + const subject = webSocket<{ name: string; value: string }>('ws://websocket'); const source = subject.multiplex( () => ({ sub: 'foo' }), () => ({ unsub: 'foo' }), - value => value.name === 'foo' + (value) => value.name === 'foo' ); source .pipe( repeat(2), - map(x => x.value) + map((x) => x.value) ) - .subscribe(x => { + .subscribe((x) => { results.push(x); }); @@ -586,12 +589,12 @@ describe('webSocket', () => { }); it('should multiplex over the webSocket', () => { - const results = [] as Array<{ value: number, name: string }>; - const subject = webSocket<{ value: number, name: string }>('ws://websocket'); + const results = [] as Array<{ value: number; name: string }>; + const subject = webSocket<{ value: number; name: string }>('ws://websocket'); const source = subject.multiplex( - () => ({ sub: 'foo'}), + () => ({ sub: 'foo' }), () => ({ unsub: 'foo' }), - value => value.name === 'foo' + (value) => value.name === 'foo' ); const sub = source.subscribe(function (x: any) { @@ -602,14 +605,16 @@ describe('webSocket', () => { expect(socket.lastMessageSent).to.deep.equal(JSON.stringify({ sub: 'foo' })); - [1, 2, 3, 4, 5].map((x: number) => { - return { - name: x % 3 === 0 ? 'bar' : 'foo', - value: x - }; - }).forEach((x: any) => { - socket.triggerMessage(JSON.stringify(x)); - }); + [1, 2, 3, 4, 5] + .map((x: number) => { + return { + name: x % 3 === 0 ? 'bar' : 'foo', + value: x, + }; + }) + .forEach((x: any) => { + socket.triggerMessage(JSON.stringify(x)); + }); expect(results).to.deep.equal([1, 2, 4, 5]); @@ -622,34 +627,34 @@ describe('webSocket', () => { }); it('should keep the same socket for multiple multiplex subscriptions', () => { - const socketSubject = webSocket({url: 'ws://mysocket'}); + const socketSubject = webSocket({ url: 'ws://mysocket' }); const results = [] as string[]; - const socketMessages = [ - {id: 'A'}, - {id: 'B'}, - {id: 'A'}, - {id: 'B'}, - {id: 'B'}, - ]; - - const sub1 = socketSubject.multiplex( - () => 'no-op', - () => results.push('A unsub'), - (req: any) => req.id === 'A' - ).pipe( - takeWhile((req: any) => !req.complete) - ) - .subscribe( - { next: () => results.push('A next'), error: (e) => results.push('A error ' + e), complete: () => results.push('A complete') } - ); + const socketMessages = [{ id: 'A' }, { id: 'B' }, { id: 'A' }, { id: 'B' }, { id: 'B' }]; + + const sub1 = socketSubject + .multiplex( + () => 'no-op', + () => results.push('A unsub'), + (req: any) => req.id === 'A' + ) + .pipe(takeWhile((req: any) => !req.complete)) + .subscribe({ + next: () => results.push('A next'), + error: (e) => results.push('A error ' + e), + complete: () => results.push('A complete'), + }); - socketSubject.multiplex( - () => 'no-op', - () => results.push('B unsub'), - (req: any) => req.id === 'B') - .subscribe( - { next: () => results.push('B next'), error: (e) => results.push('B error ' + e), complete: () => results.push('B complete') } - ); + socketSubject + .multiplex( + () => 'no-op', + () => results.push('B unsub'), + (req: any) => req.id === 'B' + ) + .subscribe({ + next: () => results.push('B next'), + error: (e) => results.push('B error ' + e), + complete: () => results.push('B complete'), + }); // Setup socket and send messages let socket = MockWebSocket.lastSocket; @@ -663,47 +668,39 @@ describe('webSocket', () => { }); socket.triggerClose({ wasClean: true }); - expect(results).to.deep.equal([ - 'A next', - 'A unsub', - 'B next', - 'B next', - 'B next', - 'B complete', - 'B unsub', - ]); + expect(results).to.deep.equal(['A next', 'A unsub', 'B next', 'B next', 'B next', 'B complete', 'B unsub']); }); it('should not close the socket until all subscriptions complete', () => { - const socketSubject = webSocket<{ id: string, complete: boolean }>({url: 'ws://mysocket'}); + const socketSubject = webSocket<{ id: string; complete: boolean }>({ url: 'ws://mysocket' }); const results = [] as string[]; - const socketMessages = [ - {id: 'A'}, - {id: 'B'}, - {id: 'A', complete: true}, - {id: 'B'}, - {id: 'B', complete: true}, - ]; - - socketSubject.multiplex( - () => 'no-op', - () => results.push('A unsub'), - req => req.id === 'A' - ).pipe( - takeWhile(req => !req.complete) - ).subscribe( - { next: () => results.push('A next'), error: (e) => results.push('A error ' + e), complete: () => results.push('A complete') } - ); + const socketMessages = [{ id: 'A' }, { id: 'B' }, { id: 'A', complete: true }, { id: 'B' }, { id: 'B', complete: true }]; - socketSubject.multiplex( - () => 'no-op', - () => results.push('B unsub'), - req => req.id === 'B' - ).pipe( - takeWhile(req => !req.complete) - ).subscribe( - { next: () => results.push('B next'), error: (e) => results.push('B error ' + e), complete: () => results.push('B complete') } - ); + socketSubject + .multiplex( + () => 'no-op', + () => results.push('A unsub'), + (req) => req.id === 'A' + ) + .pipe(takeWhile((req) => !req.complete)) + .subscribe({ + next: () => results.push('A next'), + error: (e) => results.push('A error ' + e), + complete: () => results.push('A complete'), + }); + + socketSubject + .multiplex( + () => 'no-op', + () => results.push('B unsub'), + (req) => req.id === 'B' + ) + .pipe(takeWhile((req) => !req.complete)) + .subscribe({ + next: () => results.push('B next'), + error: (e) => results.push('B error ' + e), + complete: () => results.push('B complete'), + }); // Setup socket and send messages let socket = MockWebSocket.lastSocket; @@ -712,15 +709,7 @@ describe('webSocket', () => { socket.triggerMessage(JSON.stringify(msg)); }); - expect(results).to.deep.equal([ - 'A next', - 'B next', - 'A unsub', - 'A complete', - 'B next', - 'B unsub', - 'B complete', - ]); + expect(results).to.deep.equal(['A next', 'B next', 'A unsub', 'A complete', 'B next', 'B unsub', 'B complete']); }); }); @@ -729,12 +718,12 @@ describe('webSocket', () => { let messageReceived = false; const subject = webSocket({ url: 'ws://mysocket', - WebSocketCtor: MockWebSocket + WebSocketCtor: MockWebSocket, }); subject.next('ping'); - subject.subscribe(x => { + subject.subscribe((x) => { expect(x).to.equal('pong'); messageReceived = true; }); @@ -752,16 +741,13 @@ describe('webSocket', () => { }); it('should handle constructor errors if no WebSocketCtor', () => { - expect(() => { const subject = webSocket({ - url: 'ws://mysocket' + url: 'ws://mysocket', }); }).to.throw('no WebSocket constructor can be found'); - }); }); - }); class MockWebSocket { diff --git a/packages/rxjs/spec/observables/empty-spec.ts b/packages/rxjs/spec/observables/empty-spec.ts index 291ba69e68..1c8cc32873 100644 --- a/packages/rxjs/spec/observables/empty-spec.ts +++ b/packages/rxjs/spec/observables/empty-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { EMPTY } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/observables/forkJoin-spec.ts b/packages/rxjs/spec/observables/forkJoin-spec.ts index b53fa79e71..698fb07b91 100644 --- a/packages/rxjs/spec/observables/forkJoin-spec.ts +++ b/packages/rxjs/spec/observables/forkJoin-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { EmptyError, finalize, forkJoin, map, of, timer } from 'rxjs'; import { lowerCaseO } from '../helpers/test-helper'; diff --git a/packages/rxjs/spec/observables/from-promise-spec.ts b/packages/rxjs/spec/observables/from-promise-spec.ts index b06382a7e3..014d595135 100644 --- a/packages/rxjs/spec/observables/from-promise-spec.ts +++ b/packages/rxjs/spec/observables/from-promise-spec.ts @@ -6,82 +6,107 @@ import { from } from 'rxjs'; describe('from (fromPromise)', () => { it('should emit one value from a resolved promise', (done) => { const promise = Promise.resolve(42); - from(promise) - .subscribe( - { next: (x) => { expect(x).to.equal(42); }, error: (x) => { - done(new Error('should not be called')); - }, complete: () => { - done(); - } }); + from(promise).subscribe({ + next: (x) => { + expect(x).to.equal(42); + }, + error: (x) => { + done(new Error('should not be called')); + }, + complete: () => { + done(); + }, + }); }); it('should raise error from a rejected promise', (done) => { const promise = Promise.reject('bad'); - from(promise) - .subscribe({ next: (x) => { - done(new Error('should not be called')); - }, error: (e) => { - expect(e).to.equal('bad'); - done(); - }, complete: () => { - done(new Error('should not be called')); - } }); + from(promise).subscribe({ + next: (x) => { + done(new Error('should not be called')); + }, + error: (e) => { + expect(e).to.equal('bad'); + done(); + }, + complete: () => { + done(new Error('should not be called')); + }, + }); }); it('should share the underlying promise with multiple subscribers', (done) => { const promise = Promise.resolve(42); const observable = from(promise); - observable - .subscribe( - { next: (x) => { expect(x).to.equal(42); }, error: (x) => { - done(new Error('should not be called')); - } }); + observable.subscribe({ + next: (x) => { + expect(x).to.equal(42); + }, + error: (x) => { + done(new Error('should not be called')); + }, + }); setTimeout(() => { - observable - .subscribe( - { next: (x) => { expect(x).to.equal(42); }, error: (x) => { - done(new Error('should not be called')); - }, complete: () => { - done(); - } }); + observable.subscribe({ + next: (x) => { + expect(x).to.equal(42); + }, + error: (x) => { + done(new Error('should not be called')); + }, + complete: () => { + done(); + }, + }); }); }); it('should accept already-resolved Promise', (done) => { const promise = Promise.resolve(42); - promise.then((x) => { - expect(x).to.equal(42); - from(promise) - .subscribe( - { next: (y) => { expect(y).to.equal(42); }, error: (x) => { + promise.then( + (x) => { + expect(x).to.equal(42); + from(promise).subscribe({ + next: (y) => { + expect(y).to.equal(42); + }, + error: (x) => { done(new Error('should not be called')); - }, complete: () => { + }, + complete: () => { done(); - } }); - }, () => { - done(new Error('should not be called')); - }); + }, + }); + }, + () => { + done(new Error('should not be called')); + } + ); }); it('should accept PromiseLike object for interoperability', (done) => { class CustomPromise implements PromiseLike { - constructor(private promise: PromiseLike) { - } + constructor(private promise: PromiseLike) {} then( onFulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, - onRejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike { + onRejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null + ): PromiseLike { return new CustomPromise(this.promise.then(onFulfilled, onRejected)); } } const promise = new CustomPromise(Promise.resolve(42)); - from(promise) - .subscribe( - { next: (x) => { expect(x).to.equal(42); }, error: () => { - done(new Error('should not be called')); - }, complete: () => { - done(); - } }); + from(promise).subscribe({ + next: (x) => { + expect(x).to.equal(42); + }, + error: () => { + done(new Error('should not be called')); + }, + complete: () => { + done(); + }, + }); }); it('should not emit, throw or complete if immediately unsubscribed', (done) => { @@ -89,8 +114,7 @@ describe('from (fromPromise)', () => { const throwSpy = sinon.spy(); const completeSpy = sinon.spy(); const promise = Promise.resolve(42); - const subscription = from(promise) - .subscribe({ next: nextSpy, error: throwSpy, complete: completeSpy }); + const subscription = from(promise).subscribe({ next: nextSpy, error: throwSpy, complete: completeSpy }); subscription.unsubscribe(); setTimeout(() => { diff --git a/packages/rxjs/spec/observables/from-spec.ts b/packages/rxjs/spec/observables/from-spec.ts index e51a97891c..b54c64971c 100644 --- a/packages/rxjs/spec/observables/from-spec.ts +++ b/packages/rxjs/spec/observables/from-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { TestScheduler } from 'rxjs/testing'; import { asyncScheduler, of, from, Observer, observable, Subject, noop, Subscription } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/fromEvent-spec.ts b/packages/rxjs/spec/observables/fromEvent-spec.ts index 31f6f906dc..e03deeee35 100644 --- a/packages/rxjs/spec/observables/fromEvent-spec.ts +++ b/packages/rxjs/spec/observables/fromEvent-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { fromEvent, NEVER, timer } from 'rxjs'; import { mapTo, take, concatWith } from 'rxjs/operators'; diff --git a/packages/rxjs/spec/observables/fromEventPattern-spec.ts b/packages/rxjs/spec/observables/fromEventPattern-spec.ts index a333380b43..a63cfe8718 100644 --- a/packages/rxjs/spec/observables/fromEventPattern-spec.ts +++ b/packages/rxjs/spec/observables/fromEventPattern-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; diff --git a/packages/rxjs/spec/observables/generate-spec.ts b/packages/rxjs/spec/observables/generate-spec.ts index 6070d7b88b..c46a227457 100644 --- a/packages/rxjs/spec/observables/generate-spec.ts +++ b/packages/rxjs/spec/observables/generate-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { TestScheduler } from 'rxjs/testing'; import { expect } from 'chai'; import { generate } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/if-spec.ts b/packages/rxjs/spec/observables/if-spec.ts index 0f494d94b8..d625e1f91d 100644 --- a/packages/rxjs/spec/observables/if-spec.ts +++ b/packages/rxjs/spec/observables/if-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { iif, of } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/observables/interval-spec.ts b/packages/rxjs/spec/observables/interval-spec.ts index e5381a1656..bca583957d 100644 --- a/packages/rxjs/spec/observables/interval-spec.ts +++ b/packages/rxjs/spec/observables/interval-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { NEVER, interval, asapScheduler, animationFrameScheduler, queueScheduler } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/observables/merge-spec.ts b/packages/rxjs/spec/observables/merge-spec.ts index 8f2e3e72a3..558fe85488 100644 --- a/packages/rxjs/spec/observables/merge-spec.ts +++ b/packages/rxjs/spec/observables/merge-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { lowerCaseO } from '../helpers/test-helper'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/observables/never-spec.ts b/packages/rxjs/spec/observables/never-spec.ts index 34c3badc64..c6cb3f37e7 100644 --- a/packages/rxjs/spec/observables/never-spec.ts +++ b/packages/rxjs/spec/observables/never-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { NEVER } from 'rxjs'; import { expect } from 'chai'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/observables/of-spec.ts b/packages/rxjs/spec/observables/of-spec.ts index e18bbc4d16..95c743952f 100644 --- a/packages/rxjs/spec/observables/of-spec.ts +++ b/packages/rxjs/spec/observables/of-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { of } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/observables/onErrorResumeNext-spec.ts b/packages/rxjs/spec/observables/onErrorResumeNext-spec.ts index e5f6f367a9..20ad5192d2 100644 --- a/packages/rxjs/spec/observables/onErrorResumeNext-spec.ts +++ b/packages/rxjs/spec/observables/onErrorResumeNext-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { onErrorResumeNext, of } from 'rxjs'; import { finalize } from 'rxjs/operators'; import { expect } from 'chai'; diff --git a/packages/rxjs/spec/observables/partition-spec.ts b/packages/rxjs/spec/observables/partition-spec.ts index 4811733e23..d07c0ccfe0 100644 --- a/packages/rxjs/spec/observables/partition-spec.ts +++ b/packages/rxjs/spec/observables/partition-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { Observable, partition, of } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; diff --git a/packages/rxjs/spec/observables/race-spec.ts b/packages/rxjs/spec/observables/race-spec.ts index 9934a8fe5f..b542250ef2 100644 --- a/packages/rxjs/spec/observables/race-spec.ts +++ b/packages/rxjs/spec/observables/race-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { race, of } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; import { expect } from 'chai'; diff --git a/packages/rxjs/spec/observables/range-spec.ts b/packages/rxjs/spec/observables/range-spec.ts index 420fd9d914..2b633994ae 100644 --- a/packages/rxjs/spec/observables/range-spec.ts +++ b/packages/rxjs/spec/observables/range-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { asapScheduler as asap, range, of } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/throwError-spec.ts b/packages/rxjs/spec/observables/throwError-spec.ts index 0bcbc899d6..cad3aff76d 100644 --- a/packages/rxjs/spec/observables/throwError-spec.ts +++ b/packages/rxjs/spec/observables/throwError-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { TestScheduler } from 'rxjs/testing'; import { throwError } from 'rxjs'; diff --git a/packages/rxjs/spec/observables/using-spec.ts b/packages/rxjs/spec/observables/using-spec.ts index 9126d60746..6ea2f34fe8 100644 --- a/packages/rxjs/spec/observables/using-spec.ts +++ b/packages/rxjs/spec/observables/using-spec.ts @@ -6,10 +6,9 @@ describe('using', () => { it('should dispose of the resource when the subscription is disposed', (done) => { let disposed = false; const source = using( - () => new Subscription(() => disposed = true), + () => new Subscription(() => (disposed = true)), (resource) => range(0, 3) - ) - .pipe(take(2)); + ).pipe(take(2)); source.subscribe(); @@ -25,16 +24,24 @@ describe('using', () => { let disposed = false; const e1 = using( - () => new Subscription(() => disposed = true), - (resource) => new Promise((resolve: any) => { resolve(expected); })); + () => new Subscription(() => (disposed = true)), + (resource) => + new Promise((resolve: any) => { + resolve(expected); + }) + ); - e1.subscribe({ next: x => { - expect(x).to.equal(expected); - }, error: (x) => { - done(new Error('should not be called')); - }, complete: () => { - done(); - } }); + e1.subscribe({ + next: (x) => { + expect(x).to.equal(expected); + }, + error: (x) => { + done(new Error('should not be called')); + }, + complete: () => { + done(); + }, + }); }); it('should accept factory returns promise rejects', (done) => { @@ -42,17 +49,25 @@ describe('using', () => { let disposed = false; const e1 = using( - () => new Subscription(() => disposed = true), - (resource) => new Promise((resolve: any, reject: any) => { reject(expected); })); + () => new Subscription(() => (disposed = true)), + (resource) => + new Promise((resolve: any, reject: any) => { + reject(expected); + }) + ); - e1.subscribe({ next: x => { - done(new Error('should not be called')); - }, error: (x) => { - expect(x).to.equal(expected); - done(); - }, complete: () => { - done(new Error('should not be called')); - } }); + e1.subscribe({ + next: (x) => { + done(new Error('should not be called')); + }, + error: (x) => { + expect(x).to.equal(expected); + done(); + }, + complete: () => { + done(new Error('should not be called')); + }, + }); }); it('should raise error when resource factory throws', (done) => { @@ -68,14 +83,18 @@ describe('using', () => { } ); - source.subscribe({ next: (x) => { - done(new Error('should not be called')); - }, error: (x) => { - expect(x).to.equal(expectedError); - done(); - }, complete: () => { - done(new Error('should not be called')); - } }); + source.subscribe({ + next: (x) => { + done(new Error('should not be called')); + }, + error: (x) => { + expect(x).to.equal(expectedError); + done(); + }, + complete: () => { + done(new Error('should not be called')); + }, + }); }); it('should raise error when observable factory throws', (done) => { @@ -83,19 +102,23 @@ describe('using', () => { let disposed = false; const source = using( - () => new Subscription(() => disposed = true), + () => new Subscription(() => (disposed = true)), (resource) => { throw error; } ); - source.subscribe({ next: (x) => { - done(new Error('should not be called')); - }, error: (x) => { - expect(x).to.equal(error); - done(); - }, complete: () => { - done(new Error('should not be called')); - } }); + source.subscribe({ + next: (x) => { + done(new Error('should not be called')); + }, + error: (x) => { + expect(x).to.equal(error); + done(); + }, + complete: () => { + done(new Error('should not be called')); + }, + }); }); }); diff --git a/packages/rxjs/spec/observables/zip-spec.ts b/packages/rxjs/spec/observables/zip-spec.ts index 7a483edd0e..90fbdf3602 100644 --- a/packages/rxjs/spec/observables/zip-spec.ts +++ b/packages/rxjs/spec/observables/zip-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { queueScheduler as rxQueueScheduler, zip, from, scheduled } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/operators/takeUntil-spec.ts b/packages/rxjs/spec/operators/takeUntil-spec.ts index fff6d152c0..9c1db97510 100644 --- a/packages/rxjs/spec/operators/takeUntil-spec.ts +++ b/packages/rxjs/spec/operators/takeUntil-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { takeUntil, mergeMap, tap } from 'rxjs/operators'; import { of, EMPTY, Subject, merge } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; diff --git a/packages/rxjs/spec/scheduled/scheduled-spec.ts b/packages/rxjs/spec/scheduled/scheduled-spec.ts index c4628bb663..f73d65e4b9 100644 --- a/packages/rxjs/spec/scheduled/scheduled-spec.ts +++ b/packages/rxjs/spec/scheduled/scheduled-spec.ts @@ -43,8 +43,12 @@ describe('scheduled', () => { const results: any[] = []; const input = Promise.resolve('x'); // strings are iterables scheduled(input, testScheduler).subscribe({ - next(value) { results.push(value); }, - complete() { results.push('done'); }, + next(value) { + results.push(value); + }, + complete() { + results.push('done'); + }, }); expect(results).to.deep.equal([]); diff --git a/packages/rxjs/spec/schedulers/AnimationFrameScheduler-spec.ts b/packages/rxjs/spec/schedulers/AnimationFrameScheduler-spec.ts index 992a7616d2..fd907efe63 100644 --- a/packages/rxjs/spec/schedulers/AnimationFrameScheduler-spec.ts +++ b/packages/rxjs/spec/schedulers/AnimationFrameScheduler-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { animationFrameScheduler, Subscription, merge } from 'rxjs'; diff --git a/packages/rxjs/spec/schedulers/AsapScheduler-spec.ts b/packages/rxjs/spec/schedulers/AsapScheduler-spec.ts index 19c8f0d5ad..fe73409138 100644 --- a/packages/rxjs/spec/schedulers/AsapScheduler-spec.ts +++ b/packages/rxjs/spec/schedulers/AsapScheduler-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { asapScheduler, Subscription, SchedulerAction, merge } from 'rxjs'; diff --git a/packages/rxjs/spec/schedulers/QueueScheduler-spec.ts b/packages/rxjs/spec/schedulers/QueueScheduler-spec.ts index 6f5bd64273..fec4301208 100644 --- a/packages/rxjs/spec/schedulers/QueueScheduler-spec.ts +++ b/packages/rxjs/spec/schedulers/QueueScheduler-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import * as sinon from 'sinon'; import { queueScheduler, Subscription, merge } from 'rxjs'; diff --git a/packages/rxjs/spec/schedulers/TestScheduler-spec.ts b/packages/rxjs/spec/schedulers/TestScheduler-spec.ts index bb523c4d46..9bf45fac34 100644 --- a/packages/rxjs/spec/schedulers/TestScheduler-spec.ts +++ b/packages/rxjs/spec/schedulers/TestScheduler-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { TestScheduler } from 'rxjs/testing'; import { Observable, Subject, of, merge, animationFrameScheduler, asapScheduler, asyncScheduler, interval } from 'rxjs'; diff --git a/packages/rxjs/spec/schedulers/VirtualTimeScheduler-spec.ts b/packages/rxjs/spec/schedulers/VirtualTimeScheduler-spec.ts index 2b48000417..f2c2189664 100644 --- a/packages/rxjs/spec/schedulers/VirtualTimeScheduler-spec.ts +++ b/packages/rxjs/spec/schedulers/VirtualTimeScheduler-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { SchedulerAction, VirtualAction, VirtualTimeScheduler } from 'rxjs'; diff --git a/packages/rxjs/spec/schedulers/animationFrameProvider-spec.ts b/packages/rxjs/spec/schedulers/animationFrameProvider-spec.ts index 31f9dd3ce8..7cd80bab95 100644 --- a/packages/rxjs/spec/schedulers/animationFrameProvider-spec.ts +++ b/packages/rxjs/spec/schedulers/animationFrameProvider-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { animationFrameProvider } from 'rxjs/internal/scheduler/animationFrameProvider'; diff --git a/packages/rxjs/spec/schedulers/dateTimestampProvider-spec.ts b/packages/rxjs/spec/schedulers/dateTimestampProvider-spec.ts index 3b45cb948c..7a4e476fc2 100644 --- a/packages/rxjs/spec/schedulers/dateTimestampProvider-spec.ts +++ b/packages/rxjs/spec/schedulers/dateTimestampProvider-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { dateTimestampProvider } from 'rxjs/internal/scheduler/dateTimestampProvider'; diff --git a/packages/rxjs/spec/schedulers/intervalProvider-spec.ts b/packages/rxjs/spec/schedulers/intervalProvider-spec.ts index 55bf3f9690..b39fb2378d 100644 --- a/packages/rxjs/spec/schedulers/intervalProvider-spec.ts +++ b/packages/rxjs/spec/schedulers/intervalProvider-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { intervalProvider } from 'rxjs/internal/scheduler/intervalProvider'; diff --git a/packages/rxjs/spec/schedulers/timeoutProvider-spec.ts b/packages/rxjs/spec/schedulers/timeoutProvider-spec.ts index 829c44f880..3c34983521 100644 --- a/packages/rxjs/spec/schedulers/timeoutProvider-spec.ts +++ b/packages/rxjs/spec/schedulers/timeoutProvider-spec.ts @@ -1,4 +1,3 @@ -/** @prettier */ import { expect } from 'chai'; import { timeoutProvider } from 'rxjs/internal/scheduler/timeoutProvider'; diff --git a/packages/rxjs/spec/support/mocha-browser-runner.html b/packages/rxjs/spec/support/mocha-browser-runner.html index 95ae615165..a76bdca4a9 100644 --- a/packages/rxjs/spec/support/mocha-browser-runner.html +++ b/packages/rxjs/spec/support/mocha-browser-runner.html @@ -1,50 +1,50 @@ - - - + + + -
- - - - - - - - + + + + + + + + runner.on('fail', logFailure); + }; + - \ No newline at end of file + diff --git a/packages/rxjs/spec/support/mocha.sauce.gruntfile.js b/packages/rxjs/spec/support/mocha.sauce.gruntfile.js index 138c88d47f..5629cd0e16 100644 --- a/packages/rxjs/spec/support/mocha.sauce.gruntfile.js +++ b/packages/rxjs/spec/support/mocha.sauce.gruntfile.js @@ -7,19 +7,19 @@ module.exports = function (grunt) { args: ['./mocha.sauce.runner.js'], options: { wait: true, - cwd: './' - } - } + cwd: './', + }, + }, }, connect: { server: { options: { base: '../../', - port: 9876 - } - } - } + port: 9876, + }, + }, + }, }); var parentcwd = process.cwd(); @@ -31,4 +31,4 @@ module.exports = function (grunt) { process.chdir(parentcwd); grunt.registerTask('default', ['connect', 'run:sauce']); -}; \ No newline at end of file +}; diff --git a/packages/rxjs/spec/support/mocha.sauce.runner.js b/packages/rxjs/spec/support/mocha.sauce.runner.js index e17ff9f497..5bf30357be 100644 --- a/packages/rxjs/spec/support/mocha.sauce.runner.js +++ b/packages/rxjs/spec/support/mocha.sauce.runner.js @@ -5,12 +5,12 @@ var customLaunchers = { sl_chrome: { base: 'SauceLabs', browserName: 'chrome', - version: '46' + version: '46', }, sl_chrome_beta: { base: 'SauceLabs', browserName: 'chrome', - version: 'beta' + version: 'beta', }, /* sl_chrome_dev: { @@ -21,7 +21,7 @@ var customLaunchers = { sl_firefox: { base: 'SauceLabs', browserName: 'firefox', - version: '44' + version: '44', }, /*sl_firefox_beta: { base: 'SauceLabs', @@ -37,92 +37,92 @@ var customLaunchers = { base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.9', - version: '7' + version: '7', }, sl_safari8: { base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.10', - version: '8' + version: '8', }, sl_safari9: { base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.11', - version: '9.0' + version: '9.0', }, sl_ios8: { base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.11', - version: '8.4' + version: '8.4', }, sl_ios9: { base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.11', - version: '9.1' + version: '9.1', }, sl_ie9: { base: 'SauceLabs', browserName: 'internet explorer', platform: 'Windows 2008', - version: '9' + version: '9', }, sl_ie10: { base: 'SauceLabs', browserName: 'internet explorer', platform: 'Windows 2012', - version: '10' + version: '10', }, sl_ie11: { base: 'SauceLabs', browserName: 'internet explorer', platform: 'Windows 8.1', - version: '11' + version: '11', }, sl_edge: { base: 'SauceLabs', browserName: 'MicrosoftEdge', platform: 'Windows 10', - version: '14.14393' + version: '14.14393', }, sl_edge_13: { base: 'SauceLabs', browserName: 'MicrosoftEdge', platform: 'Windows 10', - version: '13.10586' + version: '13.10586', }, sl_android_4_1: { base: 'SauceLabs', browserName: 'android', platform: 'Linux', - version: '4.1' + version: '4.1', }, sl_android_4_2: { base: 'SauceLabs', browserName: 'android', platform: 'Linux', - version: '4.2' + version: '4.2', }, sl_android_4_3: { base: 'SauceLabs', browserName: 'android', platform: 'Linux', - version: '4.3' + version: '4.3', }, sl_android_4_4: { base: 'SauceLabs', browserName: 'android', platform: 'Linux', - version: '4.4' + version: '4.4', }, sl_android5: { base: 'SauceLabs', browserName: 'android', platform: 'Linux', - version: '5.1' - } + version: '5.1', + }, }; var sauce = new mochaSauce({ @@ -134,7 +134,7 @@ var sauce = new mochaSauce({ port: 4445, runSauceConnect: true, // run sauceConnect automatically - url: 'http://localhost:9876/spec/support/mocha-browser-runner.html' + url: 'http://localhost:9876/spec/support/mocha-browser-runner.html', }); sauce.record(true, true); @@ -154,4 +154,4 @@ sauce.on('end', function (browser, res) { sauce.start(function (err, res) { console.log('-------------- done --------------'); -}); \ No newline at end of file +}); diff --git a/packages/rxjs/spec/tsconfig.json b/packages/rxjs/spec/tsconfig.json index 316120d15c..4c7a85e49f 100644 --- a/packages/rxjs/spec/tsconfig.json +++ b/packages/rxjs/spec/tsconfig.json @@ -12,4 +12,4 @@ "path": "../src/tsconfig.types.spec.json" } ] -} \ No newline at end of file +} diff --git a/packages/rxjs/spec/tslint.json b/packages/rxjs/spec/tslint.json index 456f551f62..ce9869dcfa 100644 --- a/packages/rxjs/spec/tslint.json +++ b/packages/rxjs/spec/tslint.json @@ -22,4 +22,4 @@ "radix": [false], "triple-equals": [false] } -} \ No newline at end of file +} diff --git a/packages/rxjs/spec/util/UnsubscriptionError-spec.ts b/packages/rxjs/spec/util/UnsubscriptionError-spec.ts index 5d9396a412..adfccf5bb3 100644 --- a/packages/rxjs/spec/util/UnsubscriptionError-spec.ts +++ b/packages/rxjs/spec/util/UnsubscriptionError-spec.ts @@ -6,9 +6,13 @@ describe('UnsubscriptionError', () => { it('should create a message that is a clear indication of its internal errors', () => { const err1 = new Error('Swiss cheese tastes amazing but smells like socks'); const err2 = new Error('User too big to fit in tiny European elevator'); - const source1 = new Observable(() => () => { throw err1; }); + const source1 = new Observable(() => () => { + throw err1; + }); const source2 = timer(1000); - const source3 = new Observable(() => () => { throw err2; }); + const source3 = new Observable(() => () => { + throw err2; + }); const source = merge(source1, source2, source3); const subscription = source.subscribe(); diff --git a/packages/rxjs/spec/util/isObservable-spec.ts b/packages/rxjs/spec/util/isObservable-spec.ts index 24fb6f69dc..eb111dd486 100644 --- a/packages/rxjs/spec/util/isObservable-spec.ts +++ b/packages/rxjs/spec/util/isObservable-spec.ts @@ -9,8 +9,12 @@ describe('isObservable', () => { it('should return true for an observable that comes from another RxJS 5+ library', () => { const o: any = { - lift() { /* noop */ }, - subscribe() { /* noop */ }, + lift() { + /* noop */ + }, + subscribe() { + /* noop */ + }, }; expect(isObservable(o)).to.be.true; @@ -18,7 +22,9 @@ describe('isObservable', () => { it('should NOT return true for any old subscribable', () => { const o: any = { - subscribe() { /* noop */ }, + subscribe() { + /* noop */ + }, }; expect(isObservable(o)).to.be.false; @@ -31,5 +37,4 @@ describe('isObservable', () => { it('should return false for a number', () => { expect(isObservable(1)).to.be.false; }); - }); diff --git a/packages/rxjs/spec/util/isPromise-spec.ts b/packages/rxjs/spec/util/isPromise-spec.ts index 5eca957f81..f2e2d2f445 100644 --- a/packages/rxjs/spec/util/isPromise-spec.ts +++ b/packages/rxjs/spec/util/isPromise-spec.ts @@ -29,5 +29,4 @@ describe('isPromise', () => { it('should return false for a string', () => { expect(isPromise('1')).to.be.false; }); - }); diff --git a/packages/rxjs/spec/util/rx-spec.ts b/packages/rxjs/spec/util/rx-spec.ts index 18374d0139..a94436ee18 100644 --- a/packages/rxjs/spec/util/rx-spec.ts +++ b/packages/rxjs/spec/util/rx-spec.ts @@ -1,36 +1,43 @@ -import { expect } from "chai"; -import { map, Observable, rx } from "rxjs"; +import { expect } from 'chai'; +import { map, Observable, rx } from 'rxjs'; describe('rx', () => { it('should work like pipe, convert the first argument to an observable', () => { const a = [1, 2, 3]; const results: any[] = []; - - rx(a, map(x => x + 1)).subscribe({ - next: value => results.push(value), + + rx( + a, + map((x) => x + 1) + ).subscribe({ + next: (value) => results.push(value), complete: () => { results.push('done'); - } - }) - expect(results).to.deep.equal([2, 3, 4, 'done']) + }, + }); + expect(results).to.deep.equal([2, 3, 4, 'done']); }); it('should simply convert the first argument to an observable if it is the only thing provided', () => { const a = [1, 2, 3]; const results: any[] = []; - + rx(a).subscribe({ - next: value => results.push(value), + next: (value) => results.push(value), complete: () => { results.push('done'); - } - }) - expect(results).to.deep.equal([1, 2, 3, 'done']) + }, + }); + expect(results).to.deep.equal([1, 2, 3, 'done']); }); it('should allow any kind of custom piping', () => { const a = [1, 2, 3]; - const result = rx(a, map(x => x + 1), source => source instanceof Observable) + const result = rx( + a, + map((x) => x + 1), + (source) => source instanceof Observable + ); expect(result).to.be.true; }); });