Skip to content

Commit

Permalink
add test in #48
Browse files Browse the repository at this point in the history
  • Loading branch information
danielduan committed Jun 17, 2018
1 parent d87efe4 commit caee408
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/fixtures/hoc-function/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { mapStateToProps, mapDispatchToProps } from './testSelector';

const TestComponent = (props) => {
const { text, onClick } = props;

return (
<div>
<div>Text: {text}</div>
<button onClick={onClick}>Button</button>
</div>
);
};

TestComponent.propTypes = {
/** Text to display */
text: PropTypes.string,
/** Called on click */
onClick: PropTypes.func
};

export default connect(mapStateToProps, mapDispatchToProps)(TestComponent);
78 changes: 78 additions & 0 deletions test/fixtures/hoc-function/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactRedux = require('react-redux');

var _testSelector = require('./testSelector');

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

var TestComponent = function TestComponent(props) {
var text = props.text,
onClick = props.onClick;


return _react2.default.createElement(
'div',
null,
_react2.default.createElement(
'div',
null,
'Text: ',
text
),
_react2.default.createElement(
'button',
{ onClick: onClick },
'Button'
)
);
};

TestComponent.propTypes = {
/** Text to display */
text: _propTypes2.default.string,
/** Called on click */
onClick: _propTypes2.default.func
};

exports.default = (0, _reactRedux.connect)(_testSelector.mapStateToProps, _testSelector.mapDispatchToProps)(TestComponent);
TestComponent.__docgenInfo = {
'description': '',
'methods': [],
'props': {
'text': {
'type': {
'name': 'string'
},
'required': false,
'description': 'Text to display'
},
'onClick': {
'type': {
'name': 'func'
},
'required': false,
'description': 'Called on click'
}
}
};

if (typeof STORYBOOK_REACT_CLASSES !== 'undefined') {
STORYBOOK_REACT_CLASSES['test/fixtures/hoc-function/actual.js'] = {
name: 'TestComponent',
docgenInfo: TestComponent.__docgenInfo,
path: 'test/fixtures/hoc-function/actual.js'
};
}

0 comments on commit caee408

Please sign in to comment.