✈️ migrate to static properies of ES7

proptypes should not be  capital
Add unit-test to check if separator has default value
This commit is contained in:
abdennour 2017-02-17 20:24:28 +03:00
commit c5053cf334
6 changed files with 28 additions and 15 deletions

View file

@ -163,7 +163,7 @@ import {CSVDownload} from 'react-csv';
For non-node developers, they have to use CDN version :
```html
<script src="https://cdn.rawgit.com/abdennour/react-csv/7918cadc/cdn/react-csv-latest.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/abdennour/react-csv/6424b500/cdn/react-csv-latest.min.js" type="text/javascript"></script>
<script type="text/babel">
const {CSVDownload, CSVLink} = ReactCSV;// or window.ReactCSV

View file

@ -13,7 +13,7 @@ class App extends React.Component {
render() {
return (
<div style={{padding: 10}}>
<h1>react-csv</h1>
<h3><code>react-csv/sample-site/src/app.jsx</code></h3>
<hr />
<div>

View file

@ -1,11 +1,20 @@
import React from 'react';
import {buildURI} from '../core';
import {defaultProps as CommonDefaultProps, PropTypes} from '../metaProps';
import {
defaultProps as commonDefaultProps,
propTypes as commonPropTypes} from '../metaProps';
const defaultProps = {
target: '_blank'
};
class CSVDownload extends React.Component {
static defaultProps = Object.assign(
commonDefaultProps,
defaultProps
);
static propTypes = commonPropTypes;
constructor(props) {
super(props);
this.state={};
@ -31,10 +40,4 @@ class CSVDownload extends React.Component {
}
}
CSVDownload.defaultProps = Object.assign(
CommonDefaultProps,
defaultProps
);
CSVDownload.PropTypes = PropTypes;
export default CSVDownload;

View file

@ -1,8 +1,14 @@
import React from 'react';
import {buildURI} from '../core';
import {defaultProps, PropTypes} from '../metaProps';
import {
defaultProps as commonDefaultProps,
propTypes as commonPropTypes} from '../metaProps';
class CSVLink extends React.Component {
static defaultProps = commonDefaultProps;
static propTypes = commonPropTypes;
constructor(props) {
super(props);
this.buildURI= this.buildURI.bind(this);
@ -22,7 +28,5 @@ class CSVLink extends React.Component {
)
}
}
CSVLink.defaultProps = defaultProps;
CSVLink.PropTypes = PropTypes;
export default CSVLink;

View file

@ -1,7 +1,7 @@
import React from 'react';
export const PropTypes = {
export const propTypes = {
data: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.array

View file

@ -34,10 +34,16 @@ describe('CSVLink', () => {
]
};
});
it(`renders without error if required props are passed`, () => {
const wrapper = shallow( <CSVLink {...minProps} > Click here </CSVLink>);
expect(wrapper.length).toEqual(1);
});
});
it(`has comma as default separator `, () => {
const wrapper = mount( <CSVLink {...minProps} > Click here </CSVLink>);
expect(wrapper.props().separator).toEqual(',');
})
it(`renders anchor tag`, () => {
const wrapper = shallow( <CSVLink {...minProps} > Click here </CSVLink>);