From 99d8205a8d13a91ae2bdd8d36ded150bbaabe2a0 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 10 Feb 2022 14:40:55 +0100 Subject: [PATCH] useSearchModal: clarify tests Signed-off-by: Vincenzo Scamporlino --- .../src/components/SearchModal/useSearchModal.test.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/search/src/components/SearchModal/useSearchModal.test.tsx b/plugins/search/src/components/SearchModal/useSearchModal.test.tsx index 7ec43c7bb6..424dffff76 100644 --- a/plugins/search/src/components/SearchModal/useSearchModal.test.tsx +++ b/plugins/search/src/components/SearchModal/useSearchModal.test.tsx @@ -30,7 +30,7 @@ describe('useSearchModal', () => { }, ); - it('should properly toggle the state', () => { + it('should keep open forever to true once modal is toggled', () => { const rendered = renderHook(() => useSearchModal()); act(() => rendered.result.current.toggleModal()); @@ -46,14 +46,17 @@ describe('useSearchModal', () => { }); }); - it('should properly change the state', () => { + it('should keep open to false if setOpen(false) is invoked on an initially closed modal', () => { const rendered = renderHook(() => useSearchModal()); - act(() => rendered.result.current.setOpen(false)); expect(rendered.result.current.state).toEqual({ open: false, hidden: true, }); + }); + + it('should keep open forever to true even when the modal transition from opened to closed', () => { + const rendered = renderHook(() => useSearchModal()); act(() => rendered.result.current.setOpen(true)); expect(rendered.result.current.state).toEqual({