Skip to content

Commit

Permalink
adds test to validate
Browse files Browse the repository at this point in the history
  • Loading branch information
tim committed Jun 17, 2024
1 parent dd15e29 commit 6889ab7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
' <div className="app">\n' +
" hello {name}\n" +
" </div>\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" +
' <div abc="app">hello {name}\n' +
" </div>\n" +
" );\n" +
"}",
);
});

0 comments on commit 6889ab7

Please sign in to comment.