Skip to content

Commit

Permalink
Test 'create-react-class' with fixtures
Browse files Browse the repository at this point in the history
NOTE: Never going to merge this commit, but I may cherry-pick it onto
branches in order to test fixes for issue facebook#9765

In this case I will clean it up afterwards.

**what is the change?:**
Require and use the UMD bundles of 'create-react-class' in three
fixtures to test the three supported uses;
 - test Global JS with globals.html
 - test AMD with requirejs.html
 - test CommonJS with webpack-alias

**why make this change?:**
To test facebook#9761 and other PRs fixing facebook#9765

**test plan:**
Manual testing;
 - cd into the directory in fixtures
 - run the build step if needed
 - open the file

**issue:**
facebook#9765
  • Loading branch information
flarnie committed Jun 10, 2017
1 parent 1c303da commit 254c4cb
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 45 deletions.
6 changes: 5 additions & 1 deletion addons/create-react-class/create-react-class.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
(function(f) {
console.log('here in addons');
if (typeof exports === "object" && typeof module !== "undefined") {
console.log('successfully tested Common JS');
module.exports = f();
} else if (typeof define === "function" && define.amd) {
console.log('successfully tested AMD');
define(['react'], f);
} else {
console.log('successfully tested globals');
var g;
if (typeof window !== "undefined") {
g = window;
Expand Down Expand Up @@ -781,7 +785,7 @@ module.exports = factory(
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*
*/

function makeEmptyFunction(arg) {
Expand Down
28 changes: 18 additions & 10 deletions fixtures/globals.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<body>
<script src="../build/react-with-addons.js"></script>
<script src="../build/react-dom.js"></script>
<script src="../addons/create-react-class/create-react-class.js"></script>
<style>
.example-appear {
opacity: 0.01;
Expand All @@ -15,18 +16,25 @@
<div id="container"></div>
<script>
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
var Greeting = createReactClass({
render: function() {
return React.createElement('H1', null, 'Hello' + this.props.name + '!!!!!');
}
});
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
React.createElement(
CSSTransitionGroup,
{
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
},
React.createElement(Greeting, {name: 'FOO'}),
),
document.getElementById('container')
);
</script>
</body>
</html>
</html>
47 changes: 31 additions & 16 deletions fixtures/requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,40 @@
requirejs.config({
paths: {
react: '../build/react-with-addons',
'react-dom': '../build/react-dom'
'react-dom': '../build/react-dom',
'create-react-class':
'../addons/create-react-class/create-react-class'
}
});

require(['react', 'react-dom'], function(React, ReactDOM) {
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
require(
['react', 'react-dom', 'create-react-class'],
function(
React,
ReactDOM,
createReactClass
) {
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
var Greeting = createReactClass({
render: function() {
return React.createElement('H1', null, 'Hello' + this.props.name + '!!!!!');
}
});
ReactDOM.render(
React.createElement(
CSSTransitionGroup,
{
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
},
React.createElement(Greeting, {name: 'FOO'}),
),
document.getElementById('container')
);
});
</script>
</body>
</html>
</html>
1 change: 1 addition & 0 deletions fixtures/webpack-alias/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
alias: {
'react': 'react/dist/react-with-addons',
'react-dom': 'react-dom/dist/react-dom',
'create-react-class': 'create-react-class/create-react-class',
},
},
};
27 changes: 18 additions & 9 deletions fixtures/webpack-alias/input.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
var React = require('react');
var ReactDOM = require('react-dom');
var createReactClass = require('create-react-class');

var Greeting = createReactClass({
render: function() {
return React.createElement('H1', null, 'Hello' + this.props.name + '!!!!!');
}
});

var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
React.createElement(
CSSTransitionGroup,
{
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0
},
React.createElement(Greeting, {name: 'FOO'})
),
document.getElementById('container')
);
27 changes: 18 additions & 9 deletions fixtures/webpack/input.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
var React = require('react');
var CSSTransitionGroup = require('react-addons-css-transition-group');
var ReactDOM = require('react-dom');
var createReactClass = require('create-react-class');

var Greeting = createReactClass({
render: function() {
return React.createElement('H1', null, 'Hello' + this.props.name + '!!!!!');
}
});

ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
React.createElement(
CSSTransitionGroup,
{
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0
},
React.createElement(Greeting, {name: 'FOO'})
),
document.getElementById('container')
);

0 comments on commit 254c4cb

Please sign in to comment.