diff --git a/src/components/contact/ContactForm.test.js b/src/components/contact/ContactForm.test.js index 9178e58..9b45cf9 100644 --- a/src/components/contact/ContactForm.test.js +++ b/src/components/contact/ContactForm.test.js @@ -167,6 +167,7 @@ describe('ContactForm', () => { it('should call send with required data', () => { feedback.send.returns(Promise.resolve()); + component.onSubmit(); expect(feedback.send, 'to have a call satisfying', [ diff --git a/src/components/ui/form/Input.js b/src/components/ui/form/Input.js index 59ce3de..ff807da 100644 --- a/src/components/ui/form/Input.js +++ b/src/components/ui/form/Input.js @@ -11,7 +11,7 @@ import { SKIN_DARK, COLOR_GREEN } from 'components/ui'; import styles from './form.scss'; import FormInputComponent from './FormInputComponent'; -let copiedStateTimeout: ?TimeoutID; +let copiedStateTimeout: TimeoutID; export default class Input extends FormInputComponent<{ skin: Skin, @@ -108,7 +108,7 @@ export default class Input extends FormInputComponent<{ } getValue() { - return this.el || this.el.value; + return this.el && this.el.value; } focus() { @@ -121,6 +121,10 @@ export default class Input extends FormInputComponent<{ } onCopy = async () => { + if (!this.getValue()) { + return; + } + try { clearTimeout(copiedStateTimeout); await copy(this.getValue()); diff --git a/src/components/ui/form/Input.test.js b/src/components/ui/form/Input.test.js new file mode 100644 index 0000000..0a8f6b1 --- /dev/null +++ b/src/components/ui/form/Input.test.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import expect from 'unexpected'; +import { IntlProvider } from 'react-intl'; + +import Input from './Input'; + +describe('Input', () => { + it('should return input value', () => { + let component; + const wrapper = mount( + + {component = el;}}/> + + ); + + expect(wrapper.find('input[name="test"]').node.value, 'to equal', 'foo'); + expect(component.getValue(), 'to equal', 'foo'); + }); +});