import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import _slicedToArray from 'babel-runtime/helpers/slicedToArray';
import * as React from 'react';
import Form from '..';
import Input from '../../input';
describe('Form.typescript', function () {
    it('Form.Item', function () {
        var form = React.createElement(
            Form,
            null,
            React.createElement(
                Form.Item,
                { name: 'test' },
                React.createElement(Input, null)
            )
        );
        expect(form).toBeTruthy();
    });
    describe('generic', function () {
        it('hooks', function () {
            var Demo = function Demo() {
                var _Form$useForm = Form.useForm(),
                    _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
                    form = _Form$useForm2[0];

                form.setFieldsValue({ path1: { path2: 2333 } });
                return React.createElement(Form, { form: form, onFinish: function onFinish(values) {
                        var _a;
                        expect(values).toBeTruthy();
                        expect(values.username).toBeTruthy();
                        expect((_a = values.path1) === null || _a === void 0 ? void 0 : _a.path2).toBeTruthy();
                    } });
            };
            expect(Demo).toBeTruthy();
        });
        it('ref', function () {
            var Demo = function (_React$Component) {
                _inherits(Demo, _React$Component);

                function Demo() {
                    _classCallCheck(this, Demo);

                    var _this = _possibleConstructorReturn(this, (Demo.__proto__ || Object.getPrototypeOf(Demo)).apply(this, arguments));

                    _this.formRef = React.createRef();
                    return _this;
                }

                _createClass(Demo, [{
                    key: 'componentDidMount',
                    value: function componentDidMount() {
                        var _a;
                        (_a = this.formRef.current) === null || _a === void 0 ? void 0 : _a.setFieldsValue({ path1: { path2: 233 } });
                    }
                }, {
                    key: 'render',
                    value: function render() {
                        return React.createElement(Form, { ref: this.formRef, onFinish: function onFinish(values) {
                                var _a;
                                expect(values).toBeTruthy();
                                expect(values.username).toBeTruthy();
                                expect((_a = values.path1) === null || _a === void 0 ? void 0 : _a.path2).toBeTruthy();
                            } });
                    }
                }]);

                return Demo;
            }(React.Component);

            expect(Demo).toBeTruthy();
        });
    });
    it('FormItem renderProps support generic', function () {
        var Demo = function Demo() {
            return React.createElement(
                Form,
                null,
                React.createElement(
                    Form.Item,
                    null,
                    function (_ref) {
                        var getFieldsValue = _ref.getFieldsValue;

                        var values = getFieldsValue();
                        expect(values).toBeTruthy();
                        return null;
                    }
                )
            );
        };
        expect(Demo).toBeTruthy();
    });
});