-
Notifications
You must be signed in to change notification settings - Fork 400
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
ShowMoreCard should expand if updated content changes #3057
Merged
Merged
Changes from all commits
Commits
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
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 will work in production but I don't think it will work for our test suite. The problem is that React does not guarantee that the callback to
setState()
will be invoked immediately. Thus, the test you wrote will probably pass most of the time but not all of the time. If thesetState()
callback is delayed then your test will fail.There are a few ways to solve this. We could try to wedge promises in here so that the test can use a promise chain. I don't see an easy way to do that.
Alternatively, we could keep the process synchronous which would make the test you already wrote pass 100% of the time. I think restoring
componentWillReceiveProps()
to how it was and adding thiselse
block would accomplish that: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.
Well, it's possible that Enzyme has some trickery to ensure all batched state changes are applied but they don't document this. I'm skeptical since this kind of state change is triggered from within the component (not from an Enzyme method).
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.
What we could do (maybe) is reusing the
callback
from EnzymesetState()
(see: enzymejs/enzyme#617) and ensure the test case asserts things once thesetState()
has been triggered (and usedone()
to ensure the test does not silently fail). WDYT?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.
Ugh, yeah, we really can't rely on
setState()
being synchronous anywhere. enzymejs/enzyme#509 (comment)It would be nice to use promises instead of
done()
but your approach will work. Creating a promise wrapper for everywhere we rely onwrapper.setState()
in the tests is probably a better long term solution.