TypeScript/tests/cases/fourslash/formattingJsxElements.ts

179 lines
5.4 KiB
TypeScript
Raw Normal View History

2015-08-16 10:27:23 +02:00
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
////function foo0() {
2015-08-16 10:27:23 +02:00
//// return (
//// <div className="commentBox" >
////Hello, World!/*autoformat*/
/////*indent*/
//// </div>
//// )
////}
////
////function foo1() {
//// return (
//// <div className="commentBox" data-id="test">
////Hello, World!/*autoformat1*/
/////*indent1*/
//// </div>
2015-08-16 10:27:23 +02:00
//// )
////}
////
////function foo2() {
//// return (
//// <div data-name="commentBox"
////class1= {/*1*/
////}>/*2*/
////Hello, World!/*autoformat2*/
/////*indent2*/
//// </div>
//// )
////}
////function foo3() {
//// return (
//// <jsx-element className="commentBox"
//// class2= {/*3*/
//// }>/*4*/
//// Hello, World!/*autoformat3*/
//// /*indent3*/
//// </jsx-element>
//// )
////}
////function foo4() {
//// return (
//// <jsx-element className="commentBox"
//// class3= {/*5*/
//// }/>/*6*/
//// )
////}
////
2017-12-28 01:56:03 +01:00
////const bar = (
//// <>
//// /*fragmentChildIndent*/<p>text</p>
//// </>
////);
////
////const bar2 = <>
//// <p>text</p>
//// /*fragmentClosingTagIndent*/</>;
////
2015-09-09 17:48:53 +02:00
////(function () {
//// return <div
////className=""/*attrAutoformat*/
/////*attrIndent*/
////id={
////"abc" + "cde"/*expressionAutoformat*/
/////*expressionIndent*/
////}
//// >/*danglingBracketAutoformat*/
2015-09-09 17:48:53 +02:00
//// </div>/*closingTagAutoformat*/
////})
////
////let h5 = <h5>
////<span>/*childJsxElementAutoformat*/
/////*childJsxElementIndent*/
////<span></span>/*grandchildJsxElementAutoformat*/
////</span>/*containedClosingTagAutoformat*/
////</h5>;
////
2016-06-26 08:17:05 +02:00
////<div>,{integer}</div>;/*commaInJsxElement*/
////<div>, {integer}</div>;/*commaInJsxElement2*/
2017-12-28 01:56:03 +01:00
////<>,{integer}</>;/*commaInJsxFragment*/
////<>, {integer}</>;/*commaInJsxFragment2*/
////<span>)</span>;/*closingParenInJsxElement*/
////<span>) </span>;/*closingParenInJsxElement2*/
2017-12-28 01:56:03 +01:00
////<>)</>;/*closingParenInJsxFragment*/
////<>) </>;/*closingParenInJsxFragment2*/
2016-07-31 17:35:34 +02:00
////<Router routes = { 3 } / >;/*jsxExpressionSpaces*/
2016-06-26 08:17:05 +02:00
////<Router routes={ (3) } />;/*jsxExpressionSpaces2*/
////<Router routes={() => {}}/*jsxExpressionSpaces3*/
/////>;/*jsxDanglingSelfClosingToken*/
2015-08-16 10:27:23 +02:00
format.document();
goTo.marker("autoformat");
verify.currentLineContentIs(' Hello, World!');
goTo.marker("indent");
verify.indentationIs(12);
goTo.marker("autoformat1");
verify.currentLineContentIs(' Hello, World!');
goTo.marker("indent1");
verify.indentationIs(12);
goTo.marker("1");
2016-07-31 17:35:34 +02:00
verify.currentLineContentIs(' class1={');
goTo.marker("2");
verify.currentLineContentIs(' }>');
goTo.marker("autoformat2");
verify.currentLineContentIs(' Hello, World!');
goTo.marker("indent2");
verify.indentationIs(12);
goTo.marker("3");
2016-07-31 17:35:34 +02:00
verify.currentLineContentIs(' class2={');
goTo.marker("4");
verify.currentLineContentIs(' }>');
goTo.marker("autoformat3");
verify.currentLineContentIs(' Hello, World!');
goTo.marker("indent3");
verify.indentationIs(12);
goTo.marker("5");
2016-07-31 17:35:34 +02:00
verify.currentLineContentIs(' class3={');
goTo.marker("6");
2016-07-31 17:35:34 +02:00
verify.currentLineContentIs(' } />');
2015-09-09 17:48:53 +02:00
2017-12-28 01:56:03 +01:00
goTo.marker("fragmentChildIndent");
verify.currentLineContentIs(" <p>text</p>");
goTo.marker("fragmentClosingTagIndent");
verify.currentLineContentIs("</>;");
goTo.marker("attrAutoformat");
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(" >");
2015-09-09 17:48:53 +02:00
goTo.marker("closingTagAutoformat");
verify.currentLineContentIs(" </div>");
goTo.marker("childJsxElementAutoformat");
verify.currentLineContentIs(" <span>");
goTo.marker("childJsxElementIndent");
verify.indentationIs(8);
goTo.marker("grandchildJsxElementAutoformat");
verify.currentLineContentIs(" <span></span>");
goTo.marker("containedClosingTagAutoformat");
verify.currentLineContentIs(" </span>");
goTo.marker("commaInJsxElement");
verify.currentLineContentIs("<div>,{integer}</div>;");
goTo.marker("commaInJsxElement2");
verify.currentLineContentIs("<div>, {integer}</div>;");
2017-12-28 01:56:03 +01:00
goTo.marker("commaInJsxFragment");
verify.currentLineContentIs("<>,{integer}</>;");
goTo.marker("commaInJsxFragment2");
verify.currentLineContentIs("<>, {integer}</>;");
goTo.marker("closingParenInJsxElement");
verify.currentLineContentIs("<span>)</span>;");
goTo.marker("closingParenInJsxElement2");
2016-06-26 08:17:05 +02:00
verify.currentLineContentIs("<span>) </span>;");
2017-12-28 01:56:03 +01:00
goTo.marker("closingParenInJsxFragment");
verify.currentLineContentIs("<>)</>;");
goTo.marker("closingParenInJsxFragment2");
verify.currentLineContentIs("<>) </>;");
2016-06-26 08:17:05 +02:00
goTo.marker("jsxExpressionSpaces");
verify.currentLineContentIs("<Router routes={3} />;");
goTo.marker("jsxExpressionSpaces2");
verify.currentLineContentIs("<Router routes={(3)} />;");
goTo.marker("jsxExpressionSpaces3");
verify.currentLineContentIs("<Router routes={() => { }}");
goTo.marker("jsxDanglingSelfClosingToken");
verify.currentLineContentIs("/>;");