Skip to content

Commit

Permalink
feat(AlertContainer): allow props to be passed to outer div
Browse files Browse the repository at this point in the history
  • Loading branch information
bfbiggs authored and pauljeter committed Jun 25, 2019
1 parent 9c2657c commit 915a5fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions react/src/lib/AlertContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class AlertContainer extends React.Component {
const {
children,
className,
position
position,
...otherProps
} = this.props;

return (
Expand All @@ -17,7 +18,8 @@ class AlertContainer extends React.Component {
'md-alert__container' +
` md-alert__container--${position}` +
`${(className && ` ${className}`) || ''}`
}
}
{...otherProps}
role='alert'
>
{children}
Expand All @@ -37,7 +39,7 @@ AlertContainer.propTypes = {
children: PropTypes.node,
/** @prop Optional css class string | '' */
className: PropTypes.string,
/** @prop Define alert's position with css class name: 'bottom-right' */
/** @prop Define alert's position with css class name | 'bottom-right' */
position: PropTypes.oneOf(['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'])
};

Expand Down
6 changes: 6 additions & 0 deletions react/src/lib/AlertContainer/tests/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,10 @@ describe('tests for <AlertContainer />', () => {
container.update();
expect(container.find('button').props().id).toEqual('testProp');
});

it('should pass otherProps to container', () => {
const container = shallow(<AlertContainer id='testid'/>);

expect(container.find('#testid').exists()).toEqual(true);
});
});

0 comments on commit 915a5fa

Please sign in to comment.