mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
!101 add statfs js api mock
Merge pull request !101 from shuzhouhao/OpenHarmony-3.1-Beta
This commit is contained in:
@@ -34,6 +34,7 @@ import { mockWifi } from './wifi'
|
||||
import { mockSettings } from './settings'
|
||||
import { mockUri } from './uri'
|
||||
import { mockXml } from './xml'
|
||||
import { mockStatfs } from './statfs'
|
||||
|
||||
export function mockRequireNapiFun() {
|
||||
global.requireNapi = function (...args) {
|
||||
@@ -110,6 +111,8 @@ export function mockRequireNapiFun() {
|
||||
return mockUri();
|
||||
case "xml":
|
||||
return mockXml();
|
||||
case "statfs":
|
||||
return mockStatfs();
|
||||
default:
|
||||
return global.requireNapiPreview(...args);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockStatfs() {
|
||||
const statfs = {
|
||||
getFreeBytes: function (...args) {
|
||||
console.warn("statfs.getFreeBytes 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.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getTotalBytes: function (...args) {
|
||||
console.warn("statfs.getTotalBytes 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.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
return statfs;
|
||||
}
|
||||
Reference in New Issue
Block a user