2017-01-13 21:52:48 +08:00
|
|
|
import React from 'react';
|
2017-10-31 13:56:43 +08:00
|
|
|
import { shallow, mount } from 'enzyme';
|
2017-01-13 21:52:48 +08:00
|
|
|
import Form from '..';
|
|
|
|
|
|
|
|
describe('Form', () => {
|
|
|
|
it('hideRequiredMark', () => {
|
|
|
|
const wrapper = shallow(
|
|
|
|
<Form hideRequiredMark />
|
|
|
|
);
|
|
|
|
expect(wrapper.hasClass('ant-form-hide-required-mark')).toBe(true);
|
|
|
|
});
|
2017-10-31 13:56:43 +08:00
|
|
|
|
|
|
|
describe('wrappedComponentRef', () => {
|
|
|
|
it('warns on functional component', () => {
|
|
|
|
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
const TestForm = () => <Form />;
|
|
|
|
const Wrapped = Form.create()(TestForm);
|
|
|
|
mount(<Wrapped wrappedComponentRef={() => {}} />);
|
|
|
|
expect(spy).toHaveBeenCalled();
|
|
|
|
spy.mockReset();
|
|
|
|
spy.mockRestore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('get component ref', () => {
|
|
|
|
class TestForm extends React.Component { // eslint-disable-line
|
|
|
|
render() {
|
|
|
|
return <Form />;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const Wrapped = Form.create()(TestForm);
|
|
|
|
let form;
|
|
|
|
mount(<Wrapped wrappedComponentRef={node => form = node} />);
|
|
|
|
expect(form).toBeInstanceOf(TestForm);
|
|
|
|
});
|
|
|
|
});
|
2017-01-13 21:52:48 +08:00
|
|
|
});
|