update Storage mock file

Signed-off-by: PaDaBoo <xuejianwu@huawei.com>
This commit is contained in:
PaDaBoo
2022-07-18 16:45:01 +08:00
parent 4e75350066
commit d698d8aee1
@@ -15,11 +15,9 @@
import { paramMock } from "../utils"
const ValueTypes = {
unknow: '[PC Preview] unknow value type'
};
const ValueTypes = '[PC Preview] unknow value type'
const StorageObserverMock = {
const StorageObserver = {
key: '[PC Preview] unknown key'
};
const MAX_KEY_LENGTH = 80;
@@ -83,17 +81,17 @@ export function mockDataStorage() {
getSync: function () {
console.warn("Storage.getSync interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return ValueTypes.unknow
return ValueTypes
},
get: function (...args) {
console.warn("Storage.get 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, ValueTypes.unknow)
args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes)
} else {
return new Promise((resolve) => {
resolve(ValueTypes.unknow)
resolve(ValueTypes)
})
}
},
@@ -182,13 +180,13 @@ export function mockDataStorage() {
console.warn("Storage.on 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
args[len - 1].call(this, StorageObserverMock)
args[len - 1].call(this, StorageObserver)
},
off: function (...args) {
console.warn("Storage.off 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
args[len - 1].call(this, storageObserverMock)
args[len - 1].call(this, storageObserver)
}
}
return storage