Skip to content
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

Improve error boundaries tests #7569

Merged
merged 1 commit into from
Aug 31, 2016

Conversation

millermedeiros
Copy link
Contributor

this is kinda of a follow up to #7558 where @spicyj said:

Can you make a custom componentDidMount instead of mocking putListener? This current test won't verify that the queue is reset if we were to refactor the events system and how putListener works. Also, no need for the parens within render.
#7558 (comment)

the new tests makes sure the methods are executed in the proper order and don't rely on EventPluginHub anymore - the 'does not register event handlers for unmounted children' test still uses EventPluginHub since it looks like it makes sense to leave that check there...

also removed some parentheses and wrapped some lines.

container.innerHTML = ReactDOMServer.renderToString(<Boundary />);
expect(container.firstChild.innerHTML).toBe('Happy Birthday!');
expect(EventPluginHub.putListener).not.toBeCalled();
// note: renderToString does not call componentDidMount
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure why this even uses renderToString. Mind changing it to use ReactDOM.render so that we test the queueing behavior better? (See, I didn't even notice that the old test was testing the wrong thing but now that componentDidMount is completely absent here it's much more obvious. Thanks.)

Copy link
Contributor

@aweary aweary Aug 27, 2016

Choose a reason for hiding this comment

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

Should we have tests for both renderToString and ReactDOM.render? The title of this test block should be changed too if we're not testing SSR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In most cases it's fine to just test client rendering since the server codepath is mostly a subset of the client one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, updated the test to use ReactDOM.render instead. FYI, original test was introduced by #6694

Copy link
Collaborator

Choose a reason for hiding this comment

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

rawr. okay.

@sophiebits
Copy link
Collaborator

lgtm otherwise, thanks!

@ghost ghost added the CLA Signed label Aug 27, 2016
@millermedeiros
Copy link
Contributor Author

this should be good to go, updated all the test to use ReactDOM.render instead of renderToString

@sophiebits
Copy link
Collaborator

Thanks!

@ghost ghost added the CLA Signed label Aug 31, 2016
@millermedeiros millermedeiros deleted the boundarytest branch August 31, 2016 05:35
@zpao zpao modified the milestones: 15.3.2, 15-next Sep 8, 2016
zpao pushed a commit that referenced this pull request Sep 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants