tests: Add TSX tests

This commit is contained in:
Parth Mane 2024-05-02 17:44:10 +05:30
parent dd8cea468e
commit ec2d873c6a
2 changed files with 24 additions and 0 deletions

View file

@ -14,4 +14,5 @@ import "./printer";
import "./syntax";
import "./flow";
import "./typescript";
import "./tsx";
import "./visit";

23
test/tsx.ts Normal file
View file

@ -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> />;"]);
});
},
);