Skip to content

test(scan-spec): Change use of .reduce to .scan in scan-spec.ts#2902

Merged
benlesh merged 1 commit intoReactiveX:masterfrom
hsubra89:fix-scan-tests
Oct 5, 2017
Merged

test(scan-spec): Change use of .reduce to .scan in scan-spec.ts#2902
benlesh merged 1 commit intoReactiveX:masterfrom
hsubra89:fix-scan-tests

Conversation

@hsubra89
Copy link
Contributor

@hsubra89 hsubra89 commented Oct 4, 2017

Test the .scan operator from scan-spec.ts instead of .reduce

@@ -231,14 +231,14 @@ describe('Observable.prototype.scan', () => {
it('should accept array typed reducers', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even test name seems we just copied test but haven't updated? 😱

Copy link
Contributor Author

@hsubra89 hsubra89 Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name still seemed to make sense to me. I'm not entirely certain the tests are actually fully correct. I'll leave references in the actual code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I just remove the word reducers from the test name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah what I'm saying is these test seems like just copied from reduce and we haven't updated at all. Not saying test case name should be updated as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah k. :D

@rxjs-bot
Copy link

rxjs-bot commented Oct 4, 2017

Messages
📖

CJS: 1347.9KB, global: 747.2KB (gzipped: 140.5KB), min: 145.3KB (gzipped: 30.9KB)

Generated by 🚫 dangerJS

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.465% when pulling 16a874d on hsubra89:fix-scan-tests into 5dbad94 on ReactiveX:master.

@@ -249,7 +249,7 @@ describe('Observable.prototype.scan', () => {
it('should accept R typed reducers', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test dosen't seem right. Shouldn't the actual call to .scan be something like this?

a.scan<{ a: number, b: string }, { a?: number; b?: string }>((acc, value) => { ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it for T only overload testing?

scan<T>(this: Observable<T>, accumulator: (acc: T, value: T, index: number) => T, seed?: T)

Copy link
Contributor Author

@hsubra89 hsubra89 Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwonoj Well, the test is called should accept R typed reducers. I'm assumed that meant we're explicitly testing the case where we have two different types for acc and the source. I'm guessing that based on the other tests in the file, i.e, there's another one for T typed reducers and `Array typed reducers'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can't just trust test name and test cases here at all, since from first it was testing reduce anyway 😅 I was just guessing by usage of code here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the way the overloads and the tests are set-up, in the actual test, both acc and value are T. Which means acc isn't really inheriting what R is supposed to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should leave this as-is for now, and i'll propose some changes to these tests in #2897 after we get this in ?

@@ -231,14 +231,14 @@ describe('Observable.prototype.scan', () => {
it('should accept array typed reducers', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I just remove the word reducers from the test name?

@@ -231,14 +231,14 @@ describe('Observable.prototype.scan', () => {
it('should accept array typed reducers', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah k. :D

let a: Rx.Observable<{ a: number; b: string }>;
a.reduce<{ a?: number; b?: string }>((acc, value) => {
a.scan<{ a?: number; b?: string }>((acc, value) => {
value.a = acc.a;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, isn't this supposed to be acc.a = value.a? I'll fix this now.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.465% when pulling c86264c on hsubra89:fix-scan-tests into 5dbad94 on ReactiveX:master.

Change the use of `.reduce` from scan-spec to correctly use `.scan` instead.

None
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.465% when pulling 923195f on hsubra89:fix-scan-tests into 5dbad94 on ReactiveX:master.

1 similar comment
@coveralls
Copy link

coveralls commented Oct 5, 2017

Coverage Status

Coverage remained the same at 97.465% when pulling 923195f on hsubra89:fix-scan-tests into 5dbad94 on ReactiveX:master.

@benlesh benlesh merged commit 5c6b794 into ReactiveX:master Oct 5, 2017
@hsubra89 hsubra89 deleted the fix-scan-tests branch October 5, 2017 20:41
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants