#22: fix tests

This commit is contained in:
SleepWalker 2018-05-05 10:05:57 +03:00
parent 6f650ba0c5
commit e66840a391
3 changed files with 27 additions and 2 deletions

View File

@ -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', [

View File

@ -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());

View File

@ -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(
<IntlProvider locale="en" defaultLocale="en">
<Input defaultValue="foo" name="test" ref={(el) => {component = el;}}/>
</IntlProvider>
);
expect(wrapper.find('input[name="test"]').node.value, 'to equal', 'foo');
expect(component.getValue(), 'to equal', 'foo');
});
});