提交 17fe3d0a 编写于 作者: O openharmony_ci 提交者: Gitee

!858 add off testcase

Merge pull request !858 from yaojian16/cherry-pick-1633933389
......@@ -384,6 +384,47 @@ describe('workerTest', function () {
expect(times).assertEqual(10)
})
// check worker off function is ok
it('worker_off_test_001', 0, function () {
var ss = new worker.Worker("workers/worker.js");
var zhangsan_times = 0;
ss.on("zhangsan", ()=>{
zhangsan_times++;
})
ss.dispatchEvent({type: "zhangsan"})
expect(zhangsan_times).assertEqual(1)
ss.off("zhangsan")
ss.dispatchEvent({type: "zhangsan"})
ss.dispatchEvent({type: "zhangsan"})
expect(zhangsan_times).assertEqual(1)
})
// check worker off function is ok
it('worker_off_test_002', 0, function () {
var ss = new worker.Worker("workers/worker.js");
var zhangsan_times = 0;
ss.on("zhangsan", ()=>{
zhangsan_times++;
})
ss.dispatchEvent({type: "zhangsan"})
ss.dispatchEvent({type: "zhangsan"})
expect(zhangsan_times).assertEqual(2)
for (var i=0;i<3;i++)
{
ss.off("zhangsan")
}
ss.dispatchEvent({type: "zhangsan"})
expect(zhangsan_times).assertEqual(2)
})
// check worker removeEventListener function is ok
it('worker_removeListener_test_001', 0, function () {
var ss = new worker.Worker("workers/worker.js");
......@@ -423,7 +464,6 @@ describe('workerTest', function () {
ss.dispatchEvent({type: "zhangsan"})
expect(zhangsan_times).assertEqual(2)
})
// check worker removeAllListener function is ok
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册