!123 add filemanager mock

Merge pull request !123 from zhangxingxia/master
This commit is contained in:
openharmony_ci
2022-01-20 03:11:50 +00:00
committed by Gitee
2 changed files with 46 additions and 0 deletions
@@ -0,0 +1,43 @@
import { paramMock } from "../utils"
export function mockFileManager() {
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)
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
listFile: function (...args) {
console.warn("filemanager.listFile 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)
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
createFile: function (...args) {
console.warn("filemanager.createFile 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 filemanager;
}
@@ -39,6 +39,7 @@ import { mockUri } from './uri'
import { mockXml } from './xml'
import { mockConvertXml } from './convertxml'
import { mockStatfs } from './statfs'
import { mockFileManager } from "./filemanager"
import { mockSettings } from './settings'
import { mockAbilityAccessCtrl } from './abilityAccessCtrl'
@@ -127,6 +128,8 @@ export function mockRequireNapiFun() {
return mockConvertXml();
case "statfs":
return mockStatfs();
case "filemanager":
return mockFileManager();
case "settings":
return mockSettings();
case "abilityAccessCtrl":