Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 28db2cc

Browse files
committed
add tests
1 parent 2dbf02a commit 28db2cc

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/async-currenttarget.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ ruleTester.run('async-currenttarget', rule, {
1212
code: 'document.addEventListener(async function(event) { event.currentTarget; await delay() })',
1313
parserOptions: {ecmaVersion: 2017},
1414
},
15+
{
16+
code: 'document.addEventListener(async function(event) { const currentTarget = event.currentTarget; await delay(); foo(() => currentTarget) })',
17+
parserOptions: {ecmaVersion: 2017},
18+
},
1519
],
1620
invalid: [
1721
{
@@ -24,5 +28,15 @@ ruleTester.run('async-currenttarget', rule, {
2428
},
2529
],
2630
},
31+
{
32+
code: 'document.addEventListener(async function(event) { await delay(); foo(() => e.currentTarget) })',
33+
parserOptions: {ecmaVersion: 2017},
34+
errors: [
35+
{
36+
message: 'event.currentTarget inside an async function is error prone',
37+
type: 'MemberExpression',
38+
},
39+
],
40+
},
2741
],
2842
})

tests/async-preventdefault.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,15 @@ ruleTester.run('async-preventdefault', rule, {
2727
},
2828
],
2929
},
30+
{
31+
code: 'document.addEventListener(async function(event) { await delay(); foo(() => event.preventDefault()) })',
32+
parserOptions: {ecmaVersion: 2017},
33+
errors: [
34+
{
35+
message: 'event.preventDefault() inside an async function is error prone',
36+
type: 'CallExpression',
37+
},
38+
],
39+
},
3040
],
3141
})

0 commit comments

Comments
 (0)