diff --git a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js index 457332ec06f09521d58987b4689e56c4e10b3c15..e8c184bc540d0a6b428ce77cea9fd86e2c9d4b0d 100644 --- a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js @@ -61,6 +61,9 @@ try { expect(null).assertFail() } } +function storeObserver(devices) { + console.info(TAG + devices + " dataChange"); +} export default function rdbStoreDistributedTest() { describe('rdbStoreDistributedTest', function () { @@ -343,11 +346,14 @@ describe('rdbStoreDistributedTest', function () { */ it('testRdbStoreDistributed0012', 0, async function (done) { console.info(TAG + "************* testRdbStoreDistributed0012 start *************"); - rdbStore.on("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "on dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + rdbStore.on("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "on dataChange success "); + expect(rdbStore).assertEqual(rdbStore); + }catch(err){ + console.info(TAG + "on dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0012 end *************"); }) @@ -357,13 +363,16 @@ describe('rdbStoreDistributedTest', function () { * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_013 * @tc.desc subscribe test */ - it('testRdbStoreDistributed0013', 0, async function (done) { + it('testRdbStoreDistributed0013', 0, function (done) { console.info(TAG + "************* testRdbStoreDistributed0013 start *************"); - rdbStore.off("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "off dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + let off = rdbStore.on("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "off dataChange success " + off); + expect(rdbStore).assertEqual(rdbStore); + }catch(err){ + console.info(TAG + "off dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0013 end *************"); }) diff --git a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js index 32e72b05ba3636fe005640c04c666a6f1d8e737d..113b1da5d9eb1f86f03cc1a14a966134d9d6108f 100644 --- a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js @@ -175,12 +175,13 @@ describe('rdbEncryptTest', function () { rdbStore = null try { rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) + expect(rdbStore !== null).assertFalse() } catch (err) { console.info(TAG + `catch err: ` + err) - expect(err).assertTrue + expect(rdbStore).assertEqual(null) + done() + console.info(TAG + "************* RdbEncryptTest_0040 end *************") } - done() - console.info(TAG + "************* RdbEncryptTest_0040 end *************") }) console.info(TAG + "*************Unit Test End*************") } diff --git a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js index b796590f13b6fd1005119db1e96eb9b925474e37..1878a0376f05d29e139a3c4770a1c40a6cd4f013 100644 --- a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js @@ -64,6 +64,10 @@ try { } } +function storeObserver(devices) { + console.info(TAG + devices + " dataChange"); +} + export default function relationalStoreDistributedTest() { describe('relationalStoreDistributedTest', function () { beforeAll(async function () { @@ -345,11 +349,14 @@ describe('relationalStoreDistributedTest', function () { */ it('testRdbStoreDistributed0012', 0, async function (done) { console.info(TAG + "************* testRdbStoreDistributed0012 start *************"); - rdbStore.on("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "on dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + rdbStore.on("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "on dataChange success "); + expect(rdbStore).assertEqual(rdbStore); + }catch(err){ + console.info(TAG + "on dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0012 end *************"); }) @@ -359,13 +366,16 @@ describe('relationalStoreDistributedTest', function () { * @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_013 * @tc.desc subscribe test */ - it('testRdbStoreDistributed0013', 0, async function (done) { + it('testRdbStoreDistributed0013', 0, function (done) { console.info(TAG + "************* testRdbStoreDistributed0013 start *************"); - rdbStore.off("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "off dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + let off = rdbStore.on("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "off dataChange success " + off); + expect(rdbStore).assertEqual(rdbStore); + }catch(err){ + console.info(TAG + "off dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0013 end *************"); }) diff --git a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js index a6be9c8549410f8710270367d047981422523e06..618bf0da34425936e24e505b5fae7954e407c113 100644 --- a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js @@ -178,13 +178,13 @@ describe('relationalStoreEncryptTest', function () { rdbStore = null try { rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) + expect(rdbStore !== null).assertFalse() } catch (err) { console.info(TAG + `catch err: err.code= ${err.code}, message = ${err.message}`) - expect(err.code === 14800000).assertTrue + expect(err.code).assertEqual(14800000); + done() + console.info(TAG + "************* RdbEncryptTest_0040 end *************") } - - done() - console.info(TAG + "************* RdbEncryptTest_0040 end *************") }) console.info(TAG + "*************Unit Test End*************") }