text: "use strict";var _react=require("react"),_react2=_interopRequireDefault(_react),_enzymeAdapterReact=require("enzyme-adapter-react-16"),_enzymeAdapterReact2=_interopRequireDefault(_enzymeAdapterReact),_index=require("../index"),_index2=_interopRequireDefault(_index),_upload=require("../upload"),_request=require("../request"),_getelement=require("../getelement"),_upload2=require("../../css/upload"),_enzyme=require("enzyme"),_enzyme2=_interopRequireDefault(_enzyme),_reactTestRenderer=require("react-test-renderer"),_reactTestRenderer2=_interopRequireDefault(_reactTestRenderer);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}require("jest-styled-components"),_enzyme2.default.configure({adapter:new _enzymeAdapterReact2.default}),describe("Upload Test",function(){function s(){return!0}function i(e){return e.children().instance()}var e,t,a,o={themeConfig:{},themeState:{}},l=(0,_enzyme.mount)(_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,url:"xxxx.test"}));function n(t,a,n){it("Function getIndexInArray ",function(){var e=(0,_upload.getIndexInArray)(t,a.toLowerCase());expect(e).toEqual(n)})}function u(t,a,n){it("Function isKeyInArr ",function(){var e=(0,_upload.isKeyInArray)(t,a.toLowerCase());expect(e).toEqual(n)})}function r(t,a,n){it("Function getPercentValue ",function(){var e=(0,_upload.getPercentValue)(t,a);expect(e).toEqual(n)})}function p(t,a){it("Function getListIconType ",function(){var e=(0,_upload2.getListIconType)(t);expect(e).toEqual(a)})}function c(t,a){it("Function getQueryString ",function(){var e=(0,_request.getQueryString)(t);expect(e).toEqual(a)})}function d(t){it("Function getFormData ",function(){var e=(0,_request.getFormData)(t,{});expect(e instanceof FormData).toEqual(!0)})}function g(n,s,e){var i=2<arguments.length&&void 0!==e?e:{};it("Function GetIconByType ",function(){var e=(0,_getelement.getIconByType)({defaultTips:{uploadText:"上传",uploadTips:"请将文件拖到此处",failTips:"文件上传失败请重试",loadingTips:"文件上传中..."}},n,i),t=i.type;if(n&&e)if("string"==typeof e||1===t&&"default"===n)expect(e).toEqual(s);else{var a=e.props.iconClass;expect(a).toBe(s)}else expect(e).toBe(s)})}function f(e,t){it("Function setStateValue ",function(){i(l).setStateValue(e),expect(i(l).state).toEqual(t)})}function m(t,a,n,s){it("Function updateFieldList ",function(){var e=i(l).updateFieldList(t,a,s);expect(e).toEqual(n)})}function h(t,a){it("Function isEmptyObject ",function(){var e=(0,_upload.isEmptyObject)(t);expect(e).toEqual(a)})}function x(t,a,n){it("Function updateFieldList ",function(){var e=i(l).appendFileList(t,a);expect(e).toEqual(n)})}function j(e,t,a){it("Function uploadProgress ",function(){i(l).setStateValue({fileListDone:[{hashMark:1,name:"文件11111.jpg",status:"default"}]}),i(l).uploadProgress(e,1),expect(i(l).state.classNameStatus).toEqual(t),expect(i(l).state.fileListDone).toEqual(a)})}function _(t,a,n){it("Function isIdInArray ",function(){var e=(0,_upload.isIdInArray)(t,a);expect(e).toEqual(n)})}it("css",function(){var e=_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,url:"xxxx.test"});expect(_reactTestRenderer2.default.create(e).toJSON()).toMatchSnapshot()}),it("props autoUpload true",function(){var e=(0,_enzyme.mount)(_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,autoUpload:!0,url:"xxxx.test"}));expect(i(e).state.isAllowUpload).toEqual(!0)}),it("props autoUpload false",function(){var e=(0,_enzyme.mount)(_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,autoUpload:!1,url:"xxxx.test"}));expect(i(e).state.isAllowUpload).toEqual(!1)}),it("props url",function(){var e=(0,_enzyme.mount)(_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,url:"xxxx.test"}));expect(e.props().url).toEqual("xxxx.test")}),it("props fileList",function(){var e=(0,_enzyme.mount)(_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,url:"xxxx.test",fileList:[{id:1,name:"文件11111.jpg",status:"done"},{id:2,name:"文件666.doc",status:"fail"}]}));expect(i(e).state.fileListDone).toEqual([{id:1,name:"文件11111.jpg",status:"done"},{id:2,name:"文件666.doc",status:"fail"}])}),it("props fileList null",function(){var e=(0,_enzyme.mount)(_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,url:"xxxx.test"}));expect(i(e).state.fileListDone).toEqual([])}),n(["jpg","png","jpeg","gif","svg","bmp"],"jpg",0),n(["jpg","png","jpeg","gif","svg","bmp"],"jPg",0),n(["jpg","png","jpeg","gif","svg","bmp"],"JPG",0),n(["jpg","png","jpeg","gif","svg","bmp"],"jpEg",2),n(["jpg","png","jpeg","gif","svg","bmp"],"ABC",-1),n(["jpg","png","jpeg","gif","svg","bmp"],"BMP",5),u(["jpg","png","jpeg","gif","svg","bmp"],"jpg",!0),u(["jpg","png","jpeg","gif","svg","bmp"],"jPg",!0),u(["jpg","png","jpeg","gif","svg","bmp"],"JPG",!0),u(["jpg","png","jpeg","gif","svg","bmp"],"jpEg",!0),u(["jpg","png","jpeg","gif","svg","bmp"],"ABC",!1),u(["jpg","png","jpeg","gif","svg","bmp"],"BMP",!0),r(2345,3455,67),r(null,3455,0),r(2345,void 0,0),r(3488,3455,100),p("http://jshdfj.jpg","picture"),p("http://jshdfj.png","picture"),p("http://jshdfj.JPEG","picture"),p("http://jshdfj.avi","video"),p("http://jshdfj.MP4","video"),p("http://jshdfj.cccc","file"),p("http://jshdfj.text","file"),p("http://jshdfj.doc","file"),p("","file"),p(null,"file"),p(void 0,"file"),it("Function getRequestXHR ",function(){var e=(0,_request.getRequestXHR)();expect(e instanceof window.XMLHttpRequest).toEqual(!0)}),c({u:23,name:"lll",file:"xsdss"},"u=23&name=lll&file=xsdss"),c({cc:66,df:"lll",file:"xsdss"},"cc=66&df=lll&file=xsdss"),c(null,""),c(void 0,""),c({},""),c({hello:"world"},"hello=world"),d({data:{a:123,b:223},name:"file",file:"666"}),d({data:{a:777,b:888},name:"abc",file:"567"}),g("default","上传",{type:1}),g("default","lugia-icon-financial_upload right"),g("loading","lugia-icon-financial_loading_o loading"),g(void 0,null),g(void 0,null,{type:1}),f({classNameStatus:"done",defaultText:"文件已上传成功！"},{classNameStatus:"done",defaultText:"文件已上传成功！",fileListDone:[],isAllowUpload:!0}),f({classNameStatus:"loading",defaultText:"文件正在上传！"},{classNameStatus:"loading",defaultText:"文件正在上传！",fileListDone:[],isAllowUpload:!0}),f({classNameStatus:"default",defaultText:"文件已上传成功！",abc:"abc"},{abc:"abc",classNameStatus:"default",defaultText:"文件已上传成功！",fileListDone:[],isAllowUpload:!0}),m([{hashMark:1,name:"文件11111.jpg",status:"loading",percent:0},{hashMark:2,name:"文件22222222.jpg",status:"loading"}],1,[{hashMark:1,name:"文件11111.jpg",status:"loading",percent:20},{hashMark:2,name:"文件22222222.jpg",status:"loading"}],[{target:"percent",value:20}]),m([{id:1,name:"文件11111.jpg",status:"loading",percent:20},{id:2,name:"文件22222222.jpg",status:"loading"}],3,[{id:1,name:"文件11111.jpg",status:"loading",percent:20},{id:2,name:"文件22222222.jpg",status:"loading"}],[{target:"percent",value:50}]),h({},!0),h({aa:1},!1),x([{hashMark:1,name:"文件11111.jpg",status:"loading",percent:0}],{hashMark:2,name:"文件2222.jpg",status:"loading"},[{hashMark:1,name:"文件11111.jpg",status:"loading",percent:0},{hashMark:2,name:"文件2222.jpg",status:"loading"}]),x([{hashMark:1,name:"文件11111.jpg",status:"loading",percent:0}],{},[{hashMark:1,name:"文件11111.jpg",status:"loading",percent:0}]),j({loaded:0,total:2048},"loading",[{hashMark:1,name:"文件11111.jpg",status:"loading",percent:0}]),j({loaded:1024,total:2048},"loading",[{hashMark:1,name:"文件11111.jpg",status:"loading",percent:50}]),j({loaded:2048,total:2048},"loading",[{hashMark:1,name:"文件11111.jpg",status:"loading",percent:100}]),j({},"loading",[{hashMark:1,name:"文件11111.jpg",status:"loading",percent:0}]),e={data:{url:"test.jpg"}},a=[{hashMark:1,name:"文件11111.jpg",status:t="done",url:"test.jpg"}],it("Function uploadSuccess ",function(){i(l).setStateValue({fileListDone:[{hashMark:1,name:"文件11111.jpg",status:"default"}]}),i(l).uploadSuccess(e,q,1),expect(i(l).state.classNameStatus).toEqual(t),expect(i(l).state.fileListDone).toEqual(a)}),_("1",[{hashMark:"1",name:"文件11111.jpg",status:"default"}],!0),_("2",[{hashMark:"1",name:"文件11111.jpg",status:"default"}],!1),_("1",[],!1);var P,q=[{lastModified:1541066150245,lastModifiedDate:new Date(1541066150245),name:"headPic.jpg",size:53021,type:"image/jpeg",webkitRelativePath:""}];function v(t,a,n){it("Function setAutoUploadState ",function(){var e=(0,_enzyme.mount)(_react2.default.createElement(_index2.default,{getPartOfThemeHocProps:s,getPartOfThemeProps:s,themeProps:o,url:"xxxx.test"}));a&&i(e).setStateValue({choosedFile:a}),i(e).setAutoUploadState(t),expect(i(e).state.isAllowUpload).toEqual(n)})}function y(e,t){it("Function setDeleteList ",function(){i(l).setStateValue({fileListDone:[{hashMark:1,name:"文件11111.jpg",status:"done"},{hashMark:2,name:"文件2222.jpg",status:"default"}]}),i(l).setDeleteList(e),expect(i(l).state.fileListDone).toEqual(t)})}function E(e,t,a,n){it("Function checkUploadFail ",function(){i(l).setStateValue({fileListDone:[{hashMark:1,name:"文件11111.jpg",status:"loading"}]}),i(l).uploadFail(e,t),expect(i(l).state.classNameStatus).toEqual(a),expect(i(l).state.fileListDone).toEqual(n)})}v(!1,void 0,!0),v(!0,q,!0),v(!1,q,!1),y(1,[{hashMark:1,name:"文件11111.jpg",status:"done"}]),y(0,[{hashMark:2,name:"文件2222.jpg",status:"default"}]),y(2,[{hashMark:1,name:"文件11111.jpg",status:"done"},{hashMark:2,name:"文件2222.jpg",status:"default"}]),E({},1,"fail",[{hashMark:1,name:"文件11111.jpg",status:"fail"}]),E({},2,"fail",[{hashMark:1,name:"文件11111.jpg",status:"loading"}]),P=q,it("Function checkSetChoosedFile ",function(){i(l).setChoosedFile(q),expect(i(l).state.choosedFile).toEqual(P)})});