From e7a722835aeda5ebe0eeab2328a7e628927e6416 Mon Sep 17 00:00:00 2001 From: Pawel Kowalczyk Date: Tue, 9 Oct 2018 11:59:13 +0200 Subject: [PATCH] tests fix Feature #14313 Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk --- .../search-bar/search-bar-view.test.tsx | 85 +++++++++++++++++-- 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/src/views-components/search-bar/search-bar-view.test.tsx b/src/views-components/search-bar/search-bar-view.test.tsx index 4230aa80..de1e961c 100644 --- a/src/views-components/search-bar/search-bar-view.test.tsx +++ b/src/views-components/search-bar/search-bar-view.test.tsx @@ -8,6 +8,7 @@ import { SearchBarView, DEFAULT_SEARCH_DEBOUNCE } from "./search-bar-view"; import * as Adapter from 'enzyme-adapter-react-16'; + configure({ adapter: new Adapter() }); describe("", () => { @@ -22,20 +23,44 @@ describe("", () => { describe("on submit", () => { it("calls onSearch with initial value passed via props", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("form").simulate("submit"); expect(onSearch).toBeCalledWith("initial value"); }); it("calls onSearch with current value", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("input").simulate("change", { target: { value: "current value" } }); searchBar.find("form").simulate("submit"); expect(onSearch).toBeCalledWith("current value"); }); it("calls onSearch with new value passed via props", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("input").simulate("change", { target: { value: "current value" } }); searchBar.setProps({ value: "new value" }); searchBar.find("form").simulate("submit"); @@ -43,7 +68,16 @@ describe("", () => { }); it("cancels timeout set on input value change", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("input").simulate("change", { target: { value: "current value" } }); searchBar.find("form").simulate("submit"); jest.runTimersToTime(1000); @@ -55,7 +89,15 @@ describe("", () => { describe("on input value change", () => { it("calls onSearch after default timeout", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("input").simulate("change", { target: { value: "current value" } }); expect(onSearch).not.toBeCalled(); jest.runTimersToTime(DEFAULT_SEARCH_DEBOUNCE); @@ -63,7 +105,16 @@ describe("", () => { }); it("calls onSearch after the time specified in props has passed", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("input").simulate("change", { target: { value: "current value" } }); jest.runTimersToTime(1000); expect(onSearch).not.toBeCalled(); @@ -72,7 +123,16 @@ describe("", () => { }); it("calls onSearch only once after no change happened during the specified time", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("input").simulate("change", { target: { value: "current value" } }); jest.runTimersToTime(500); searchBar.find("input").simulate("change", { target: { value: "changed value" } }); @@ -81,7 +141,16 @@ describe("", () => { }); it("calls onSearch again after the specified time has passed since previous call", () => { - const searchBar = mount(); + const searchBar = mount( ['test']} />); searchBar.find("input").simulate("change", { target: { value: "current value" } }); jest.runTimersToTime(500); searchBar.find("input").simulate("change", { target: { value: "intermediate value" } }); -- 2.30.2