X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/e4f350462118a86831f92eb375c2bc89cbf85920..76fe6edc8d158f67c600f75c6bb351d7a679b71e:/src/components/search-input/search-input.test.tsx

diff --git a/src/components/search-input/search-input.test.tsx b/src/components/search-input/search-input.test.tsx
index c1bd79ab..ba70f752 100644
--- a/src/components/search-input/search-input.test.tsx
+++ b/src/components/search-input/search-input.test.tsx
@@ -98,28 +98,20 @@ describe("<SearchInput />", () => {
     describe("on input target change", () => {
         it("clears the input value on selfClearProp change", () => {
             const searchInput = mount(<SearchInput selfClearProp="abc" value="123" onSearch={onSearch} debounce={1000}/>);
-            // initial no clear call
-            jest.runTimersToTime(0);
-            searchInput.setProps({ selfClearProp: '111' });
-            expect(onSearch).not.toBeCalledWith("");
-            expect(onSearch).toHaveBeenCalledTimes(0);
 
-            // second call trigger input clear
-            searchInput.setProps({ selfClearProp: 'aaa111' });
-            jest.runTimersToTime(0);
+            // component should clear value upon creation
+            jest.runTimersToTime(1000);
             expect(onSearch).toBeCalledWith("");
             expect(onSearch).toHaveBeenCalledTimes(1);
 
-            // third call trigger not input clear beacuse of the same selfClearProp value
-            searchInput.setProps({ selfClearProp: 'aaa111', value: '321' });
-            jest.runTimersToTime(0);
-            expect(onSearch).toBeCalledWith("");
+            // component should not clear on same selfClearProp
+            searchInput.setProps({ selfClearProp: 'abc' });
+            jest.runTimersToTime(1000);
             expect(onSearch).toHaveBeenCalledTimes(1);
-            expect(searchInput.props().value).toBe('321');
 
-            // third call trigger input clear beacuse of different selfClearProp value
-            searchInput.setProps({ selfClearProp: 'aaa222' });
-            jest.runTimersToTime(0);
+            // component should clear on selfClearProp change
+            searchInput.setProps({ selfClearProp: '111' });
+            jest.runTimersToTime(1000);
             expect(onSearch).toBeCalledWith("");
             expect(onSearch).toHaveBeenCalledTimes(2);
         });
