Skip to content

Commit

Permalink
fix: Prop spreading for SideNavigation (#248)
Browse files Browse the repository at this point in the history
* Add prop spreading

* Add spread
  • Loading branch information
cjskillingstad committed Jan 17, 2019
1 parent e1f58a4 commit 02e1d70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/SideNavigation/SideNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { BrowserRouter, Link } from 'react-router-dom';
import React, { Component } from 'react';

export const SideNav = props => {
const { icons, children } = props;
const { icons, children, ...rest } = props;
return (
<nav className={`fd-side-nav${icons ? ' fd-side-nav--icons' : ''}`}>
<nav {...rest} className={`fd-side-nav${icons ? ' fd-side-nav--icons' : ''}`}>
{children}
</nav>
);
Expand Down Expand Up @@ -159,18 +159,19 @@ SideNavList.propTypes = {
};

export const SideNavGroup = props => {
const { title, children, className, ...rest } = props;
const { title, children, className, titleProps, ...rest } = props;
return (
<div
className={`fd-side-nav__group${className ? ' ' + className : ''}`}
{...rest}>
<h1 className='fd-side-nav__title'>{title}</h1>
<h1 {...titleProps} className='fd-side-nav__title'>{title}</h1>
{children}
</div>
);
};

SideNavGroup.propTypes = {
className: PropTypes.string,
title: PropTypes.string
title: PropTypes.string,
titleProps: PropTypes.object
};
11 changes: 7 additions & 4 deletions src/SideNavigation/SideNavigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ describe('<SideNavigation />', () => {
});

describe('Prop spreading', () => {
xtest('should allow props to be spread to the SideNav component', () => {
// TODO: placeholder for this test description once that functionality is built
test('should allow props to be spread to the SideNav component', () => {
const element = mount(<SideNav data-sample='Sample' />);

expect(
Expand Down Expand Up @@ -226,8 +225,12 @@ describe('<SideNavigation />', () => {
).toBe('Sample');
});

xtest('should allow props to be spread to the SideNavGroup component\'s h1 element', () => {
// TODO: placeholder for this test description once that functionality is built
test('should allow props to be spread to the SideNavGroup component\'s h1 element', () => {
const element = mount(<SideNavGroup titleProps={{'data-sample': 'Sample'}} />);

expect(
element.find('h1').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
});
});

0 comments on commit 02e1d70

Please sign in to comment.