From e2ea1359533664ead0ae9b810fe56bf518846c78 Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Thu, 21 Jun 2018 16:36:48 +0200 Subject: [PATCH] Add search input communication test, fix context menu communication test Feature #13633 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../data-explorer/data-explorer.test.tsx | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/src/components/data-explorer/data-explorer.test.tsx b/src/components/data-explorer/data-explorer.test.tsx index 88481ce6..8ced6cb3 100644 --- a/src/components/data-explorer/data-explorer.test.tsx +++ b/src/components/data-explorer/data-explorer.test.tsx @@ -10,6 +10,7 @@ import DataExplorer from "./data-explorer"; import ContextMenu from "../context-menu/context-menu"; import ColumnSelector from "../column-selector/column-selector"; import DataTable from "../data-table/data-table"; +import SearchInput from "../search-input/search-input"; configure({ adapter: new Adapter() }); @@ -17,39 +18,44 @@ describe("", () => { it("communicates with ", () => { const onContextAction = jest.fn(); const dataExplorer = mount(); - + columns={[{ name: "Column 1", render: jest.fn(), selected: true }]} />); expect(dataExplorer.find(ContextMenu).prop("actions")).toEqual([]); - dataExplorer.setState({ contextMenu: { item: "Item 1" } }); + dataExplorer.find(DataTable).prop("onRowContextMenu")({ + preventDefault: 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 ", () => { + const onSearch = jest.fn(); + const dataExplorer = mount(); + expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value"); + dataExplorer.find(SearchInput).prop("onSearch")("new value"); + expect(onSearch).toHaveBeenCalledWith("new value"); + }); + it("communicates with ", () => { const onColumnToggle = jest.fn(); const columns = [{ name: "Column 1", render: jest.fn(), selected: true }]; const dataExplorer = mount(); - + items={["Item 1"]} />); expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns); dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns"); expect(onColumnToggle).toHaveBeenCalledWith("columns"); }); - + it("communicates with ", () => { const onFiltersChange = jest.fn(); const onSortToggle = jest.fn(); @@ -57,15 +63,12 @@ describe("", () => { const columns = [{ name: "Column 1", render: jest.fn(), selected: true }]; const items = ["Item 1"]; const dataExplorer = mount(); - + onRowClick={onRowClick} />); expect(dataExplorer.find(DataTable).prop("columns")).toBe(columns); expect(dataExplorer.find(DataTable).prop("items")).toBe(items); dataExplorer.find(DataTable).prop("onRowClick")("event", "rowClick"); @@ -75,4 +78,17 @@ describe("", () => { expect(onSortToggle).toHaveBeenCalledWith("sortToggle"); expect(onRowClick).toHaveBeenCalledWith("rowClick"); }); +}); + +const mockDataExplorerProps = () => ({ + columns: [], + items: [], + contextActions: [], + searchValue: "", + onSearch: jest.fn(), + onFiltersChange: jest.fn(), + onSortToggle: jest.fn(), + onRowClick: jest.fn(), + onColumnToggle: jest.fn(), + onContextAction: jest.fn() }); \ No newline at end of file -- 2.39.5