From b8aa6d8c8f7d1f1783a10abcbaf04283617a63d3 Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Mon, 23 Oct 2023 16:54:01 +0500 Subject: [PATCH] tests: add test coverages --- .../BankingInformationSettings.test.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Settings/BankingInformationSettings/BankingInformationSettings.test.js b/src/Settings/BankingInformationSettings/BankingInformationSettings.test.js index 32c84f5a..7e8b0771 100644 --- a/src/Settings/BankingInformationSettings/BankingInformationSettings.test.js +++ b/src/Settings/BankingInformationSettings/BankingInformationSettings.test.js @@ -3,6 +3,7 @@ import user from '@folio/jest-config-stripes/testing-library/user-event'; import { useOkapiKy } from '@folio/stripes/core'; import BankingInformationSettings from './BankingInformationSettings'; +import { useBankingInformation } from '../hooks'; jest.mock('react-query', () => ({ ...jest.requireActual('react-query'), @@ -11,6 +12,11 @@ jest.mock('react-query', () => ({ })), })); +jest.mock('@folio/stripes/components', () => ({ + ...jest.requireActual('@folio/stripes/components'), + Loading: () =>
Loading
, +})); + jest.mock('../hooks', () => ({ useBankingInformation: jest.fn(() => ({ isLoading: false, @@ -38,7 +44,22 @@ describe('BankingInformationSettings component', () => { expect(screen.getByText('ui-organizations.settings.bankingInformation.disabled')).toBeInTheDocument(); }); + it('should render Loading component', () => { + useBankingInformation.mockReturnValue({ + isLoading: true, + enabled: false, + }); + + renderBankingInformationSettings(); + + expect(screen.getByText('Loading')).toBeInTheDocument(); + }); + it('should save banking options', async () => { + useBankingInformation.mockClear().mockReturnValue({ + isLoading: false, + enabled: true, + }); const mockPutMethod = jest.fn(() => ({ json: () => Promise.resolve('ok'), }));