move all plugin tests out of babel-core and into their appropriate folders
This commit is contained in:
@@ -12,5 +12,8 @@
|
||||
"babel-runtime": "^5.0.0",
|
||||
"babel-helper-builder-react-jsx": "^6.0.14",
|
||||
"babel-plugin-syntax-jsx": "^6.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-helper-plugin-test-runner": "^6.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class App extends React.Component {
|
||||
render() {
|
||||
const navbarHeader = <div className="navbar-header">
|
||||
<a className="navbar-brand" href="/">
|
||||
<img src="/img/logo/logo-96x36.png" />
|
||||
</a>
|
||||
</div>;
|
||||
|
||||
return <div>
|
||||
<nav className="navbar navbar-default">
|
||||
<div className="container">
|
||||
{navbarHeader}
|
||||
</div>
|
||||
</nav>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
var _ref = React.createElement(
|
||||
"div",
|
||||
{ className: "navbar-header" },
|
||||
React.createElement(
|
||||
"a",
|
||||
{ className: "navbar-brand", href: "/" },
|
||||
React.createElement("img", { src: "/img/logo/logo-96x36.png" })
|
||||
)
|
||||
);
|
||||
|
||||
var App = (function (_React$Component) {
|
||||
babelHelpers.inherits(App, _React$Component);
|
||||
|
||||
function App() {
|
||||
babelHelpers.classCallCheck(this, App);
|
||||
babelHelpers.get(Object.getPrototypeOf(App.prototype), "constructor", this).apply(this, arguments);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(App, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var navbarHeader = _ref;
|
||||
|
||||
return React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(
|
||||
"nav",
|
||||
{ className: "navbar navbar-default" },
|
||||
React.createElement(
|
||||
"div",
|
||||
{ className: "container" },
|
||||
navbarHeader
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}]);
|
||||
return App;
|
||||
})(React.Component);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers-2", "transform-react-constant-elements", "transform-es2015-classes", "syntax-jsx"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<div> </div>;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement("div", null, "\u00A0 ");
|
||||
@@ -0,0 +1 @@
|
||||
<div> </div>;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement("div", null, "\u00A0");
|
||||
@@ -0,0 +1,13 @@
|
||||
var x = (
|
||||
<div>
|
||||
{/* A comment at the beginning */}
|
||||
{/* A second comment at the beginning */}
|
||||
<span>
|
||||
{/* A nested comment */}
|
||||
</span>
|
||||
{/* A sandwiched comment */}
|
||||
<br />
|
||||
{/* A comment at the end */}
|
||||
{/* A second comment at the end */}
|
||||
</div>
|
||||
);
|
||||
@@ -0,0 +1,11 @@
|
||||
var x = (React.createElement("div", null,
|
||||
/* A comment at the beginning */
|
||||
/* A second comment at the beginning */
|
||||
React.createElement("span", null
|
||||
/* A nested comment */
|
||||
),
|
||||
/* A sandwiched comment */
|
||||
React.createElement("br", null)
|
||||
/* A comment at the end */
|
||||
/* A second comment at the end */
|
||||
));
|
||||
@@ -0,0 +1,10 @@
|
||||
var x = (
|
||||
<div
|
||||
/* a multi-line
|
||||
comment */
|
||||
attr1="foo">
|
||||
<span // a double-slash comment
|
||||
attr2="bar"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
var x = (React.createElement("div", {
|
||||
/* a multi-line
|
||||
comment */
|
||||
attr1: "foo"},
|
||||
React.createElement("span", {// a double-slash comment
|
||||
attr2: "bar"}
|
||||
)
|
||||
));
|
||||
@@ -0,0 +1,3 @@
|
||||
<Component
|
||||
{...props}
|
||||
sound="moo" />
|
||||
@@ -0,0 +1,2 @@
|
||||
React.createElement(Component, babelHelpers._extends({}, props, {
|
||||
sound: "moo" }));
|
||||
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/arrow-functions/actual.js
vendored
Normal file
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/arrow-functions/actual.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
var foo = function () {
|
||||
return () => <this />;
|
||||
};
|
||||
|
||||
var bar = function () {
|
||||
return () => <this.foo />;
|
||||
};
|
||||
15
packages/babel-plugin-transform-react-jsx/test/fixtures/react/arrow-functions/expected.js
vendored
Normal file
15
packages/babel-plugin-transform-react-jsx/test/fixtures/react/arrow-functions/expected.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var foo = function () {
|
||||
var _this = this;
|
||||
|
||||
return function () {
|
||||
return React.createElement(_this, null);
|
||||
};
|
||||
};
|
||||
|
||||
var bar = function () {
|
||||
var _this2 = this;
|
||||
|
||||
return function () {
|
||||
return React.createElement(_this2.foo, null);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
var x =
|
||||
<div>
|
||||
foo
|
||||
{"bar"}
|
||||
baz
|
||||
<div>
|
||||
buz
|
||||
bang
|
||||
</div>
|
||||
qux
|
||||
{null}
|
||||
quack
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"buz bang"
|
||||
),
|
||||
"qux",
|
||||
null,
|
||||
"quack"
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
var Component;
|
||||
Component = React.createClass({
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
var Component;
|
||||
Component = React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
export default React.createClass({
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
export default React.createClass({
|
||||
displayName: "actual",
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
13
packages/babel-plugin-transform-react-jsx/test/fixtures/react/display-name-if-missing/actual.js
vendored
Normal file
13
packages/babel-plugin-transform-react-jsx/test/fixtures/react/display-name-if-missing/actual.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var Whateva = React.createClass({
|
||||
displayName: "Whatever",
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
var Bar = React.createClass({
|
||||
"displayName": "Ba",
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
var Whateva = React.createClass({
|
||||
displayName: "Whatever",
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
var Bar = React.createClass({
|
||||
"displayName": "Ba",
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
exports = {
|
||||
Component: React.createClass({
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
exports = {
|
||||
Component: React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
exports.Component = React.createClass({
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
exports.Component = React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
var Component = React.createClass({
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
var Component = React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
<Text>
|
||||
To get started, edit index.ios.js!!!{"\n"}
|
||||
Press Cmd+R to reload
|
||||
</Text>
|
||||
@@ -0,0 +1,7 @@
|
||||
React.createElement(
|
||||
Text,
|
||||
null,
|
||||
"To get started, edit index.ios.js!!!",
|
||||
"\n",
|
||||
"Press Cmd+R to reload"
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
/** @jsx dom */
|
||||
|
||||
<Foo></Foo>;
|
||||
|
||||
var profile = <div>
|
||||
<img src="avatar.png" className="profile" />
|
||||
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
|
||||
</div>;
|
||||
@@ -0,0 +1,14 @@
|
||||
/** @jsx dom */
|
||||
|
||||
dom(Foo, null);
|
||||
|
||||
var profile = dom(
|
||||
"div",
|
||||
null,
|
||||
dom("img", { src: "avatar.png", className: "profile" }),
|
||||
dom(
|
||||
"h3",
|
||||
null,
|
||||
[user.firstName, user.lastName].join(" ")
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [["transform-react-jsx", "foo.bar"]]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/** @jsx dom */
|
||||
|
||||
<Foo></Foo>;
|
||||
|
||||
var profile = <div>
|
||||
<img src="avatar.png" className="profile" />
|
||||
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
|
||||
</div>;
|
||||
@@ -0,0 +1,14 @@
|
||||
/** @jsx dom */
|
||||
|
||||
dom(Foo, null);
|
||||
|
||||
var profile = dom(
|
||||
"div",
|
||||
null,
|
||||
dom("img", { src: "avatar.png", className: "profile" }),
|
||||
dom(
|
||||
"h3",
|
||||
null,
|
||||
[user.firstName, user.lastName].join(" ")
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
<Foo></Foo>;
|
||||
|
||||
var profile = <div>
|
||||
<img src="avatar.png" className="profile" />
|
||||
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
|
||||
</div>;
|
||||
@@ -0,0 +1,12 @@
|
||||
dom(Foo, null);
|
||||
|
||||
var profile = dom(
|
||||
"div",
|
||||
null,
|
||||
dom("img", { src: "avatar.png", className: "profile" }),
|
||||
dom(
|
||||
"h3",
|
||||
null,
|
||||
[user.firstName, user.lastName].join(" ")
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [["transform-react-jsx", { "pragma": "dom" }]]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
var div = <div>test</div>;
|
||||
@@ -0,0 +1 @@
|
||||
var div = React.createElement("div", null, "test");
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"retainLines": true
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
var div = <div>test</div>;
|
||||
@@ -0,0 +1,5 @@
|
||||
var div = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"test"
|
||||
);
|
||||
3
packages/babel-plugin-transform-react-jsx/test/fixtures/react/options.json
vendored
Normal file
3
packages/babel-plugin-transform-react-jsx/test/fixtures/react/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers-2", "syntax-jsx", "transform-react-jsx", "transform-react-display-name", "transform-es2015-arrow-functions"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<Component constructor="foo" />;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement(Component, { constructor: "foo" });
|
||||
@@ -0,0 +1 @@
|
||||
<Namespace.DeepNamespace.Component />;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement(Namespace.DeepNamespace.Component, null);
|
||||
@@ -0,0 +1 @@
|
||||
<Namespace.Component />;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement(Namespace.Component, null);
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement(Namespace.Component, null);
|
||||
@@ -0,0 +1,15 @@
|
||||
var x = <div>
|
||||
<Component />
|
||||
</div>;
|
||||
|
||||
var x = <div>
|
||||
{props.children}
|
||||
</div>;
|
||||
|
||||
var x = <Composite>
|
||||
{props.children}
|
||||
</Composite>;
|
||||
|
||||
var x = <Composite>
|
||||
<Composite2 />
|
||||
</Composite>;
|
||||
@@ -0,0 +1,23 @@
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(Component, null)
|
||||
);
|
||||
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
props.children
|
||||
);
|
||||
|
||||
var x = React.createElement(
|
||||
Composite,
|
||||
null,
|
||||
props.children
|
||||
);
|
||||
|
||||
var x = React.createElement(
|
||||
Composite,
|
||||
null,
|
||||
React.createElement(Composite2, null)
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
var x = <div></div>;
|
||||
@@ -0,0 +1 @@
|
||||
var x = React.createElement("div", null);
|
||||
@@ -0,0 +1 @@
|
||||
var x = <div>text</div>;
|
||||
@@ -0,0 +1,5 @@
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"text"
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
<Namespace:Component />;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Namespace tags are not supported. ReactJSX is not XML."
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
var HelloMessage = React.createClass({
|
||||
render: function() {
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
}
|
||||
});
|
||||
|
||||
React.render(<HelloMessage name={
|
||||
<span>
|
||||
Sebastian
|
||||
</span>
|
||||
} />, mountNode);
|
||||
@@ -0,0 +1,18 @@
|
||||
var HelloMessage = React.createClass({
|
||||
displayName: "HelloMessage",
|
||||
|
||||
render: function () {
|
||||
return React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"Hello ",
|
||||
this.props.name
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
React.render(React.createElement(HelloMessage, { name: React.createElement(
|
||||
"span",
|
||||
null,
|
||||
"Sebastian"
|
||||
) }), mountNode);
|
||||
@@ -0,0 +1 @@
|
||||
<hasOwnProperty>testing</hasOwnProperty>;
|
||||
@@ -0,0 +1,5 @@
|
||||
React.createElement(
|
||||
"hasOwnProperty",
|
||||
null,
|
||||
"testing"
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
var x = <div>
|
||||
<div><br /></div>
|
||||
<Component>{foo}<br />{bar}</Component>
|
||||
<br />
|
||||
</div>;
|
||||
@@ -0,0 +1,17 @@
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement("br", null)
|
||||
),
|
||||
React.createElement(
|
||||
Component,
|
||||
null,
|
||||
foo,
|
||||
React.createElement("br", null),
|
||||
bar
|
||||
),
|
||||
React.createElement("br", null)
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
var x =
|
||||
<div
|
||||
attr1={
|
||||
"foo" + "bar"
|
||||
}
|
||||
attr2={
|
||||
"foo" + "bar" +
|
||||
|
||||
"baz" + "bug"
|
||||
}
|
||||
attr3={
|
||||
"foo" + "bar" +
|
||||
"baz" + "bug"
|
||||
}
|
||||
attr4="baz">
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
var x = React.createElement("div", {
|
||||
attr1: "foo" + "bar",
|
||||
attr2: "foo" + "bar" + "baz" + "bug",
|
||||
attr3: "foo" + "bar" + "baz" + "bug",
|
||||
attr4: "baz" });
|
||||
@@ -0,0 +1 @@
|
||||
<button data-value='a value'>Button</button>;
|
||||
@@ -0,0 +1,5 @@
|
||||
React.createElement(
|
||||
'button',
|
||||
{ 'data-value': 'a value' },
|
||||
'Button'
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
<font-face />;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement("font-face", null);
|
||||
@@ -0,0 +1,2 @@
|
||||
<Component { ... x } y
|
||||
={2 } z />
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement(Component, babelHelpers._extends({}, x, { y: 2, z: true }));
|
||||
@@ -0,0 +1 @@
|
||||
<Component y={2} z { ... x } />
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement(Component, babelHelpers._extends({ y: 2, z: true }, x));
|
||||
@@ -0,0 +1 @@
|
||||
<Component y={2} { ... x } z />
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement(Component, babelHelpers._extends({ y: 2 }, x, { z: true }));
|
||||
1
packages/babel-plugin-transform-react-jsx/test/index.js
Normal file
1
packages/babel-plugin-transform-react-jsx/test/index.js
Normal file
@@ -0,0 +1 @@
|
||||
require("babel-helper-plugin-test-runner")(__dirname);
|
||||
Reference in New Issue
Block a user