-
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
feat(mergeScan): Add index to the accumulator function #4458
Conversation
Pull Request Test Coverage Report for Build 8001
💛 - Coveralls |
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.
LGTM, but would you be able to re-write the test to use marble diagram?
@cartant I think the test is fine given it's just asserting the index is being passed to the function. |
@@ -21,6 +21,10 @@ it('should support a currency', () => { | |||
const o = of(1, 2, 3).pipe(mergeScan((acc, value) => of(acc + value), '', 47)); // $ExpectType Observable<string> | |||
}); | |||
|
|||
it('should support an index parameter', () => { | |||
const o = of(1, 2, 3).pipe(mergeScan((acc, value, index) => of(index), 0)); // $ExpectType Observable<number> | |||
}); |
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.
spec/operators/mergeScan-spec.ts
Outdated
return of(x); | ||
}, 0)).subscribe(); | ||
|
||
expect(recorded).to.deep.equal(expected); |
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.
Can you please move expected inside of equal
here? It will make the test moderately more readable, IMO.
705e8cb
to
dfd6213
Compare
Generated by 🚫 dangerJS |
Thank you, @martinsik! |
Description:
This PR adds
index
parameter to the accumulator function used bymergeScan
just like in most other operators.Related issue (if exists):
Closes #4441