From 19253b584d3823b34c5a25f649d535bef6e983ca Mon Sep 17 00:00:00 2001 From: vetalcore Date: Tue, 26 Nov 2024 14:26:58 +0200 Subject: [PATCH] refactor(common): fix unit tests --- .../src/wallet/lib/__tests__/get-inputs-value.test.ts | 4 ++-- .../CollapsablePanel/__tests__/CollapsablePanel.test.tsx | 2 +- .../components/Drawer/__tests__/DrawerNavigation.test.tsx | 4 ++-- .../src/ui/components/Form/Input/__tests__/Input.test.tsx | 2 +- .../components/Form/TextArea/__tests__/TextArea.test.tsx | 5 +++-- .../src/ui/components/Search/__tests__/Search.test.tsx | 8 +++++--- .../src/ui/components/Toast/__tests__/Toast.test.tsx | 5 +++-- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/cardano/src/wallet/lib/__tests__/get-inputs-value.test.ts b/packages/cardano/src/wallet/lib/__tests__/get-inputs-value.test.ts index 0a1efcee1..c94847ee2 100644 --- a/packages/cardano/src/wallet/lib/__tests__/get-inputs-value.test.ts +++ b/packages/cardano/src/wallet/lib/__tests__/get-inputs-value.test.ts @@ -250,7 +250,7 @@ describe('Testing getTxInputsValueAndAddress function', () => { ]); const result = getTxInputsValueAndAddress( - Array.from({ length: 30 }).map((_, index) => ({ index, txId: 'txId1' }) as unknown as Cardano.TxIn), + Array.from({ length: 30 }).map((_, index) => ({ index, txId: 'txId1' } as unknown as Cardano.TxIn)), { transactionsByHashes } as unknown as ChainHistoryProvider, @@ -285,7 +285,7 @@ describe('Testing getTxInputsValueAndAddress function', () => { ); const result = getTxInputsValueAndAddress( - Array.from({ length: 30 }).map((_, index) => ({ index: 0, txId: `txId${index}` }) as Cardano.TxIn), + Array.from({ length: 30 }).map((_, index) => ({ index: 0, txId: `txId${index}` } as Cardano.TxIn)), { transactionsByHashes } as unknown as ChainHistoryProvider, diff --git a/packages/common/src/ui/components/CollapsablePanel/__tests__/CollapsablePanel.test.tsx b/packages/common/src/ui/components/CollapsablePanel/__tests__/CollapsablePanel.test.tsx index e07a218f8..596bd718e 100644 --- a/packages/common/src/ui/components/CollapsablePanel/__tests__/CollapsablePanel.test.tsx +++ b/packages/common/src/ui/components/CollapsablePanel/__tests__/CollapsablePanel.test.tsx @@ -22,7 +22,7 @@ describe('CollapsablePanel', () => { ); const clickable = queryByRole('button'); act(() => { - fireEvent.click(clickable); + clickable && fireEvent.click(clickable); }); expect(queryByTestId('test-content')).toBeInTheDocument(); }); diff --git a/packages/common/src/ui/components/Drawer/__tests__/DrawerNavigation.test.tsx b/packages/common/src/ui/components/Drawer/__tests__/DrawerNavigation.test.tsx index c36f91036..3918a03c4 100644 --- a/packages/common/src/ui/components/Drawer/__tests__/DrawerNavigation.test.tsx +++ b/packages/common/src/ui/components/Drawer/__tests__/DrawerNavigation.test.tsx @@ -15,7 +15,7 @@ describe('DrawerNavigation', () => { const { queryByTestId } = render(); const backButton = queryByTestId('navigation-button-arrow'); expect(backButton).toBeInTheDocument(); - fireEvent.click(backButton); + backButton && fireEvent.click(backButton); expect(onClick).toHaveBeenCalled(); }); test('shows close button if on click function is defined', () => { @@ -23,7 +23,7 @@ describe('DrawerNavigation', () => { const { queryByTestId } = render(); const closeButton = queryByTestId('navigation-button-cross'); expect(closeButton).toBeInTheDocument(); - fireEvent.click(closeButton); + closeButton && fireEvent.click(closeButton); expect(onClick).toHaveBeenCalled(); }); test('shows left actions if passed as props instead of back arrow', () => { diff --git a/packages/common/src/ui/components/Form/Input/__tests__/Input.test.tsx b/packages/common/src/ui/components/Form/Input/__tests__/Input.test.tsx index e9729638c..060a0c4a4 100644 --- a/packages/common/src/ui/components/Form/Input/__tests__/Input.test.tsx +++ b/packages/common/src/ui/components/Form/Input/__tests__/Input.test.tsx @@ -15,7 +15,7 @@ describe('Input', () => { const input = queryByTestId('input-test'); expect(input).toHaveValue(''); act(() => { - fireEvent.change(input, { target: { value: 'new value' } }); + input && fireEvent.change(input, { target: { value: 'new value' } }); }); expect(input).toHaveValue('new value'); expect(onChange).toHaveBeenCalled(); diff --git a/packages/common/src/ui/components/Form/TextArea/__tests__/TextArea.test.tsx b/packages/common/src/ui/components/Form/TextArea/__tests__/TextArea.test.tsx index bc17123d7..6bc72eb5a 100644 --- a/packages/common/src/ui/components/Form/TextArea/__tests__/TextArea.test.tsx +++ b/packages/common/src/ui/components/Form/TextArea/__tests__/TextArea.test.tsx @@ -15,7 +15,7 @@ describe('TextArea', () => { const area = queryByTestId('text-area-test'); expect(area).toHaveValue(''); act(() => { - fireEvent.change(area, { target: { value: 'new value' } }); + area && fireEvent.change(area, { target: { value: 'new value' } }); }); expect(area).toHaveValue('new value'); expect(onChange).toHaveBeenCalled(); @@ -24,7 +24,8 @@ describe('TextArea', () => { const onBlur = jest.fn(); const { queryByTestId } = render(