Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Commit

Permalink
Stateless Components: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdustan committed Oct 6, 2015
1 parent e173e2e commit eb8d1bf
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/fixtures/modern/stateless/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"plugins": ["../../../src"],
"extra": {
"react-transform": {
"transforms": [
{
"transform": "my-custom-module/wrap",
"locals": ["module"],
"imports": ["react"]
},
{
"transform": "my-other-custom-module/wrap"
}
]
}
}
}
18 changes: 18 additions & 0 deletions test/fixtures/stateless/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"plugins": ["../../../src"],
"extra": {
"react-transform": {
"transforms": [
{
"transform": "my-custom-module/wrap",
"locals": ["module"],
"imports": ["react"]
},
{
"transform": "my-other-custom-module/wrap"
}
]
}
}
}

22 changes: 22 additions & 0 deletions test/fixtures/stateless/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function NotComponent() {}

var StillNotAComponent = function() {};

let SimpleComponent = props => {
arbitraryComputation();

return <div />
};

let Something = (Math.random() > .5) ?
props => <div /> :
props => <span />;

function factory() {
const ComponentInsideFunction = (props) => (
<div />
)

return props => <div />;
}

84 changes: 84 additions & 0 deletions test/fixtures/stateless/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"use strict";

var _myCustomModuleWrap2 = require("my-custom-module/wrap");

var _myCustomModuleWrap3 = _interopRequireDefault(_myCustomModuleWrap2);

var _react = require("react");

var _myOtherCustomModuleWrap2 = require("my-other-custom-module/wrap");

var _myOtherCustomModuleWrap3 = _interopRequireDefault(_myOtherCustomModuleWrap2);

var _components = {
_$SimpleComponent: {
displayName: "SimpleComponent",
isInFunction: true
},
_$Unknown: {
isInFunction: true
},
_$Unknown2: {
isInFunction: true
},
_$ComponentInsideFunction: {
displayName: "ComponentInsideFunction",
isInFunction: true
},
_$Unknown3: {
isInFunction: true
},
_$factory: {
displayName: "factory",
isInFunction: true
}
};

var _reactComponentWrapper = (0, _myCustomModuleWrap3["default"])({
filename: "/Users/dkasten/projects/oss/babel-plugin-react-transform/test/fixtures/stateless/actual.js",
components: _components,
locals: [module],
imports: [_react]
});

var _reactComponentWrapper2 = (0, _myOtherCustomModuleWrap3["default"])({
filename: "/Users/dkasten/projects/oss/babel-plugin-react-transform/test/fixtures/stateless/actual.js",
components: _components,
locals: [],
imports: []
});

function _wrapComponent(uniqueId) {
return function (ReactClass) {
return _reactComponentWrapper2(_reactComponentWrapper(ReactClass, uniqueId), uniqueId);
};
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function NotComponent() {}

var StillNotAComponent = function StillNotAComponent() {};

var SimpleComponent = _wrapComponent("_$SimpleComponent")(function (props) {
arbitraryComputation();

return React.createElement("div", null);
});

var Something = Math.random() > .5 ? _wrapComponent("_$Unknown")(function (props) {
return React.createElement("div", null);
}) : _wrapComponent("_$Unknown2")(function (props) {
return React.createElement("span", null);
});

_wrapComponent("_$factory")(function factory() {
var ComponentInsideFunction = _wrapComponent("_$ComponentInsideFunction")(function (props) {
return React.createElement("div", null);
});

return _wrapComponent("_$Unknown3")(function (props) {
return React.createElement("div", null);
});
});

0 comments on commit eb8d1bf

Please sign in to comment.