1import { hasComplete } from "./utils" 2 3export function mockRequest() { 4 const uploadResponseMock = { 5 code: "[PC Preview]: unknow code", 6 data: "[PC Preview]: unknow data", 7 headers: "[PC Preview]: unknow headers" 8 } 9 const downloadResponse = { 10 token: "[PC Preview]: unknow token" 11 } 12 const onDownloadCompleteMock = { 13 uri: "[PC Preview]: unknow uri" 14 } 15 global.systemplugin.request = { 16 upload: function (...args) { 17 console.warn("system.request.upload interface mocked in the Previewer. How this interface works on the" + 18 " Previewer may be different from that on a real device.") 19 args[0].success(uploadResponseMock) 20 hasComplete(args[0].complete) 21 }, 22 download: function (...args) { 23 console.warn("system.request.download interface mocked in the Previewer. How this interface works on the" + 24 " Previewer may be different from that on a real device.") 25 args[0].success(downloadResponse) 26 hasComplete(args[0].complete) 27 }, 28 onDownloadComplete: function (...args) { 29 console.warn("system.request.onDownloadComplete interface mocked in the Previewer. How this interface works on" + 30 " the Previewer may be different from that on a real device.") 31 args[0].success(onDownloadCompleteMock) 32 hasComplete(args[0].complete) 33 } 34 } 35}