Skip to content

Commit 3b961ea

Browse files
committed
[Tests] jsx-no-script-url: Improve tests
1 parent d1556a3 commit 3b961ea

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

tests/lib/rules/jsx-no-script-url.js

+19-20
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ ruleTester.run('jsx-no-script-url', rule, {
3838
{ code: '<a href={"javascript:"}></a>' },
3939
{ code: '<Foo href="javascript:"></Foo>' },
4040
{ code: '<a href />' },
41+
{
42+
code: '<Foo other="javascript:"></Foo>',
43+
options: [[{ name: 'Foo', props: ['to', 'href'] }]],
44+
},
4145
{
4246
code: '<Foo href="javascript:"></Foo>',
4347
settings: {
@@ -51,6 +55,13 @@ ruleTester.run('jsx-no-script-url', rule, {
5155
linkComponents: [{ name: 'Foo', linkAttribute: ['to', 'href'] }],
5256
},
5357
},
58+
{
59+
code: '<Foo other="javascript:"></Foo>',
60+
options: [[], { includeFromSettings: true }],
61+
settings: {
62+
linkComponents: [{ name: 'Foo', linkAttribute: ['to', 'href'] }],
63+
},
64+
},
5465
]),
5566
invalid: parsers.all([
5667
// defaults
@@ -71,23 +82,18 @@ ruleTester.run('jsx-no-script-url', rule, {
7182
{
7283
code: '<Foo to="javascript:"></Foo>',
7384
errors: [{ messageId: 'noScriptURL' }],
74-
options: [
75-
[{ name: 'Foo', props: ['to', 'href'] }],
76-
],
85+
options: [[{ name: 'Foo', props: ['to', 'href'] }]],
7786
},
7887
{
7988
code: '<Foo href="javascript:"></Foo>',
8089
errors: [{ messageId: 'noScriptURL' }],
81-
options: [
82-
[{ name: 'Foo', props: ['to', 'href'] }],
83-
],
90+
options: [[{ name: 'Foo', props: ['to', 'href'] }]],
8491
},
85-
{ // make sure it still uses defaults when passed options
92+
{
93+
// make sure it still uses defaults when passed options
8694
code: '<a href="javascript:void(0)"></a>',
8795
errors: [{ messageId: 'noScriptURL' }],
88-
options: [
89-
[{ name: 'Foo', props: ['to', 'href'] }],
90-
],
96+
options: [[{ name: 'Foo', props: ['to', 'href'] }]],
9197
},
9298

9399
// with components passed by settings
@@ -117,10 +123,7 @@ ruleTester.run('jsx-no-script-url', rule, {
117123
<Bar link="javascript:"></Bar>
118124
</div>
119125
`,
120-
errors: [
121-
{ messageId: 'noScriptURL' },
122-
{ messageId: 'noScriptURL' },
123-
],
126+
errors: [{ messageId: 'noScriptURL' }, { messageId: 'noScriptURL' }],
124127
options: [
125128
[{ name: 'Bar', props: ['link'] }],
126129
{ includeFromSettings: true },
@@ -136,12 +139,8 @@ ruleTester.run('jsx-no-script-url', rule, {
136139
<Bar link="javascript:"></Bar>
137140
</div>
138141
`,
139-
errors: [
140-
{ messageId: 'noScriptURL' },
141-
],
142-
options: [
143-
[{ name: 'Bar', props: ['link'] }],
144-
],
142+
errors: [{ messageId: 'noScriptURL' }],
143+
options: [[{ name: 'Bar', props: ['link'] }]],
145144
settings: {
146145
linkComponents: [{ name: 'Foo', linkAttribute: ['to', 'href'] }],
147146
},

0 commit comments

Comments
 (0)