From 7692ac130138cb0530dbe9c428b4aea129df5ce5 Mon Sep 17 00:00:00 2001 From: wuchunbo Date: Tue, 15 Feb 2022 15:16:22 +0800 Subject: [PATCH] add rdb sync api mock Signed-off-by: wuchunbo --- runtime/main/extend/systemplugin/napi/rdb.js | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/rdb.js b/runtime/main/extend/systemplugin/napi/rdb.js index 32569f62..dfcf7dd8 100644 --- a/runtime/main/extend/systemplugin/napi/rdb.js +++ b/runtime/main/extend/systemplugin/napi/rdb.js @@ -159,6 +159,16 @@ export const RdbPredicatesClass = class RdbPredicates { " Previewer may be different from that on a real device.") return new RdbPredicatesClass(); }; + this.inDevices = function (...args) { + console.warn("RdbPredicates.inDevices interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return new RdbPredicatesClass(); + }; + this.inAllDevices = function (...args) { + console.warn("RdbPredicates.inAllDevices interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return new RdbPredicatesClass(); + }; } }; @@ -346,6 +356,54 @@ export function mockRdb() { }) } } + setDistributedTables: function (...args) { + console.warn("RdbStore.setDistributedTables 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + sync: function (...args) { + console.warn("RdbStore.sync 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + on: function (...args) { + console.warn("RdbStore.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 + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + off: function (...args) { + console.warn("RdbStore.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 + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } }; return rdbMock;