Skip to content

[List, Edit, Create, Show] Wrap view components into styles HOC instead of wrapping main components - #3161

Merged
fzaninotto merged 6 commits into
marmelab:masterfrom
cherniavskii:ShowView-styles
Apr 25, 2019
Merged

fzaninotto merged 6 commits into
marmelab:masterfrom
cherniavskii:ShowView-styles

Conversation

@cherniavskii

Copy link
Copy Markdown
Contributor

When using ShowController and ShowView instead of single Show component, Show styles aren't used anymore.
This makes aside component appear under show view (when using Show component, aside is on the right).

Wrapping ShowView with styles HOC resolves the issue. Also, it makes more sense, since styles are related to view component, not Show component, which is simply composition of controller and view.

@fzaninotto

Copy link
Copy Markdown
Member

You're totally right, it makes more sense. Would you mind doing the same for Edit and List, so that all views are consistent?

};

export default withStyles(styles)(Show);
export default Show;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It does not make much sense to have both a named and a default export for the same object. Remove the named export (you will have to change the import in Show.spec.js, too).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure

@cherniavskii

Copy link
Copy Markdown
Contributor Author

Did the same for Edit, Create, and List components.
I have troubles with ListView unit tests though. It uses enzyme shallow rendering, e.g. for checking that Card component is rendered.

@cherniavskii cherniavskii changed the title [Show] Wrap ShowView into styles HOC instead of wrapping Show component [List, Edit, Create, Show] Wrap view components into styles HOC instead of wrapping main components Apr 25, 2019
@cherniavskii

cherniavskii commented Apr 25, 2019 •

Copy link
Copy Markdown
Contributor Author

@fzaninotto I've managed to fix that by using wrapper.dive().

Generally, I'm not a big fan of enzyme unit tests. They are tightly coupled with implementation details, which leads to false positives like this one.

@fzaninotto
fzaninotto merged commit c0fbd06 into marmelab:master Apr 25, 2019
@fzaninotto

Copy link
Copy Markdown
Member

Awesome, thanks!

@fzaninotto fzaninotto added this to the 2.9.0 milestone Apr 25, 2019
@cherniavskii
cherniavskii deleted the ShowView-styles branch April 25, 2019 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants