-
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
fix(takeLast): fix takeLast behavior to emit correct order #1412
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,40 @@ describe('Observable.prototype.takeLast()', () => { | |
expectSubscriptions(e1.subscriptions).toBe(e1subs); | ||
}); | ||
|
||
it('should take last three values', () => { | ||
const e1 = cold('--a-----b----c---d--| '); | ||
const e1subs = '^ ! '; | ||
const expected = '--------------------(bcd|)'; | ||
|
||
expectObservable(e1.takeLast(3)).toBe(expected); | ||
expectSubscriptions(e1.subscriptions).toBe(e1subs); | ||
}); | ||
|
||
it('should take all element when try to take larger then source', () => { | ||
const e1 = cold('--a-----b----c---d--| '); | ||
const e1subs = '^ ! '; | ||
const expected = '--------------------(abcd|)'; | ||
|
||
expectObservable(e1.takeLast(5)).toBe(expected); | ||
expectSubscriptions(e1.subscriptions).toBe(e1subs); | ||
}); | ||
|
||
it('should take all element when try to take exact', () => { | ||
const e1 = cold('--a-----b----c---d--| '); | ||
const e1subs = '^ ! '; | ||
const expected = '--------------------(abcd|)'; | ||
|
||
expectObservable(e1.takeLast(4)).toBe(expected); | ||
expectSubscriptions(e1.subscriptions).toBe(e1subs); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the above tests to use marble diagrams and virtual scheduling? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so, let me do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind keeping one synchronous test, of course, but the marble tests are more analogous to the issue that was reported (which was using an interval). |
||
|
||
it('should not take any values', () => { | ||
const e1 = cold('--a-----b----c---d--|'); | ||
const expected = '|'; | ||
|
||
expectObservable(e1.takeLast(0)).toBe(expected); | ||
}); | ||
|
||
it('should work with empty', () => { | ||
const e1 = cold('|'); | ||
const e1subs = '(^!)'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer