|
@@ -1,10 +1,13 @@
|
|
|
const Mock = require('mockjs')
|
|
|
const { param2Obj } = require('./utils')
|
|
|
|
|
|
+let mocks = []
|
|
|
+
|
|
|
// for front mock
|
|
|
// please use it cautiously, it will redefine XMLHttpRequest,
|
|
|
// which will cause many of your third-party libraries to be invalidated(like progress event).
|
|
|
-function mockXHR(mocks) {
|
|
|
+function mockXHR(inputMocks) {
|
|
|
+ mocks = inputMocks
|
|
|
// mock patch
|
|
|
// https://github.com/nuysoft/Mock/issues/300
|
|
|
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
|
|
@@ -42,5 +45,8 @@ function mockXHR(mocks) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-module.exports = mockXHR
|
|
|
+module.exports = {
|
|
|
+ mockXHR,
|
|
|
+ mocks,
|
|
|
+}
|
|
|
|