Merge pull request babel/babel-eslint#101 from hzoo/more-jsx

add JSXText type, more tests
This commit is contained in:
Henry Zhu 2015-05-16 23:22:53 -04:00
parent 54adf244dd
commit 82f3fe4147
2 changed files with 18 additions and 0 deletions

View File

@ -34,6 +34,8 @@ exports.toToken = function (token) {
token.value = ">";
} else if (type === tt.jsxName) {
token.type = "JSXIdentifier";
} else if (type === tt.jsxText) {
token.type = "JSXText";
} else if (type.keyword === "null") {
token.type = "Null";
} else if (type.keyword === "false" || type.keyword === "true") {

View File

@ -154,6 +154,22 @@ describe("acorn-to-esprima", function () {
parseAndAssertSame("<foo.bar />");
});
it("jsx expression with spread", function () {
parseAndAssertSame("var myDivElement = <div {...this.props} />;");
});
it("empty jsx text", function () {
parseAndAssertSame("<a></a>");
});
it("jsx text with content", function () {
parseAndAssertSame("<a>Hello, world!</a>");
});
it("nested jsx", function () {
parseAndAssertSame("<div>\n<h1>Wat</h1>\n</div>");
});
it("default import", function () {
parseAndAssertSame('import foo from "foo";');
});