Skip to content
Snippets Groups Projects
Commit 8a0756db authored by Jessie Keck's avatar Jessie Keck Committed by Chris Beer
Browse files

Make icons optional for NestedMenus

parent 8427e599
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,12 @@ describe('NestedMenu', () => {
expect(wrapper.find('WithStyles(ListItemIcon)').children().text()).toEqual('GivenIcon');
});
it('does not render a ListItemIcon if no icon prop is passed', () => {
wrapper = createWrapper({ icon: null });
expect(wrapper.find('WithStyles(ListItemIcon)').length).toBe(0);
});
it('renders the given label wrapped in a MUI Typography', () => {
wrapper = createWrapper();
......
......@@ -46,7 +46,9 @@ export class NestedMenu extends Component {
return (
<>
<MenuItem onClick={this.handleMenuClick}>
<ListItemIcon>{icon}</ListItemIcon>
{icon
&& (<ListItemIcon>{icon}</ListItemIcon>)
}
{/* ListItemText adds left padding and we want this to line-up with menu items */}
<ListItemText style={{ paddingLeft: 0 }}>
<Typography varient="inherit">{label}</Typography>
......@@ -67,6 +69,10 @@ export class NestedMenu extends Component {
NestedMenu.propTypes = {
children: PropTypes.element.isRequired,
icon: PropTypes.element.isRequired,
icon: PropTypes.element,
label: PropTypes.string.isRequired,
};
NestedMenu.defaultProps = {
icon: null,
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment