From 62c78f8625ece50349e4b75d685de550ebd46581 Mon Sep 17 00:00:00 2001 From: Alissa Crane Date: Wed, 14 Aug 2024 14:19:41 -0700 Subject: [PATCH] add test coverage --- .../components/WalletBottomSheet.test.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/wallet/components/WalletBottomSheet.test.tsx b/src/wallet/components/WalletBottomSheet.test.tsx index af38d9e198..75d0eb8145 100644 --- a/src/wallet/components/WalletBottomSheet.test.tsx +++ b/src/wallet/components/WalletBottomSheet.test.tsx @@ -101,4 +101,22 @@ describe('WalletBottomSheet', () => { expect(setIsOpenMock).toHaveBeenCalledWith(false); }); + + it('closes the bottom sheet when Escape key is pressed', () => { + const setIsOpenMock = vi.fn(); + useAccountMock.mockReturnValue({ address: '0x123' }); + useWalletContextMock.mockReturnValue({ + isOpen: true, + setIsOpen: setIsOpenMock, + }); + + render(Content); + + fireEvent.keyDown(screen.getByRole('button'), { + key: 'Escape', + code: 'Escape', + }); + + expect(setIsOpenMock).toHaveBeenCalledWith(false); + }); });