From 6889ab7a9ccf68dbb9bcb57f47e88527ac653555 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 17 Jun 2024 20:04:21 +0200 Subject: [PATCH] adds test to validate --- test/jsx.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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" + + "}", + ); +});