Skip to content

Commit

Permalink
UIORGS-390 rename hook useBankingInformation to useBankingInformation…
Browse files Browse the repository at this point in the history
…Settings: to not confuse domens
  • Loading branch information
usavkov-epam committed Nov 9, 2023
1 parent e2d4e81 commit 7b6029e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Loading } from '@folio/stripes/components';
import { useOkapiKy } from '@folio/stripes/core';

import { SETTINGS_API } from '../../common/constants';
import { useBankingInformation } from '../../common/hooks';
import { useBankingInformationSettings } from '../../common/hooks';
import BankingInformationSettingsForm from './BankingInformationSettingsForm';

const BankingInformationSettings = () => {
Expand All @@ -14,7 +14,7 @@ const BankingInformationSettings = () => {
bankingInformation,
isLoading,
refetch,
} = useBankingInformation();
} = useBankingInformationSettings();
const ky = useOkapiKy();
const sendCallout = useShowCallout();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import user from '@folio/jest-config-stripes/testing-library/user-event';
import { useOkapiKy } from '@folio/stripes/core';

import { useBankingInformation } from '../../common/hooks';
import { useBankingInformationSettings } from '../../common/hooks';
import BankingInformationSettings from './BankingInformationSettings';

const mockRefetch = jest.fn();
Expand All @@ -19,7 +19,7 @@ jest.mock('@folio/stripes/components', () => ({
}));

jest.mock('../hooks', () => ({
useBankingInformation: jest.fn(() => ({
useBankingInformationSettings: jest.fn(() => ({
isLoading: false,
enabled: false,
refetch: mockRefetch,
Expand All @@ -43,7 +43,7 @@ describe('BankingInformationSettings component', () => {
});

it('should render Loading component', () => {
useBankingInformation.mockReturnValue({
useBankingInformationSettings.mockReturnValue({
isLoading: true,
enabled: false,
});
Expand All @@ -54,7 +54,7 @@ describe('BankingInformationSettings component', () => {
});

it('should save banking options', async () => {
useBankingInformation.mockClear().mockReturnValue({
useBankingInformationSettings.mockClear().mockReturnValue({
isLoading: false,
enabled: true,
refetch: mockRefetch,
Expand Down
4 changes: 2 additions & 2 deletions src/Settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl';

import { Settings } from '@folio/stripes/smart-components';

import { useBankingInformation } from '../common/hooks';
import { useBankingInformationSettings } from '../common/hooks';
import { CategorySettings } from './CategorySettings';
import { TypeSettings } from './TypeSettings';
import { BankingAccountTypeSettings } from './BankingAccountTypeSettings';
Expand Down Expand Up @@ -38,7 +38,7 @@ const bankingAccountTypesPage = {
};

const SettingsPage = (props) => {
const { enabled } = useBankingInformation();
const { enabled } = useBankingInformationSettings();

const settingsPages = useMemo(() => (enabled ? pages.concat(bankingAccountTypesPage) : pages), [enabled]);

Expand Down
10 changes: 5 additions & 5 deletions src/Settings/SettingsPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MemoryRouter } from 'react-router-dom';

import { screen, render } from '@folio/jest-config-stripes/testing-library/react';

import { useBankingInformation } from '../common/hooks';
import { useBankingInformationSettings } from '../common/hooks';
import SettingsPage from './SettingsPage';

jest.mock('@folio/stripes/core');
Expand All @@ -14,7 +14,7 @@ jest.mock('@folio/stripes/components', () => ({
Loading: () => <div>Loading</div>,
}));
jest.mock('./hooks', () => ({
useBankingInformation: jest.fn(() => ({
useBankingInformationSettings: jest.fn(() => ({
isLoading: false,
enabled: false,
})),
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('SettingsPage', () => {
});

it('should return banking account types link', async () => {
useBankingInformation.mockReturnValue({
useBankingInformationSettings.mockReturnValue({
isLoading: false,
enabled: true,
});
Expand All @@ -62,8 +62,8 @@ describe('SettingsPage', () => {
expect(screen.getByText('ui-organizations.settings.bankingAccountTypes')).toBeInTheDocument();
});

it('should display loading on fetching useBankingInformation', async () => {
useBankingInformation.mockReturnValue({
it('should display loading on fetching useBankingInformationSettings', async () => {
useBankingInformationSettings.mockReturnValue({
isLoading: true,
enabled: false,
});
Expand Down
2 changes: 1 addition & 1 deletion src/common/hooks/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './useAcqMethods';
export * from './useBankingInformation';
export * from './useBankingInformationSettings';
export * from './useIntegrationConfig';
export * from './useIntegrationConfigMutation';
export * from './useLinkedAgreements';
Expand Down
1 change: 0 additions & 1 deletion src/common/hooks/useBankingInformation/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/common/hooks/useBankingInformationSettings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useBankingInformationSettings } from './useBankingInformationSettings';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

const DEFAULT_DATA = {};

export const useBankingInformation = () => {
export const useBankingInformationSettings = () => {
const ky = useOkapiKy();
const [namespace] = useNamespace({ key: 'banking-information-settings' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { useOkapiKy } from '@folio/stripes/core';

import { BANKING_INFORMATION_ENABLED_KEY } from '../../constants';
import { useBankingInformation } from './useBankingInformation';
import { useBankingInformationSettings } from './useBankingInformationSettings';

const queryClient = new QueryClient();

Expand All @@ -28,7 +28,7 @@ const wrapper = ({ children }) => (
</QueryClientProvider>
);

describe('useBankingInformation', () => {
describe('useBankingInformationSettings', () => {
beforeEach(() => {
useOkapiKy
.mockClear()
Expand All @@ -40,7 +40,7 @@ describe('useBankingInformation', () => {
});

it('should fetch banking information settings', async () => {
const { result } = renderHook(() => useBankingInformation(), { wrapper });
const { result } = renderHook(() => useBankingInformationSettings(), { wrapper });

await waitFor(() => expect(result.current.isLoading).toBeFalsy());

Expand Down

0 comments on commit 7b6029e

Please sign in to comment.