UNPKG

mini-program-request-mock

Version:
2 lines (1 loc) 1.01 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).requestMock={})}(this,(function(t){"use strict";var e={},r=function(){function t(t){this.reqData=null,this.resData=null,this.errData=null,t&&this.get(t)}return t.prototype.get=function(t){return this.reqData=t,e[JSON.stringify(this.reqData)]=this,this},t.prototype.getErrData=function(){return this.errData},t.prototype.getReqData=function(){return this.reqData},t.prototype.getResData=function(){return this.resData},t.prototype.success=function(t){return this.resData=t,this},t.prototype.fail=function(t){return this.errData=t,this},t}();global.wx.request=jest.fn().mockImplementation((function(t){var r=e[JSON.stringify(t)];return r.getErrData()&&t.fail(r.getErrData()),t.success(r.getResData())})),t.default=r,Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=request-mock.min.js.map