const onSearch = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
+ items={["item 1"]}
searchValue="search value"
onSearch={onSearch} />);
expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value");
expect(onRowClick).toHaveBeenCalledWith("rowClick");
});
- it("renders <TablePagination/> if items list is not empty", () => {
- const onChangePage = jest.fn();
- const onChangeRowsPerPage = jest.fn();
+ it("does not render <SearchInput/>, <ColumnSelector/> and <TablePagination/> if there is no items", () => {
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
- items={["Item 1"]}
+ items={[]}
/>);
- expect(dataExplorer.find(TablePagination)).toHaveLength(1);
+ expect(dataExplorer.find(SearchInput)).toHaveLength(0);
+ expect(dataExplorer.find(ColumnSelector)).toHaveLength(0);
+ expect(dataExplorer.find(TablePagination)).toHaveLength(0);
});
it("communicates with <TablePagination/>", () => {
onActionClick={this.callAction}
onClose={this.closeContextMenu} />
<Toolbar className={this.props.classes.toolbar}>
- <Grid container justify="space-between" wrap="nowrap" alignItems="center">
- <div className={this.props.classes.searchBox}>
- <SearchInput
- value={this.props.searchValue}
- onSearch={this.props.onSearch} />
- </div>
- <ColumnSelector
- columns={this.props.columns}
- onColumnToggle={this.props.onColumnToggle} />
- </Grid>
+ {this.props.items.length > 0 &&
+ <Grid container justify="space-between" wrap="nowrap" alignItems="center">
+ <div className={this.props.classes.searchBox}>
+ <SearchInput
+ value={this.props.searchValue}
+ onSearch={this.props.onSearch} />
+ </div>
+ <ColumnSelector
+ columns={this.props.columns}
+ onColumnToggle={this.props.onColumnToggle} />
+ </Grid>}
+
</Toolbar>
<DataTable
columns={this.props.columns}