From 17dc704a5eac6dd7a57ba1128a331ea3dd9f05c0 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Wed, 19 May 2021 19:07:01 +1000 Subject: [PATCH] test: change descriptions and add comments --- spec/operators/publish-spec.ts | 5 ++++- spec/operators/publishBehavior-spec.ts | 5 ++++- spec/operators/publishLast-spec.ts | 5 ++++- spec/operators/publishReplay-spec.ts | 5 ++++- spec/operators/share-spec.ts | 5 ++++- spec/operators/shareReplay-spec.ts | 5 ++++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/spec/operators/publish-spec.ts b/spec/operators/publish-spec.ts index b405cb34ac..9cbf0a18ea 100644 --- a/spec/operators/publish-spec.ts +++ b/spec/operators/publish-spec.ts @@ -338,7 +338,7 @@ describe('publish operator', () => { done(); }); - it('should subscribe to its own source when using a shared pipeline', () => { + it('should be referentially-transparent', () => { const source1 = cold('-1-2-3-4-5-|'); const source1Subs = '^ !'; const expected1 = '-1-2-3-4-5-|'; @@ -346,10 +346,13 @@ describe('publish operator', () => { const source2Subs = '^ !'; const expected2 = '-6-7-8-9-0-|'; + // Calls to the _operator_ must be referentially-transparent. const sharedPipeLine = pipe( publish() ); + // The non-referentially-transparent publishing occurs within the _operator function_ + // returned by the _operator_ and that happens when the complete pipeline is composed. const published1 = source1.pipe(sharedPipeLine) as ConnectableObservable; const published2 = source2.pipe(sharedPipeLine) as ConnectableObservable; diff --git a/spec/operators/publishBehavior-spec.ts b/spec/operators/publishBehavior-spec.ts index 398337af4e..33cc9583ce 100644 --- a/spec/operators/publishBehavior-spec.ts +++ b/spec/operators/publishBehavior-spec.ts @@ -345,7 +345,7 @@ describe('publishBehavior operator', () => { done(); }); - it('should subscribe to its own source when using a shared pipeline', () => { + it('should be referentially-transparent', () => { const source1 = cold('-1-2-3-4-5-|'); const source1Subs = '^ !'; const expected1 = 'x1-2-3-4-5-|'; @@ -353,10 +353,13 @@ describe('publishBehavior operator', () => { const source2Subs = '^ !'; const expected2 = 'x6-7-8-9-0-|'; + // Calls to the _operator_ must be referentially-transparent. const sharedPipeLine = pipe( publishBehavior('x') ); + // The non-referentially-transparent publishing occurs within the _operator function_ + // returned by the _operator_ and that happens when the complete pipeline is composed. const published1 = source1.pipe(sharedPipeLine) as ConnectableObservable; const published2 = source2.pipe(sharedPipeLine) as ConnectableObservable; diff --git a/spec/operators/publishLast-spec.ts b/spec/operators/publishLast-spec.ts index 03db9dd3de..48031fdfbe 100644 --- a/spec/operators/publishLast-spec.ts +++ b/spec/operators/publishLast-spec.ts @@ -262,7 +262,7 @@ describe('publishLast operator', () => { done(); }); - it('should subscribe to its own source when using a shared pipeline', () => { + it('should be referentially-transparent', () => { const source1 = cold('-1-2-3-4-5-|'); const source1Subs = '^ !'; const expected1 = '-----------(5|)'; @@ -270,10 +270,13 @@ describe('publishLast operator', () => { const source2Subs = '^ !'; const expected2 = '-----------(0|)'; + // Calls to the _operator_ must be referentially-transparent. const sharedPipeLine = pipe( publishLast() ); + // The non-referentially-transparent publishing occurs within the _operator function_ + // returned by the _operator_ and that happens when the complete pipeline is composed. const published1 = source1.pipe(sharedPipeLine) as ConnectableObservable; const published2 = source2.pipe(sharedPipeLine) as ConnectableObservable; diff --git a/spec/operators/publishReplay-spec.ts b/spec/operators/publishReplay-spec.ts index 594110e55d..d3c978ac7c 100644 --- a/spec/operators/publishReplay-spec.ts +++ b/spec/operators/publishReplay-spec.ts @@ -488,7 +488,7 @@ describe('publishReplay operator', () => { expectSubscriptions(source.subscriptions).toBe(sourceSubs); }); - it('should subscribe to its own source when using a shared pipeline', () => { + it('should be referentially-transparent', () => { const source1 = cold('-1-2-3-4-5-|'); const source1Subs = '^ !'; const expected1 = '-1-2-3-4-5-|'; @@ -496,10 +496,13 @@ describe('publishReplay operator', () => { const source2Subs = '^ !'; const expected2 = '-6-7-8-9-0-|'; + // Calls to the _operator_ must be referentially-transparent. const sharedPipeLine = pipe( publishReplay(1) ); + // The non-referentially-transparent publishing occurs within the _operator function_ + // returned by the _operator_ and that happens when the complete pipeline is composed. const published1 = source1.pipe(sharedPipeLine) as ConnectableObservable; const published2 = source2.pipe(sharedPipeLine) as ConnectableObservable; diff --git a/spec/operators/share-spec.ts b/spec/operators/share-spec.ts index 73cab855fb..9b0560d3b9 100644 --- a/spec/operators/share-spec.ts +++ b/spec/operators/share-spec.ts @@ -620,7 +620,7 @@ describe('share', () => { }); }); - it('should subscribe to its own source when using a shared pipeline', () => { + it('should be referentially-transparent', () => { rxTest.run(({ cold, expectObservable, expectSubscriptions }) => { const source1 = cold('-1-2-3-4-5-|'); const source1Subs = ' ^----------!'; @@ -629,8 +629,11 @@ describe('share', () => { const source2Subs = ' ^----------!'; const expected2 = ' -6-7-8-9-0-|'; + // Calls to the _operator_ must be referentially-transparent. const sharedPipeLine = pipe(share({ resetOnRefCountZero })); + // The non-referentially-transparent sharing occurs within the _operator function_ + // returned by the _operator_ and that happens when the complete pipeline is composed. const shared1 = source1.pipe(sharedPipeLine); const shared2 = source2.pipe(sharedPipeLine); diff --git a/spec/operators/shareReplay-spec.ts b/spec/operators/shareReplay-spec.ts index ebd10fa09d..904c6a0876 100644 --- a/spec/operators/shareReplay-spec.ts +++ b/spec/operators/shareReplay-spec.ts @@ -388,7 +388,7 @@ describe('shareReplay', () => { console.warn(`No support for FinalizationRegistry in Node ${process.version}`); } - it('should subscribe to its own source when using a shared pipeline', () => { + it('should be referentially-transparent', () => { testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => { const source1 = cold('-1-2-3-4-5-|'); const source1Subs = ' ^----------!'; @@ -397,8 +397,11 @@ describe('shareReplay', () => { const source2Subs = ' ^----------!'; const expected2 = ' -6-7-8-9-0-|'; + // Calls to the _operator_ must be referentially-transparent. const sharedPipeLine = pipe(shareReplay({ refCount: false })); + // The non-referentially-transparent sharing occurs within the _operator function_ + // returned by the _operator_ and that happens when the complete pipeline is composed. const shared1 = source1.pipe(sharedPipeLine); const shared2 = source2.pipe(sharedPipeLine);