add rdb sync api mock

Signed-off-by: wuchunbo <wuchunbo1@huawei.com>
This commit is contained in:
wuchunbo
2022-02-15 15:16:22 +08:00
parent a396aa1419
commit 7692ac1301
@@ -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;