Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestScheduler: Should support *lack* of subscriptions in expectSubscriptions` #5499

Closed
benlesh opened this issue Jun 15, 2020 · 2 comments
Closed
Labels
feature PRs and issues for features help wanted Issues we wouldn't mind assistance with.

Comments

@benlesh
Copy link
Member

benlesh commented Jun 15, 2020

Currently, there is no way to properly test a lack of subscription, AFAICT. (Maybe I'm wrong? haha)

So let's say I want to test something like this:

testScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
  const source = cold('  ---a---b---c---d---|');
  const expected = '     --------------------';
  const subscriptions = '--------------------';
  const result = source.pipe(subscribeOn(testScheduler, Infinity));
  expectObservable(result).toBe(expected);
  expectSubscriptions(source.subscriptions).toBe(subscriptions);
});

Ran into this while trying to test a bug in subscribeOn.

@cartant
Copy link
Collaborator

cartant commented Jun 15, 2020

Can you pass an empty array?

expectSubscriptions(source.subscriptions).toBe([]);

@benlesh
Copy link
Member Author

benlesh commented Jun 16, 2020

@cartant ... yes, that's a valid workaround. I think this issue is confusing enough that we should make sure that .toBe(' ') and .toBe('-------') work the same way as .toBe([]).

Further, it's plausible that people will have tests that expect subscriptions like ['^---!', '----', '---^--!'] or the like. I think what we need to do is just take the { subscribed: null, unsubscribed: null } (or whatever that outputs), and filter them out of the resulting arrays. Then everything should "just work" as expected.

@benlesh benlesh added feature PRs and issues for features help wanted Issues we wouldn't mind assistance with. labels Jun 16, 2020
cartant added a commit to cartant/rxjs that referenced this issue Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs and issues for features help wanted Issues we wouldn't mind assistance with.
Projects
None yet
Development

No branches or pull requests

2 participants