From 439052f0a871a4f32b7401c7b5721d0edad12bb6 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Thu, 19 Sep 2024 20:36:23 -0300 Subject: [PATCH] test: search with debounce --- src/app/__tests__/forum.spec.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/app/__tests__/forum.spec.tsx b/src/app/__tests__/forum.spec.tsx index e87292b0..a3c6f354 100644 --- a/src/app/__tests__/forum.spec.tsx +++ b/src/app/__tests__/forum.spec.tsx @@ -66,4 +66,21 @@ describe("Forum", () => { })); }); + it("deve realizar pesquisa com debounce", async () => { + const { getByPlaceholderText } = render(); + + // Alterar para o placeholder correto + const searchInput = getByPlaceholderText("Pesquise uma publicação"); + + fireEvent.changeText(searchInput, ""); + + // Aguarda o debounce + await waitFor(() => { + expect(getAllPublicacao).toHaveBeenCalledWith( + 0, + { titulo: "", isReported: false }, + expect.any(Object) + ); + }); + }); });