UNPKG

qt-public-ui

Version:

新设计规范下业务组件库

66 lines 2.19 kB
import React from 'react'; import { mount } from 'enzyme'; import EditName from '../index'; describe('EditName', function () { it("onChange is ok", function () { var fn = jest.fn(); var wrapper = mount( /*#__PURE__*/React.createElement(EditName, { title: "\u5C5E\u6027\u540D\u79F01", value: "cxw", okText: "Yes", cancelText: "No", placeholder: "\u8BF7\u8F93\u5165\u5C5E\u6027\u540D\u79F0", placement: "left", width: "240px", onChange: fn })); wrapper.find('.edit-name-icon-style').at(0).simulate('click'); wrapper.find('.ant-popover-buttons').children().at(1).simulate('click'); expect(fn).toHaveBeenCalledWith('cxw'); wrapper.find('.edit-name-icon-style').at(0).simulate('click'); wrapper.find('input').simulate('change', { target: { value: 'cccccccc' } }); wrapper.find('.ant-popover-buttons').children().at(1).simulate('click'); expect(fn).toHaveBeenCalledWith('cccccccc'); }); it("checkName is ok", function () { var fn = jest.fn(); var fn2 = jest.fn(); var wrapper = mount( /*#__PURE__*/React.createElement(EditName, { title: "\u5C5E\u6027\u540D\u79F01", value: "cxw", okText: "Yes", cancelText: "No", placeholder: "\u8BF7\u8F93\u5165\u5C5E\u6027\u540D\u79F0", placement: "left", width: "240px", checkName: fn, onChange: fn2 })); wrapper.find('.edit-name-icon-style').at(0).simulate('click'); wrapper.find('input').simulate('change', { target: { value: 'cccccccc' } }); expect(fn).toHaveBeenCalledWith('cccccccc'); }); it("ant-popover renders correctly", function () { var fn = jest.fn(); var wrapper = mount( /*#__PURE__*/React.createElement(EditName, { title: "\u5C5E\u6027\u540D\u79F01", value: "cxw", okText: "Yes", cancelText: "No", placeholder: "\u8BF7\u8F93\u5165\u5C5E\u6027\u540D\u79F0", placement: "left", width: "240px", onChange: fn })); wrapper.find('.edit-name-icon-style').at(0).simulate('click'); expect(wrapper.find('.ant-popover').render()).toMatchSnapshot(); }); });