diff --git a/src/components/modal/base/modal.jsx b/src/components/modal/base/modal.jsx index 7353b9080..0203a0f41 100644 --- a/src/components/modal/base/modal.jsx +++ b/src/components/modal/base/modal.jsx @@ -49,17 +49,20 @@ class Modal extends React.Component { }} {...omit(this.props, ['className', 'overlayClassName'])} > -
- close-icon -
+ + {this.props.showCloseButton && ( +
+ close-icon +
+ )} {this.props.children} ); @@ -70,7 +73,11 @@ Modal.propTypes = { children: PropTypes.node, className: PropTypes.string, overlayClassName: PropTypes.string, + showCloseButton: PropTypes.bool, useStandardSizes: PropTypes.bool }; +Modal.defaultProps = { + showCloseButton: true +}; module.exports = Modal; diff --git a/src/components/modal/join/modal.jsx b/src/components/modal/join/modal.jsx index 287e6b31e..bd17ac6ab 100644 --- a/src/components/modal/join/modal.jsx +++ b/src/components/modal/join/modal.jsx @@ -12,6 +12,7 @@ const JoinModal = ({ }) => ( ( ); diff --git a/test/unit/components/modal.test.jsx b/test/unit/components/modal.test.jsx new file mode 100644 index 000000000..6c427dc2f --- /dev/null +++ b/test/unit/components/modal.test.jsx @@ -0,0 +1,34 @@ +const React = require('react'); +const {shallowWithIntl} = require('../../helpers/intl-helpers.jsx'); +const Modal = require('../../../src/components/modal/base/modal.jsx'); + +describe('Modal', () => { + test('Close button not shown when showCloseButton false', () => { + const showClose = true; + const component = shallowWithIntl( + + ); + expect(component.find('div.modal-content-close').exists()).toBe(true); + expect(component.find('img.modal-content-close-img').exists()).toBe(true); + }); + test('Close button shown by default', () => { + const component = shallowWithIntl( + + ); + expect(component.find('div.modal-content-close').exists()).toBe(true); + expect(component.find('img.modal-content-close-img').exists()).toBe(true); + }); + + test('Close button shown when showCloseButton true', () => { + const showClose = false; + const component = shallowWithIntl( + + ); + expect(component.find('div.modal-content-close').exists()).toBe(false); + expect(component.find('img.modal-content-close-img').exists()).toBe(false); + }); +});