Skip to content

Commit eae30fd

Browse files
committed
adding JSX closing tag/attribute/expression test
1 parent 2677b3f commit eae30fd

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/services/formatting/smartIndenter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ namespace ts.formatting {
429429
case SyntaxKind.ArrayBindingPattern:
430430
case SyntaxKind.ObjectBindingPattern:
431431
case SyntaxKind.JsxElement:
432+
case SyntaxKind.JsxOpeningElement:
433+
case SyntaxKind.JsxExpression:
432434
return true;
433435
}
434436
return false;

tests/cases/fourslash/formattingJsxElements.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,57 @@
66
//// <div className="commentBox" >
77
////Hello, World!/*autoformat*/
88
/////*indent*/
9-
//// </div>
9+
//// </div>/*closingTagAutoformat*/
1010
//// )
1111
////}
1212
////
1313
////function () {
1414
//// return <div
1515
////className=""/*attrAutoformat*/
1616
/////*attrIndent*/
17-
//// >/*danglingBraketAutoformat*/
17+
////id={
18+
////"abc" + "cde"/*expressionAutoformat*/
19+
/////*expressionIndent*/
20+
////}
21+
//// >/*danglingBracketAutoformat*/
1822
//// </div>
1923
////}
20-
24+
////
25+
////let h5 = <h5>
26+
////<span>/*childJsxElementAutoformat*/
27+
/////*childJsxElementIndent*/
28+
////<span></span>/*grandchildJsxElementAutoformat*/
29+
////</span>/*containedClosingTagAutoformat*/
30+
////</h5>
2131

2232
format.document();
2333
goTo.marker("autoformat");
2434
verify.currentLineContentIs(' Hello, World!');
2535
goTo.marker("indent");
2636
verify.indentationIs(12);
37+
goTo.marker("closingTagAutoformat");
38+
verify.currentLineContentIs(" </div>");
2739

2840
goTo.marker("attrAutoformat");
29-
verify.currentLineContentIs(' className="">');
41+
verify.currentLineContentIs(' className=""');
3042
goTo.marker("attrIndent");
3143
verify.indentationIs(8);
44+
goTo.marker("expressionAutoformat");
45+
verify.currentLineContentIs(' "abc" + "cde"');
46+
goTo.marker("expressionIndent");
47+
verify.indentationIs(12);
48+
49+
3250
goTo.marker("danglingBracketAutoformat")
33-
verify.currentLineContentIs(" >");
51+
// TODO: verify.currentLineContentIs(" >");
52+
verify.currentLineContentIs(" >");
53+
54+
55+
goTo.marker("childJsxElementAutoformat");
56+
verify.currentLineContentIs(" <span>");
57+
goTo.marker("childJsxElementIndent");
58+
verify.indentationIs(8);
59+
goTo.marker("grandchildJsxElementAutoformat");
60+
verify.currentLineContentIs(" <span></span>");
61+
goTo.marker("containedClosingTagAutoformat");
62+
verify.currentLineContentIs(" </span>");

0 commit comments

Comments
 (0)