✈️ 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:
parent
33fdb393c7
commit
c5053cf334
6 changed files with 28 additions and 15 deletions
|
|
@ -163,7 +163,7 @@ import {CSVDownload} from 'react-csv';
|
||||||
For non-node developers, they have to use CDN version :
|
For non-node developers, they have to use CDN version :
|
||||||
|
|
||||||
```html
|
```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">
|
<script type="text/babel">
|
||||||
const {CSVDownload, CSVLink} = ReactCSV;// or window.ReactCSV
|
const {CSVDownload, CSVLink} = ReactCSV;// or window.ReactCSV
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class App extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div style={{padding: 10}}>
|
<div style={{padding: 10}}>
|
||||||
<h1>react-csv</h1>
|
<h3><code>react-csv/sample-site/src/app.jsx</code></h3>
|
||||||
<hr />
|
<hr />
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,20 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {buildURI} from '../core';
|
import {buildURI} from '../core';
|
||||||
import {defaultProps as CommonDefaultProps, PropTypes} from '../metaProps';
|
import {
|
||||||
|
defaultProps as commonDefaultProps,
|
||||||
|
propTypes as commonPropTypes} from '../metaProps';
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
};
|
};
|
||||||
class CSVDownload extends React.Component {
|
class CSVDownload extends React.Component {
|
||||||
|
|
||||||
|
static defaultProps = Object.assign(
|
||||||
|
commonDefaultProps,
|
||||||
|
defaultProps
|
||||||
|
);
|
||||||
|
|
||||||
|
static propTypes = commonPropTypes;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state={};
|
this.state={};
|
||||||
|
|
@ -31,10 +40,4 @@ class CSVDownload extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVDownload.defaultProps = Object.assign(
|
|
||||||
CommonDefaultProps,
|
|
||||||
defaultProps
|
|
||||||
);
|
|
||||||
CSVDownload.PropTypes = PropTypes;
|
|
||||||
|
|
||||||
export default CSVDownload;
|
export default CSVDownload;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {buildURI} from '../core';
|
import {buildURI} from '../core';
|
||||||
import {defaultProps, PropTypes} from '../metaProps';
|
import {
|
||||||
|
defaultProps as commonDefaultProps,
|
||||||
|
propTypes as commonPropTypes} from '../metaProps';
|
||||||
|
|
||||||
class CSVLink extends React.Component {
|
class CSVLink extends React.Component {
|
||||||
|
|
||||||
|
static defaultProps = commonDefaultProps;
|
||||||
|
static propTypes = commonPropTypes;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.buildURI= this.buildURI.bind(this);
|
this.buildURI= this.buildURI.bind(this);
|
||||||
|
|
@ -22,7 +28,5 @@ class CSVLink extends React.Component {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CSVLink.defaultProps = defaultProps;
|
|
||||||
CSVLink.PropTypes = PropTypes;
|
|
||||||
|
|
||||||
export default CSVLink;
|
export default CSVLink;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
|
||||||
export const PropTypes = {
|
export const propTypes = {
|
||||||
data: React.PropTypes.oneOfType([
|
data: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.string,
|
React.PropTypes.string,
|
||||||
React.PropTypes.array
|
React.PropTypes.array
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,16 @@ describe('CSVLink', () => {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`renders without error if required props are passed`, () => {
|
it(`renders without error if required props are passed`, () => {
|
||||||
const wrapper = shallow( <CSVLink {...minProps} > Click here </CSVLink>);
|
const wrapper = shallow( <CSVLink {...minProps} > Click here </CSVLink>);
|
||||||
expect(wrapper.length).toEqual(1);
|
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`, () => {
|
it(`renders anchor tag`, () => {
|
||||||
const wrapper = shallow( <CSVLink {...minProps} > Click here </CSVLink>);
|
const wrapper = shallow( <CSVLink {...minProps} > Click here </CSVLink>);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue