+ it("passes sorting props to <TableSortLabel />", () => {
+ const columns: DataColumns<string> = [
+ createDataColumn({
+ name: "Column 1",
+ sortDirection: SortDirection.ASC,
+ selected: true,
+ configurable: true,
+ render: (item) => <Typography>{item}</Typography>
+ })];
+ const onSortToggle = jest.fn();
+ const dataTable = mount(<DataTable
+ columns={columns}
+ items={["item 1"]}
+ onFiltersChange={jest.fn()}
+ onRowClick={jest.fn()}
+ onRowDoubleClick={jest.fn()}
+ onContextMenu={jest.fn()}
+ onSortToggle={onSortToggle} />);
+ expect(dataTable.find(TableSortLabel).prop("active")).toBeTruthy();
+ dataTable.find(TableSortLabel).at(0).simulate("click");
+ expect(onSortToggle).toHaveBeenCalledWith(columns[0]);
+ });
+
+ it("does not display <DataTableFiltersPopover /> if there is no filters provided", () => {
+ const columns: DataColumns<string> = [{
+ name: "Column 1",
+ sortDirection: SortDirection.ASC,
+ selected: true,
+ configurable: true,
+ filters: [],
+ render: (item) => <Typography>{item}</Typography>
+ }];
+ const onFiltersChange = jest.fn();
+ const dataTable = mount(<DataTable
+ columns={columns}
+ items={[]}
+ onFiltersChange={onFiltersChange}
+ onRowClick={jest.fn()}
+ onRowDoubleClick={jest.fn()}
+ onSortToggle={jest.fn()}
+ onContextMenu={jest.fn()} />);
+ expect(dataTable.find(DataTableFiltersPopover)).toHaveLength(0);
+ });