Skip to content

Commit 321f354

Browse files
committed
Add test cases for arrow functions
1 parent 9f76459 commit 321f354

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/lib/rules/jsx-wrap-multilines.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ var ASSIGNMENT_NO_PAREN = '\
7373
<p>Hello</p>\n\
7474
</div>;';
7575

76+
var ARROW_SINGLE_LINE = 'var hello = () => <p>Hello</p>;';
77+
78+
var ARROW_PAREN = '\
79+
var hello = () => (<div>\n\
80+
<p>Hello</p>\n\
81+
</div>);';
82+
83+
var ARROW_NO_PAREN = '\
84+
var hello = () => <div>\n\
85+
<p>Hello</p>\n\
86+
</div>;';
87+
7688
// ------------------------------------------------------------------------------
7789
// Tests
7890
// ------------------------------------------------------------------------------
@@ -112,6 +124,18 @@ ruleTester.run('jsx-wrap-multilines', rule, {
112124
code: ASSIGNMENT_NO_PAREN,
113125
options: [{assignment: false}],
114126
parserOptions: parserOptions
127+
}, {
128+
code: ARROW_PAREN,
129+
options: [],
130+
parserOptions: parserOptions
131+
}, {
132+
code: ARROW_SINGLE_LINE,
133+
options: [],
134+
parserOptions: parserOptions
135+
}, {
136+
code: ARROW_NO_PAREN,
137+
options: [{arrow: false}],
138+
parserOptions: parserOptions
115139
}
116140
],
117141

@@ -149,6 +173,12 @@ ruleTester.run('jsx-wrap-multilines', rule, {
149173
parserOptions: parserOptions,
150174
options: [{assignment: true}],
151175
errors: [{message: 'Missing parentheses around multilines JSX'}]
176+
}, {
177+
code: ARROW_NO_PAREN,
178+
output: ARROW_PAREN,
179+
parserOptions: parserOptions,
180+
options: [{arrow: true}],
181+
errors: [{message: 'Missing parentheses around multilines JSX'}]
152182
}
153183
]
154184
});

0 commit comments

Comments
 (0)