• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import { paramMock } from "../utils"
2
3export function mockSystemParameter() {
4  const systemParameter = {
5    getSync: function (...args) {
6      console.warn("systemParameter.getSync interface mocked in the Previewer. How this interface works on the" +
7        " Previewer may be different from that on a real device.")
8      return paramMock.paramStringMock
9    },
10    get: function (...args) {
11      console.warn("systemParameter.get interface mocked in the Previewer. How this interface works on the" +
12        " Previewer may be different from that on a real device.")
13      const len = args.length
14      if (typeof args[len - 1] === 'function') {
15        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
16      } else {
17        return new Promise((resolve, reject) => {
18          resolve(paramMock.paramStringMock);
19        })
20      }
21    },
22    setSync: function (...args) {
23      console.warn("systemParameter.setSync interface mocked in the Previewer. How this interface works on the" +
24        " Previewer may be different from that on a real device.")
25    },
26    set: function (...args) {
27      console.warn("systemParameter.set interface mocked in the Previewer. How this interface works on the" +
28        " Previewer may be different from that on a real device.")
29      const len = args.length
30      if (typeof args[len - 1] === 'function') {
31        args[len - 1].call(this, paramMock.businessErrorMock);
32      } else {
33        return new Promise((resolve, reject) => {
34          resolve();
35        })
36      }
37    }
38  }
39  return systemParameter
40}