-
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
feat(mergeScan): Add index to the accumulator function #4458
Merged
benlesh
merged 5 commits into
ReactiveX:master
from
martinsik:feat-4441-add-index-to-mergeScan
Jan 30, 2019
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ad6c91a
feat(mergeScan): add index to the accumulator function
martinsik f27b098
test(mergeScan): use marbles instead of "of()"
martinsik dfd6213
test(mergeScan): update spec, remove unnecessary dtest
martinsik 385e04c
Merge branch 'master' into feat-4441-add-index-to-mergeScan
benlesh 16bbed8
readd index lost in merge.
benlesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,4 +419,17 @@ describe('mergeScan', () => { | |
expectSubscriptions(inner[1].subscriptions).toBe(ysubs); | ||
expectSubscriptions(inner[2].subscriptions).toBe(zsubs); | ||
}); | ||
|
||
it('should pass current index to accumulator', () => { | ||
const recorded: number[] = []; | ||
const expected = [0, 1, 2, 3]; | ||
const e1 = of('a', 'b', 'c', 'd'); | ||
|
||
e1.pipe(mergeScan((acc, x, index) => { | ||
recorded.push(index); | ||
return of(x); | ||
}, 0)).subscribe(); | ||
|
||
expect(recorded).to.deep.equal(expected); | ||
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 you please move expected inside of |
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this new test is unnecessary. :)
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.
I'm pretty sure this test will fail if the index is removed from the signature, so it guards against a regression, IMO.Nah. You're right. The spec will fail first. Duh.
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.
I removed this test. I was looking at how is this thing tested elsewhere and it seemed to be the same usecase as here https://github.com/ReactiveX/rxjs/blob/master/spec-dtslint/operators/map-spec.ts#L12-L14 or here https://github.com/ReactiveX/rxjs/blob/master/spec-dtslint/operators/findIndex-spec.ts#L8-L10
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.
Personally, I'd favour the dtslint typing tests being written without regard to what's tested in the specs - even if that means there are some redundant tests.