From 4439308100da474aeaa5fc05dd2cbdea9780c677 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Fri, 5 Jun 2020 22:12:40 +1000 Subject: [PATCH] test: add failing interop subscriber test --- spec/Subscriber-spec.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/Subscriber-spec.ts b/spec/Subscriber-spec.ts index 5a61e04398..ab5efae64d 100644 --- a/spec/Subscriber-spec.ts +++ b/spec/Subscriber-spec.ts @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { SafeSubscriber } from 'rxjs/internal/Subscriber'; -import { Subscriber } from 'rxjs'; +import { Subscriber, Observable } from 'rxjs'; +import { asInteropSubscriber } from './helpers/interop-helper'; /** @test {Subscriber} */ describe('Subscriber', () => { @@ -97,4 +98,22 @@ describe('Subscriber', () => { expect(argument).to.have.lengthOf(0); }); + + it('should chain interop unsubscriptions', () => { + let observableUnsubscribed = false; + let subscriberUnsubscribed = false; + let subscriptionUnsubscribed = false; + + const subscriber = new Subscriber(); + subscriber.add(() => subscriberUnsubscribed = true); + + const source = new Observable(() => () => observableUnsubscribed = true); + const subscription = source.subscribe(asInteropSubscriber(subscriber)); + subscription.add(() => subscriptionUnsubscribed = true); + subscriber.unsubscribe(); + + expect(observableUnsubscribed).to.be.true; + expect(subscriberUnsubscribed).to.be.true; + expect(subscriptionUnsubscribed).to.be.true; + }); });