diff --git a/test/jsx.ts b/test/jsx.ts index 37f9d9ae..87895f87 100644 --- a/test/jsx.ts +++ b/test/jsx.ts @@ -93,3 +93,35 @@ it("should not remove trailing whitespaces", function () { "}", ); }); + +it("should not double parentheses in Babel", function () { + const printer = new Printer({ tabWidth: 2 }); + const source = + "function App() {\n" + + ' const name = "world";\n' + + "\n" + + " return (\n" + + '
\n' + + " hello {name}\n" + + "
\n" + + " );\n" + + "}"; + + const ast = parse(source, {parser: require("../parsers/babel")}); + ast.program.body[0].body.body[1].argument.openingElement.attributes[0].name.name = + "abc"; + + const code = printer.printGenerically(ast).code; + + assert.equal( + code, + "function App() {\n" + + ' const name = "world";\n' + + "\n" + + " return (\n" + + '
hello {name}\n' + + "
\n" + + " );\n" + + "}", + ); +});