mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 22:43:32 -04:00
9c1a3fb6b3
Signed-off-by: sunfei <sunfei.sun@huawei.com> Change-Id: I5a1d9297c3236ecdd06304d1efcac2b37647ee14
69 lines
3.0 KiB
JavaScript
69 lines
3.0 KiB
JavaScript
import { paramMock } from "./utils"
|
|
|
|
export function mockSettings () {
|
|
const mockInfo = {
|
|
URI : "[PC Preview] unknow string"
|
|
}
|
|
global.systemplugin.settings = {
|
|
getURI: function (...args) {
|
|
console.warn("settings.getURI interface mocked in the Previewer. How this interface works on the" +
|
|
" Previewer may be different from that on a real device.")
|
|
const len = args.length
|
|
if (typeof args[len - 1] === 'function') {
|
|
args[len - 1].call(this, paramMock.businessErrorMock, mockInfo)
|
|
} else {
|
|
return new Promise((resolve) => {
|
|
resolve(mockInfo);
|
|
})
|
|
}
|
|
},
|
|
getValue: function (...args) {
|
|
console.warn("settings.getValue interface mocked in the Previewer. How this interface works on the" +
|
|
" Previewer may be different from that on a real device.")
|
|
const len = args.length
|
|
if (typeof args[len - 1] === 'function') {
|
|
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
|
|
} else {
|
|
return new Promise((resolve) => {
|
|
resolve(paramMock.paramStringMock);
|
|
})
|
|
}
|
|
},
|
|
setValue: function (...args) {
|
|
console.warn("settings.setValue interface mocked in the Previewer. How this interface works on the" +
|
|
" Previewer may be different from that on a real device.")
|
|
const len = args.length
|
|
if (typeof args[len - 1] === 'function') {
|
|
args[len - 1].call(this, paramMock.businessErrorMock)
|
|
} else {
|
|
return new Promise((resolve) => {
|
|
resolve();
|
|
})
|
|
}
|
|
},
|
|
enableAirplaneMode: function (...args) {
|
|
console.warn("settings.enableAirplaneMode interface mocked in the Previewer. How this interface works on the" +
|
|
" Previewer may be different from that on a real device.")
|
|
const len = args.length
|
|
if (typeof args[len - 1] === 'function') {
|
|
args[len - 1].call(this, paramMock.businessErrorMock)
|
|
} else {
|
|
return new Promise((resolve) => {
|
|
resolve();
|
|
})
|
|
}
|
|
},
|
|
canShowFloating: function (...args) {
|
|
console.warn("settings.canShowFloating interface mocked in the Previewer. How this interface works on the" +
|
|
" Previewer may be different from that on a real device.")
|
|
const len = args.length
|
|
if (typeof args[len - 1] === 'function') {
|
|
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
|
} else {
|
|
return new Promise((resolve) => {
|
|
resolve(paramMock.paramBooleanMock);
|
|
})
|
|
}
|
|
},
|
|
}
|
|
} |