Skip to content

Commit

Permalink
fix(ModalHeader): add closeBtnProps
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Biggs authored and pauljeter committed May 17, 2019
1 parent 6352676 commit ceacf56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions react/src/lib/ModalHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ModalHeader extends React.PureComponent {
const {
children,
className,
closeBtnProps,
headerLabel,
message,
showCloseButton,
Expand Down Expand Up @@ -39,6 +40,7 @@ class ModalHeader extends React.PureComponent {
<CloseIcon
className='md-modal__close'
onClick={handleClose}
{...closeBtnProps}
/>
}
</div>
Expand All @@ -51,6 +53,8 @@ ModalHeader.propTypes = {
children: PropTypes.node,
/** @prop Optional CSS class names | '' */
className: PropTypes.string,
/** @prop Props to be passed to close button | null */
closeBtnProps: PropTypes.object,
/** @prop ModalHeader label text | '' */
headerLabel: PropTypes.string,
/** @prop Modal message | '' */
Expand All @@ -62,6 +66,7 @@ ModalHeader.propTypes = {
ModalHeader.defaultProps = {
children: null,
className: '',
closeBtnProps: null,
headerLabel: '',
message: '',
showCloseButton: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <ModalHeader
className=""
closeBtnProps={null}
headerLabel=""
id="test"
message=""
Expand Down
6 changes: 6 additions & 0 deletions react/src/lib/ModalHeader/tests/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ describe('tests for <ModalHeader />', () => {
expect(container.find('.md-modal__close').length).toEqual(1);
});

it('should apply closeBtnProps', () => {
const container = shallow(<ModalHeader closeBtnProps={{ className: 'test'}}/>);

expect(container.find('.test').length).toEqual(1);
});

it('should display not display closable button', () => {
const container = shallow(<ModalHeader showCloseButton={false} />);

Expand Down

0 comments on commit ceacf56

Please sign in to comment.