mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
!632 挑单weekly:新增HiAppEvent订阅接口Mock
Merge pull request !632 from lyj/cherry-pick-1660053516
This commit is contained in:
@@ -17,7 +17,27 @@ import { paramMock } from "../utils"
|
||||
|
||||
function buildMockInfo(interfaceName) {
|
||||
return interfaceName + " interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device."
|
||||
" may be different from that on a real device.";
|
||||
}
|
||||
|
||||
const AppEventPackage = {
|
||||
packageId: paramMock.paramNumberMock,
|
||||
row: paramMock.paramNumberMock,
|
||||
size: paramMock.paramNumberMock,
|
||||
data: paramMock.paramArrayMock
|
||||
}
|
||||
|
||||
const AppEventPackageHolderClass = class AppEventPackageHolder {
|
||||
constructor(...args) {
|
||||
console.warn(buildMockInfo("AppEventPackageHolder.constructor"));
|
||||
this.setSize = function (...arg) {
|
||||
console.warn(buildMockInfo("AppEventPackageHolder.setSize"));
|
||||
};
|
||||
this.takeNext = function (...arg) {
|
||||
console.warn(buildMockInfo("AppEventPackageHolder.takeNext"));
|
||||
return AppEventPackage;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function mockHiAppEvent() {
|
||||
@@ -42,6 +62,7 @@ export function mockHiAppEvent() {
|
||||
EventType: EventTypeMock,
|
||||
Event: EventMock,
|
||||
Param: ParamMock,
|
||||
AppEventPackageHolder: AppEventPackageHolderClass,
|
||||
write: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.write"))
|
||||
const len = args.length
|
||||
@@ -56,7 +77,17 @@ export function mockHiAppEvent() {
|
||||
configure: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.configure"));
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
addWatcher: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.addWatcher"));
|
||||
return new AppEventPackageHolderClass();
|
||||
},
|
||||
removeWatcher: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.removeWatcher"));
|
||||
},
|
||||
clearData: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.clearData"));
|
||||
}
|
||||
}
|
||||
return hiAppEvent
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user