From 915a5fa87a7077188a314935da5bd7f5a46b42d8 Mon Sep 17 00:00:00 2001 From: Ben Biggs Date: Mon, 24 Jun 2019 11:54:35 -0500 Subject: [PATCH] feat(AlertContainer): allow props to be passed to outer div --- react/src/lib/AlertContainer/index.js | 8 +++++--- react/src/lib/AlertContainer/tests/index.spec.js | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/react/src/lib/AlertContainer/index.js b/react/src/lib/AlertContainer/index.js index 03689a160d..d47ac57cff 100644 --- a/react/src/lib/AlertContainer/index.js +++ b/react/src/lib/AlertContainer/index.js @@ -8,7 +8,8 @@ class AlertContainer extends React.Component { const { children, className, - position + position, + ...otherProps } = this.props; return ( @@ -17,7 +18,8 @@ class AlertContainer extends React.Component { 'md-alert__container' + ` md-alert__container--${position}` + `${(className && ` ${className}`) || ''}` - } + } + {...otherProps} role='alert' > {children} @@ -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']) }; diff --git a/react/src/lib/AlertContainer/tests/index.spec.js b/react/src/lib/AlertContainer/tests/index.spec.js index 6644a4d12f..a4bf27567b 100644 --- a/react/src/lib/AlertContainer/tests/index.spec.js +++ b/react/src/lib/AlertContainer/tests/index.spec.js @@ -135,4 +135,10 @@ describe('tests for ', () => { container.update(); expect(container.find('button').props().id).toEqual('testProp'); }); + + it('should pass otherProps to container', () => { + const container = shallow(); + + expect(container.find('#testid').exists()).toEqual(true); + }); });