Skip to content

Commit

Permalink
test: add failing interop subscriber test
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Jun 5, 2020
1 parent ced2fec commit 4439308
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion spec/Subscriber-spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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<void>();
subscriber.add(() => subscriberUnsubscribed = true);

const source = new Observable<void>(() => () => 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;
});
});

0 comments on commit 4439308

Please sign in to comment.