1import { paramMock } from "../utils" 2 3export function mockRunningLock() { 4 const RunningLockMock = { 5 lock: function (...args) { 6 console.warn("RunningLock.lock interface mocked in the Previewer. How this interface works on the Previewer" + 7 " may be different from that on a real device.") 8 }, 9 isUsed: function () { 10 console.warn("RunningLock.isUsed interface mocked in the Previewer. How this interface works on the" + 11 " Previewer may be different from that on a real device.") 12 return paramMock.paramBooleanMock 13 }, 14 unlock: function () { 15 console.warn("RunningLock.unlock interface mocked in the Previewer. How this interface works on the Previewer" + 16 " may be different from that on a real device.") 17 } 18 }; 19 const runningLock = { 20 isRunningLockTypeSupported: function (...args) { 21 console.warn("runningLock.isRunningLockTypeSupported interface mocked in the Previewer. How this interface works on the" + 22 " Previewer may be different from that on a real device.") 23 const len = args.length 24 if (typeof args[len - 1] === 'function') { 25 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 26 } else { 27 return new Promise((resolve, reject) => { 28 resolve(paramMock.paramBooleanMock); 29 }) 30 } 31 }, 32 createRunningLock: function (...args) { 33 console.warn("runningLock.createRunningLock interface mocked in the Previewer. How this interface works on the" + 34 " Previewer may be different from that on a real device.") 35 const len = args.length 36 if (typeof args[len - 1] === 'function') { 37 args[len - 1].call(this, paramMock.businessErrorMock, RunningLockMock); 38 } else { 39 return new Promise((resolve, reject) => { 40 resolve(RunningLockMock); 41 }) 42 } 43 } 44 } 45 return runningLock 46}