diff --git a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesCallBackJsunit.test.js b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesCallBackJsunit.test.js index e265ba745609c757d3a4134e8649bac84e11aada..b58db0ae7c91d78df9526cdf9d7490569875d1fc 100644 --- a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesCallBackJsunit.test.js +++ b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesCallBackJsunit.test.js @@ -412,12 +412,36 @@ describe('preferencesV9CallbackTest', async function () { console.info('SUB_DDM_JSPREFERENCEV9_CALLBACK_1600 key' + key); }; mPreference.on('change', observer); - mPreference.off('change', observer); + mPreference.off('sschange', observer); + expect(false).assertTrue() await mPreference.put(KEY_TEST_STRING_ELEMENT, "abb"); await mPreference.flush(); } catch (err) { console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message) + mPreference.off('change', observer); + } + done(); + }) + + /** + * @tc.name mPreference.off() + * @tc.number SUB_DDM_JSPREFERENCEV9_CALLBACK_1700 + * @tc.desc mPreference.off() + */ + it('SUB_DDM_JSPREFERENCEV9_CALLBACK_1700', 0, async function (done) { + console.log("SUB_DDM_JSPREFERENCEV9_CALLBACK_1700 begin.") + try { + var observer = function (key) { + console.info('SUB_DDM_JSPREFERENCEV9_CALLBACK_1700 key' + key); + }; + mPreference.on('change', observer); + mPreference.off('change', "observer"); expect(false).assertTrue() + await mPreference.put(KEY_TEST_STRING_ELEMENT, "abb"); + await mPreference.flush(); + } catch (err) { + console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message) + mPreference.off('change', observer); } done(); }) diff --git a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesPromiseJsunit.test.js b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesPromiseJsunit.test.js index 0435ad8b8e10eaffab82ce93d64a89a66a3d29e3..cac7c359f84d25d18d295d9d17dda6d7be18f167 100644 --- a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesPromiseJsunit.test.js +++ b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/V9_PreferencesPromiseJsunit.test.js @@ -412,12 +412,36 @@ describe('preferencesV9PromiseTest', async function () { console.info('SUB_DDM_JSPREFERENCEV9_PROMISE_1600 key' + key); }; mPreference.on('change', observer); - mPreference.off('change', observer); + mPreference.off('sschange', observer); + expect(false).assertTrue() await mPreference.put(KEY_TEST_STRING_ELEMENT, "abb"); await mPreference.flush(); } catch (err) { console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message) + mPreference.off('change', observer); + } + done(); + }) + + /** + * @tc.name mPreference.off() + * @tc.number SUB_DDM_JSPREFERENCEV9_PROMISE_1700 + * @tc.desc mPreference.off() + */ + it('SUB_DDM_JSPREFERENCEV9_PROMISE_1700', 0, async function (done) { + console.log("SUB_DDM_JSPREFERENCEV9_PROMISE_1700 begin.") + try { + var observer = function (key) { + console.info('SUB_DDM_JSPREFERENCEV9_PROMISE_1700 key' + key); + }; + mPreference.on('change', observer); + mPreference.off('change', "observer"); expect(false).assertTrue() + await mPreference.put(KEY_TEST_STRING_ELEMENT, "abb"); + await mPreference.flush(); + } catch (err) { + console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message) + mPreference.off('change', observer); } done(); })