Skip to content

Commit

Permalink
tests: Add TSX tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PartMan7 committed May 2, 2024
1 parent dd8cea4 commit ec2d873
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ import "./printer";
import "./syntax";
import "./flow";
import "./typescript";
import "./tsx";
import "./visit";
23 changes: 23 additions & 0 deletions test/tsx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

const nodeMajorVersion = parseInt(process.versions.node, 10);
import * as parser from "../parsers/babel-ts";
import { EOL as eol } from "os";
import * as recast from "../main";
import assert from "assert";

(nodeMajorVersion >= 6 ? describe : xdescribe)(
"Babel TSX Compatibility",
function () {
function check(lines: string[]) {
const code = lines.join(eol);
const ast = recast.parse(code, { parser });
const output = recast.prettyPrint(ast, { tabWidth: 2 }).code;
assert.strictEqual(code, output);
}

it("should parse and print typed JSX elements", function () {
check(["<Foo<Bar> />;"]);
});
},
);

0 comments on commit ec2d873

Please sign in to comment.