Skip to content

Commit

Permalink
npm prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentinas Bartusevičius committed Jan 24, 2020
1 parent 12c08a5 commit 408aac9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 38 deletions.
10 changes: 1 addition & 9 deletions src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1345,15 +1345,7 @@ class MUIDataTable extends React.Component {
classes,
className,
title,
components: {
TableBody,
TableFilterList,
TableFooter,
TableHead,
TableResize,
TableToolbar,
TableToolbarSelect,
}
components: { TableBody, TableFilterList, TableFooter, TableHead, TableResize, TableToolbar, TableToolbarSelect },
} = this.props;
const {
announceText,
Expand Down
28 changes: 9 additions & 19 deletions src/components/TableFilterListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,17 @@ import PropTypes from 'prop-types';
import React from 'react';

class TableFilterListItem extends React.PureComponent {
static propTypes = {
label: PropTypes.node,
onDelete: PropTypes.func.isRequired,
className: PropTypes.string.isRequired,
};
static propTypes = {
label: PropTypes.node,
onDelete: PropTypes.func.isRequired,
className: PropTypes.string.isRequired,
};

render() {
const {
label,
onDelete,
className,
} = this.props;
render() {
const { label, onDelete, className } = this.props;

return (
<Chip
label={label}
onDelete={onDelete}
className={className}
/>
);
}
return <Chip label={label} onDelete={onDelete} className={className} />;
}
}

export default TableFilterListItem;
25 changes: 15 additions & 10 deletions test/MUIDataTableCustomComponents.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import MUIDataTable from '../src/MUIDataTable';
import Chip from '@material-ui/core/Chip';
import TableFilterList from '../src/components/TableFilterList';

const CustomChip = (props) => {
const CustomChip = props => {
return <Chip variant="outlined" color="secondary" label={props.label} />;
};

const CustomFilterList = (props) => {
const CustomFilterList = props => {
return <TableFilterList {...props} ItemComponent={CustomChip} />;
};

Expand Down Expand Up @@ -42,16 +42,21 @@ describe('<MUIDataTable /> with custom components', function() {

it('should render a table with custom Chip in TableFilterList', () => {
const shallowWrapper = shallow(
<MUIDataTable
columns={columns}
data={data}
components={{
TableFilterList: CustomFilterList,
}}
/>);
<MUIDataTable
columns={columns}
data={data}
components={{
TableFilterList: CustomFilterList,
}}
/>,
);
const customFilterList = shallowWrapper.dive().find(CustomFilterList);
assert.lengthOf(customFilterList, 1);
const customChip = customFilterList.dive().dive().dive().find(CustomChip);
const customChip = customFilterList
.dive()
.dive()
.dive()
.find(CustomChip);
assert.lengthOf(customChip, 1);
});
});

0 comments on commit 408aac9

Please sign in to comment.