mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +05:30
#22: fix tests
This commit is contained in:
parent
6f650ba0c5
commit
e66840a391
@ -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', [
|
||||
|
@ -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());
|
||||
|
20
src/components/ui/form/Input.test.js
Normal file
20
src/components/ui/form/Input.test.js
Normal 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');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user