[arvados] updated: 2.7.0-6417-g193354f3e7

git repository hosting git at public.arvados.org
Thu Apr 18 18:38:01 UTC 2024


Summary of changes:
 .../components/search-input/search-input.test.tsx  | 58 +++++++++-------------
 1 file changed, 24 insertions(+), 34 deletions(-)

       via  193354f3e791fea340e58d01aacee8afcc195116 (commit)
      from  515f96c411358b45a978b6b7c93da860b09ee7d0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 193354f3e791fea340e58d01aacee8afcc195116
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Thu Apr 18 14:29:24 2024 -0400

    Revert "21037: changed jest timer mocks to settimeouts Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>"
    
    Reverting due to false positives in search-input spec
    
    This reverts commit 515f96c411358b45a978b6b7c93da860b09ee7d0.
    
    Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/services/workbench2/src/components/search-input/search-input.test.tsx b/services/workbench2/src/components/search-input/search-input.test.tsx
index de36ae3858..ba70f752b9 100644
--- a/services/workbench2/src/components/search-input/search-input.test.tsx
+++ b/services/workbench2/src/components/search-input/search-input.test.tsx
@@ -11,7 +11,6 @@ configure({ adapter: new Adapter() });
 
 describe("<SearchInput />", () => {
 
-    // jest.useFakeTimers() applies to all setTimeout functions
     jest.useFakeTimers();
 
     let onSearch: () => void;
@@ -58,45 +57,39 @@ describe("<SearchInput />", () => {
             const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} />);
             searchInput.find("input").simulate("change", { target: { value: "current value" } });
             expect(onSearch).not.toBeCalled();
-            setTimeout(() => {
-                expect(onSearch).toBeCalledWith("current value");
-            }, DEFAULT_SEARCH_DEBOUNCE);
+            jest.runTimersToTime(DEFAULT_SEARCH_DEBOUNCE);
+            expect(onSearch).toBeCalledWith("current value");
         });
 
         it("calls onSearch after the time specified in props has passed", () => {
             const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} debounce={2000}/>);
             searchInput.find("input").simulate("change", { target: { value: "current value" } });
+            jest.runTimersToTime(1000);
             expect(onSearch).not.toBeCalled();
-            setTimeout(() => {
-                expect(onSearch).toBeCalledWith("current value");
-            }, 1000);
+            jest.runTimersToTime(1000);
+            expect(onSearch).toBeCalledWith("current value");
         });
 
         it("calls onSearch only once after no change happened during the specified time", () => {
             const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} debounce={1000}/>);
             searchInput.find("input").simulate("change", { target: { value: "current value" } });
-            setTimeout(() => {
-                searchInput.find("input").simulate("change", { target: { value: "changed value" } });
-            }, 500);
-            setTimeout(() => {
-                expect(onSearch).toHaveBeenCalledTimes(1);
-            }, 1000);
+            jest.runTimersToTime(500);
+            searchInput.find("input").simulate("change", { target: { value: "changed value" } });
+            jest.runTimersToTime(1000);
+            expect(onSearch).toHaveBeenCalledTimes(1);
         });
 
         it("calls onSearch again after the specified time has passed since previous call", () => {
             const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} debounce={1000}/>);
             searchInput.find("input").simulate("change", { target: { value: "current value" } });
-            setTimeout(() => {
-                searchInput.find("input").simulate("change", { target: { value: "intermediate value" } });
-            }, 500);
-            setTimeout(() => {
-                expect(onSearch).toBeCalledWith("intermediate value");
-            }, 1000);
+            jest.runTimersToTime(500);
+            searchInput.find("input").simulate("change", { target: { value: "intermediate value" } });
+            jest.runTimersToTime(1000);
+            expect(onSearch).toBeCalledWith("intermediate value");
             searchInput.find("input").simulate("change", { target: { value: "latest value" } });
-            setTimeout(() => {
-                expect(onSearch).toBeCalledWith("latest value");
-                expect(onSearch).toHaveBeenCalledTimes(2);
-            }, 1000);
+            jest.runTimersToTime(1000);
+            expect(onSearch).toBeCalledWith("latest value");
+            expect(onSearch).toHaveBeenCalledTimes(2);
 
         });
 
@@ -107,23 +100,20 @@ describe("<SearchInput />", () => {
             const searchInput = mount(<SearchInput selfClearProp="abc" value="123" onSearch={onSearch} debounce={1000}/>);
 
             // component should clear value upon creation
-            setTimeout(() => {
-                expect(onSearch).toBeCalledWith("");
-                expect(onSearch).toHaveBeenCalledTimes(1);
-            }, 1000);
+            jest.runTimersToTime(1000);
+            expect(onSearch).toBeCalledWith("");
+            expect(onSearch).toHaveBeenCalledTimes(1);
 
             // component should not clear on same selfClearProp
             searchInput.setProps({ selfClearProp: 'abc' });
-            setTimeout(() => {
-                expect(onSearch).toHaveBeenCalledTimes(1);
-            }, 1000);
+            jest.runTimersToTime(1000);
+            expect(onSearch).toHaveBeenCalledTimes(1);
 
             // component should clear on selfClearProp change
             searchInput.setProps({ selfClearProp: '111' });
-            setTimeout(() => {
-                expect(onSearch).toBeCalledWith("");
-                expect(onSearch).toHaveBeenCalledTimes(2);
-            }, 1000);
+            jest.runTimersToTime(1000);
+            expect(onSearch).toBeCalledWith("");
+            expect(onSearch).toHaveBeenCalledTimes(2);
         });
     });
 });

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list