diff --git a/app/Resources/client/src/components/Button/Button.js b/app/Resources/client/src/components/Button/Button.js
index 49e49068..96cbaf5e 100644
--- a/app/Resources/client/src/components/Button/Button.js
+++ b/app/Resources/client/src/components/Button/Button.js
@@ -36,7 +36,7 @@ class Button extends React.Component {
if (event) {
event.preventDefault()
}
- if (!this.isDisabled()) {
+ if (!this.isDisabled() && this.props.callback) {
this.setState({
disabled : true,
loading : true
@@ -64,15 +64,17 @@ class Button extends React.Component {
}
Button.propTypes = {
- text : PropTypes.string.isRequired,
+ text : PropTypes.string,
className : PropTypes.string,
disabled : PropTypes.bool,
- callback : PropTypes.func.isRequired,
+ callback : PropTypes.func,
submitEvent : PropTypes.string
}
Button.defaultProps = {
- disabled : false,
+ text : '',
+ className : '',
+ disabled : false,
}
export default Button
diff --git a/app/Resources/client/tests/components/Button.spec.js b/app/Resources/client/tests/components/Button.spec.js
new file mode 100644
index 00000000..e6ab8942
--- /dev/null
+++ b/app/Resources/client/tests/components/Button.spec.js
@@ -0,0 +1,124 @@
+import React from 'react'
+import Button from 'components/Button/Button'
+import { shallow, mount } from 'enzyme'
+import EventBus from 'components/EventBus'
+
+describe('(Component) Button', () => {
+ it('renders as a button', () => {
+ const wrapper = shallow()
+ const inst = wrapper.instance()
+ expect(inst).to.be.instanceOf(Button)
+ expect(wrapper.name()).to.equal('button')
+ })
+
+ describe('(State)', () => {
+ it('Should have initial state', () => {
+ const wrapper = mount()
+ expect(wrapper.state()).to.deep.equal({ disabled : false, loading : false })
+ })
+ })
+
+ describe('(Props)', () => {
+ it('Should have default props', () => {
+ const wrapper = mount()
+ expect(wrapper.props().text).to.equal('')
+ expect(wrapper.props().className).to.equal('')
+ expect(wrapper.props().disabled).to.equal(false)
+ })
+
+ it('Should have props', () => {
+ const wrapper = mount(
+