tests: Add TSX tests
This commit is contained in:
parent
dd8cea468e
commit
ec2d873c6a
2 changed files with 24 additions and 0 deletions
|
|
@ -14,4 +14,5 @@ import "./printer";
|
|||
import "./syntax";
|
||||
import "./flow";
|
||||
import "./typescript";
|
||||
import "./tsx";
|
||||
import "./visit";
|
||||
|
|
|
|||
23
test/tsx.ts
Normal file
23
test/tsx.ts
Normal 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> />;"]);
|
||||
});
|
||||
},
|
||||
);
|
||||
Loading…
Reference in a new issue