@@ -107,6 +107,11 @@ ruleTester.run('jsx-indent', rule, {
107107 ' <Foo />' ,
108108 '</App>'
109109 ] . join ( '\n' ) ,
110+ output : [
111+ '<App>' ,
112+ ' <Foo />' ,
113+ '</App>'
114+ ] . join ( '\n' ) ,
110115 parserOptions : parserOptions ,
111116 errors : [ { message : 'Expected indentation of 4 space characters but found 2.' } ]
112117 } , {
@@ -115,6 +120,11 @@ ruleTester.run('jsx-indent', rule, {
115120 ' <Foo />' ,
116121 '</App>'
117122 ] . join ( '\n' ) ,
123+ output : [
124+ '<App>' ,
125+ ' <Foo />' ,
126+ '</App>'
127+ ] . join ( '\n' ) ,
118128 options : [ 2 ] ,
119129 parserOptions : parserOptions ,
120130 errors : [ { message : 'Expected indentation of 2 space characters but found 4.' } ]
@@ -135,6 +145,13 @@ ruleTester.run('jsx-indent', rule, {
135145 ' </App>;' ,
136146 '}'
137147 ] . join ( '\n' ) ,
148+ output : [
149+ 'function App() {' ,
150+ ' return <App>' ,
151+ ' <Foo />' ,
152+ ' </App>;' ,
153+ '}'
154+ ] . join ( '\n' ) ,
138155 options : [ 2 ] ,
139156 parserOptions : parserOptions ,
140157 errors : [ { message : 'Expected indentation of 2 space characters but found 9.' } ]
@@ -146,6 +163,13 @@ ruleTester.run('jsx-indent', rule, {
146163 ' </App>);' ,
147164 '}'
148165 ] . join ( '\n' ) ,
166+ output : [
167+ 'function App() {' ,
168+ ' return (<App>' ,
169+ ' <Foo />' ,
170+ ' </App>);' ,
171+ '}'
172+ ] . join ( '\n' ) ,
149173 options : [ 2 ] ,
150174 parserOptions : parserOptions ,
151175 errors : [ { message : 'Expected indentation of 2 space characters but found 4.' } ]
@@ -212,6 +236,57 @@ ruleTester.run('jsx-indent', rule, {
212236 errors : [
213237 { message : 'Expected indentation of 3 tab characters but found 2.' }
214238 ]
215- } ]
239+ } , {
240+ code : [
241+ '<App>\n' ,
242+ '<Foo />\n' ,
243+ '</App>'
244+ ] . join ( '\n' ) ,
245+ output : [
246+ '<App>\n' ,
247+ '\t<Foo />\n' ,
248+ '</App>'
249+ ] . join ( '\n' ) ,
250+ parserOptions : parserOptions ,
251+ options : [ 'tab' ] ,
252+ errors : [
253+ { message : 'Expected indentation of 1 tab character but found 0.' }
254+ ]
255+ }
256+ // Tests for future work. See the comment on line 42-43 in the rule near to fixable: 'whitespace' meta property,
257+ // Right now fixer function doesn't support replacing tabs with whitespaces and vice-versa.
258+ /* , {
259+ code: [
260+ '<App>\n',
261+ ' <Foo />\n',
262+ '</App>'
263+ ].join('\n'),
264+ output: [
265+ '<App>\n',
266+ '\t<Foo />\n',
267+ '</App>'
268+ ].join('\n'),
269+ parserOptions: parserOptions,
270+ options: ['tab'],
271+ errors: [
272+ {message: 'Expected indentation of 1 tab character but found 0.'}
273+ ]
274+ }, {
275+ code: [
276+ '<App>\n',
277+ '\t<Foo />\n',
278+ '</App>'
279+ ].join('\n'),
280+ output: [
281+ '<App>\n',
282+ ' <Foo />\n',
283+ '</App>'
284+ ].join('\n'),
285+ parserOptions: parserOptions,
286+ options: [2],
287+ errors: [
288+ {message: 'Expected indentation of 2 space characters but found 0.'}
289+ ]
290+ }*/ ]
216291} ) ;
217292
0 commit comments