-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Unsubscribe from marble tests #402
Comments
While making tests for mergeMap I think I figured one potential way of making this happen. The subscription is done in this.schedule(() => {
observable.subscribe((value) => {
actual.push({ frame: this.frame, notification: Notification.createNext(value) });
}, (err) => {
actual.push({ frame: this.frame, notification: Notification.createError(err) });
}, () => {
actual.push({ frame: this.frame, notification: Notification.createComplete() });
});
}, 0); We need to keep that subscription inside expect(observable: Observable<any>, unsubscriptionMarbles?: string) So you can optionally provide a marble diagram for the unsubscription moment. And then use it like this: var e1 = hot('--a-^---b--c----d-------e--f--g--|');
var expected = '-----b--c----d---';
var unsub = '----------------------|';
expectObservable(e1.delay(20), unsub).toBe(expected); Notice the second parameter given to What do you think? Does this solve also tricky use cases we had for switch/switchMap? I would know how to implement that above. |
That's not bad. But wouldn't the unsub marbles be: var e1 = hot('--a-^---b--c----d-------e--f--g--|');
var expected = '-----b--c----d---';
var unsub = '----------------------|';
expectObservable(e1.delay(20), unsub).toBe(expected); So that the |
Correct, was my mistake. |
@staltz, I like it, but I think the character should be different than |
Ok, let's do exclamation then. Another character I considered was underscore, because it would look a bit like the opposite of var e1 = hot('--a-^---b--c----d-------e--f--g--|');
var expected = '-----b--c----d---';
var unsub = '----------------------_';
expectObservable(e1.delay(20), unsub).toBe(expected); But I'm fine with exclamation: var e1 = hot('--a-^---b--c----d-------e--f--g--|');
var expected = '-----b--c----d---';
var unsub = '----------------------!';
expectObservable(e1.delay(20), unsub).toBe(expected); |
Addresses issue ReactiveX#402
This issue can be closed since it's fully implemented. |
Can't do tests with the marble tests to show if someone wants to unsubscribe at some point: explicit disposable vs. completion. Need some way to tell the test scheduler to unsubscribe from the test observable at a particular frame.
The text was updated successfully, but these errors were encountered: