'use strict';

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _react = require('react');

var React = _interopRequireWildcard(_react);

var _ = require('..');

var _2 = _interopRequireDefault(_);

var _input = require('../../input');

var _input2 = _interopRequireDefault(_input);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

describe('Form.typescript', function () {
    it('Form.Item', function () {
        var form = React.createElement(
            _2['default'],
            null,
            React.createElement(
                _2['default'].Item,
                { name: 'test' },
                React.createElement(_input2['default'], null)
            )
        );
        expect(form).toBeTruthy();
    });
    describe('generic', function () {
        it('hooks', function () {
            var Demo = function Demo() {
                var _Form$useForm = _2['default'].useForm(),
                    _Form$useForm2 = (0, _slicedToArray3['default'])(_Form$useForm, 1),
                    form = _Form$useForm2[0];

                form.setFieldsValue({ path1: { path2: 2333 } });
                return React.createElement(_2['default'], { 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) {
                (0, _inherits3['default'])(Demo, _React$Component);

                function Demo() {
                    (0, _classCallCheck3['default'])(this, Demo);

                    var _this = (0, _possibleConstructorReturn3['default'])(this, (Demo.__proto__ || Object.getPrototypeOf(Demo)).apply(this, arguments));

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

                (0, _createClass3['default'])(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(_2['default'], { 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(
                _2['default'],
                null,
                React.createElement(
                    _2['default'].Item,
                    null,
                    function (_ref) {
                        var getFieldsValue = _ref.getFieldsValue;

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