未验证 提交 7294104c 编写于 作者: O openharmony_ci 提交者: Gitee

!6614 【Distributeddatamgr】【master】增加对off(type: 'change', callback?: Callback<{...

!6614 【Distributeddatamgr】【master】增加对off(type: 'change', callback?: Callback<{ key : string }>): void接口的异常用例
Merge pull request !6614 from 梁梁/master
......@@ -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();
})
......
......@@ -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();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册