Skip to content

Commit

Permalink
Change prop name in TextFilter to be more explicit
Browse files Browse the repository at this point in the history
Signed-off-by: Stephane Jolicoeur <sjolicoeur@pivotal.io>
  • Loading branch information
reidmit authored and sjolicoeur committed Nov 6, 2017
1 parent d2e0426 commit 4f73979
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions spec/pivotal-ui-react/text-filter/text-filter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import '../spec_helper';
import {TextFilter} from '../../../src/react/text-filter';

describe('TextFilter', () => {
let data, filter, onFilter;
let data, filter, renderFilteredData;

beforeEach(() => {
data = ['apple', 'banana', 'actuator'];
filter = jasmine.createSpy('filter').and.returnValue(data);
onFilter = jasmine.createSpy('onFilter')
renderFilteredData = jasmine.createSpy('renderFilteredData')
.and.returnValue(<ul>{data.map((v, i) => <li key={i}>{v}</li>)}</ul>);
ReactDOM.render(<TextFilter {...{
data,
filter,
onFilter
renderFilteredData
}}/>, root);
});

Expand Down Expand Up @@ -43,8 +43,8 @@ describe('TextFilter', () => {
expect('.text-filter > .grid .col:eq(2) .filtered-count').toHaveText(data.length);
});

it('calls the onFilter callback', () => {
expect(onFilter).toHaveBeenCalledWith(data);
it('calls the renderFilteredData callback', () => {
expect(renderFilteredData).toHaveBeenCalledWith(data);
});

it('renders the filtered object', () => {
Expand All @@ -60,7 +60,7 @@ describe('TextFilter', () => {
beforeEach(() => {
filtered = ['apple', 'actuator'];
filter.and.returnValue(filtered);
onFilter.and.returnValue(<ul>{filtered.map((v, i) => <li key={i}>{v}</li>)}</ul>);
renderFilteredData.and.returnValue(<ul>{filtered.map((v, i) => <li key={i}>{v}</li>)}</ul>);
$('input').val('a').simulate('change');
});

Expand All @@ -77,8 +77,8 @@ describe('TextFilter', () => {
expect('.text-filter > .grid .col:eq(2)').toHaveText(`${filtered.length} / ${data.length}`);
});

it('calls the onFilter callback', () => {
expect(onFilter).toHaveBeenCalledWith(filtered);
it('calls the renderFilteredData callback', () => {
expect(renderFilteredData).toHaveBeenCalledWith(filtered);
});

it('renders the filtered object', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/react/text-filter/text-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export class TextFilter extends React.Component {
static propTypes = {
data: PropTypes.array.isRequired,
filter: PropTypes.func.isRequired,
onFilter: PropTypes.func.isRequired
renderFilteredData: PropTypes.func.isRequired
};

static defaultProps = {
data: [],
filter: data => data,
onFilter: () => null
renderFilteredData: () => null
};

constructor(props) {
Expand All @@ -29,7 +29,7 @@ export class TextFilter extends React.Component {
}

render() {
const {data, filter, onFilter, className} = this.props;
const {data, filter, renderFilteredData, className} = this.props;
const {filterText} = this.state;
const filteredData = filter(data, filterText);

Expand All @@ -47,7 +47,7 @@ export class TextFilter extends React.Component {
</span> / <span className="unfiltered-count">{data.length}</span>
</FlexCol>
</Grid>
{onFilter(filteredData)}
{renderFilteredData(filteredData)}
</div>
);
}
Expand Down

0 comments on commit 4f73979

Please sign in to comment.