update jsmock

Signed-off-by: zhangxingxia <zhangxingxia1@huawei.com>
This commit is contained in:
zhangxingxia
2022-07-14 09:19:19 +08:00
parent f8909aa8e8
commit 398415f88e
3 changed files with 13 additions and 54 deletions
@@ -74,7 +74,6 @@ import { mockAbilityAccessCtrl } from './ohos_abilityAccessCtrl'
import { mockConfigPolicy } from './ohos_configPolicy'
import { mockUpdate } from './ohos_update'
import { mockBackgroundTaskManager } from './ohos_backgroundTaskManager'
import { mockSecurityLabel } from './ohos_securitylabel'
import { mockWorkScheduler } from './ohos_workScheduler'
import { mockWorkSchedulerExtensionAbility } from './ohos_WorkSchedulerExtensionAbility'
import { mockUserAuth } from './ohos_userIAM_userAuth'
@@ -342,7 +341,7 @@ export function mockRequireNapiFun() {
return mockConvertXml();
case "statfs":
return mockStatfs();
case "filemanager":
case "fileManager":
return mockFileManager();
case "environment":
return mockEnvironment();
@@ -360,8 +359,6 @@ export function mockRequireNapiFun() {
return mockUpdate();
case "backgroundTaskManager":
return mockBackgroundTaskManager();
case "securitylabel":
return mockSecurityLabel();
case "workScheduler":
return mockWorkScheduler();
case "WorkSchedulerExtensionAbility":
@@ -16,16 +16,24 @@
import { paramMock } from "../utils"
export function mockFileManager() {
const fileInfoMock = {
name: '[PC preview] unknow name',
path: '[PC preview] unknow path',
type: '[PC preview] unknow type',
size: '[PC preview] unknow size',
addedTime: '[PC preview] unknow addedTime',
modifiedTime: '[PC preview] unknow modifiedTime',
};
const filemanager = {
getRoot: function (...args) {
console.warn("filemanager.getRoot 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.paramArrayMock)
args[len - 1].call(this, paramMock.businessErrorMock, Array(fileInfoMock))
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
resolve(Array(fileInfoMock));
})
}
},
@@ -34,10 +42,10 @@ export function mockFileManager() {
" 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.paramArrayMock)
args[len - 1].call(this, paramMock.businessErrorMock, Array(fileInfoMock))
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
resolve(Array(fileInfoMock));
})
}
},
@@ -1,46 +0,0 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockSecurityLabel() {
const securitylabel = {
setSecurityLabel: function (...args) {
console.warn("securitylabel.setSecurityLabel 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, reject) => {
resolve();
})
}
},
getSecurityLabel: function (...args) {
console.warn("securitylabel.getSecurityLabel 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, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
}
return securitylabel;
}