describe("<DataExplorer />", () => {
- it("communicates with <ContextMenu/>", () => {
- const onContextAction = jest.fn();
- const dataExplorer = mount(<DataExplorer
- {...mockDataExplorerProps()}
- contextActions={[]}
- onContextAction={onContextAction}
- items={[{ key: "1", name: "item 1" }] as MockItem[]}
- columns={[{ name: "Column 1", render: jest.fn(), selected: true }]} />);
- expect(dataExplorer.find(ContextMenu).prop("actions")).toEqual([]);
- dataExplorer.find(DataTable).prop("onRowContextMenu")({
- preventDefault: jest.fn(),
- stopPropagation: jest.fn()
- }, "Item 1");
- dataExplorer.find(ContextMenu).prop("onActionClick")({ name: "Action 1", icon: "" });
- expect(onContextAction).toHaveBeenCalledWith({ name: "Action 1", icon: "" }, "Item 1");
- });
-
it("communicates with <SearchInput/>", () => {
const onSearch = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
columns={columns}
onColumnToggle={onColumnToggle}
- contextActions={[]}
items={[{ key: "1", name: "item 1" }] as MockItem[]} />);
expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns);
dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns");
onSortToggle: jest.fn(),
onRowClick: jest.fn(),
onColumnToggle: jest.fn(),
- onContextAction: jest.fn(),
onChangePage: jest.fn(),
- onChangeRowsPerPage: jest.fn()
+ onChangeRowsPerPage: jest.fn(),
+ onContextMenu: jest.fn()
});
\ No newline at end of file