提交 2883a47b 编写于 作者: Y y00576111

add off testcase

Signed-off-by: Ny00576111 <yaojian16@huawei.com>
Change-Id: Icfd03eda155e674901ae88273c7aadf1fd048282
上级 57b6e724
......@@ -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.
先完成此消息的编辑!
想要评论请 注册