Skip to content

Commit

Permalink
tests: add test coverages
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Oct 23, 2023
1 parent 2210b9c commit b8aa6d8
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -11,6 +12,11 @@ jest.mock('react-query', () => ({
})),
}));

jest.mock('@folio/stripes/components', () => ({
...jest.requireActual('@folio/stripes/components'),
Loading: () => <div>Loading</div>,
}));

jest.mock('../hooks', () => ({
useBankingInformation: jest.fn(() => ({
isLoading: false,
Expand Down Expand Up @@ -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'),
}));
Expand Down

0 comments on commit b8aa6d8

Please sign in to comment.