From eae30fd3de440dda52843b48f0929b24cf9a2651 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Sat, 22 Aug 2015 03:39:15 +0900 Subject: [PATCH] adding JSX closing tag/attribute/expression test --- src/services/formatting/smartIndenter.ts | 2 + .../cases/fourslash/formattingJsxElements.ts | 39 ++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index c7f762fea64..30211e0a910 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -429,6 +429,8 @@ namespace ts.formatting { case SyntaxKind.ArrayBindingPattern: case SyntaxKind.ObjectBindingPattern: case SyntaxKind.JsxElement: + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxExpression: return true; } return false; diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts index 3219fb396b9..3b98e7b5ca4 100644 --- a/tests/cases/fourslash/formattingJsxElements.ts +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -6,7 +6,7 @@ ////
////Hello, World!/*autoformat*/ /////*indent*/ -////
+//// /*closingTagAutoformat*/ //// ) ////} //// @@ -14,20 +14,49 @@ //// return
/*danglingBraketAutoformat*/ +////id={ +////"abc" + "cde"/*expressionAutoformat*/ +/////*expressionIndent*/ +////} +//// >/*danglingBracketAutoformat*/ ////
////} - +//// +////let h5 =
+/////*childJsxElementAutoformat*/ +/////*childJsxElementIndent*/ +/////*grandchildJsxElementAutoformat*/ +/////*containedClosingTagAutoformat*/ +////
format.document(); goTo.marker("autoformat"); verify.currentLineContentIs(' Hello, World!'); goTo.marker("indent"); verify.indentationIs(12); +goTo.marker("closingTagAutoformat"); +verify.currentLineContentIs(" "); goTo.marker("attrAutoformat"); -verify.currentLineContentIs(' className="">'); +verify.currentLineContentIs(' className=""'); goTo.marker("attrIndent"); verify.indentationIs(8); +goTo.marker("expressionAutoformat"); +verify.currentLineContentIs(' "abc" + "cde"'); +goTo.marker("expressionIndent"); +verify.indentationIs(12); + + goTo.marker("danglingBracketAutoformat") -verify.currentLineContentIs(" >"); \ No newline at end of file +// TODO: verify.currentLineContentIs(" >"); +verify.currentLineContentIs(" >"); + + +goTo.marker("childJsxElementAutoformat"); +verify.currentLineContentIs(" "); +goTo.marker("childJsxElementIndent"); +verify.indentationIs(8); +goTo.marker("grandchildJsxElementAutoformat"); +verify.currentLineContentIs(" "); +goTo.marker("containedClosingTagAutoformat"); +verify.currentLineContentIs(" "); \ No newline at end of file