Skip to content

Commit

Permalink
Add indexes for api directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Feb 26, 2024
1 parent 4e97c88 commit 3a2a72d
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 56 deletions.
30 changes: 13 additions & 17 deletions src/BursarExportPlugin.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { render, screen } from '@folio/jest-config-stripes/testing-library/react';
import React from 'react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';
import { useStripes } from '@folio/stripes/core';
import arrayMutators from 'final-form-arrays';
import React from 'react';
import { Form, FormProps } from 'react-final-form';
import BursarExportPlugin from './index';
import withIntlConfiguration from '../test/util/withIntlConfiguration';
import useInitialValues from './hooks/useInitialValues';
import { formValuesToDto, schedulingToDto } from './api/dto/to';
import { FORM_ID } from './constants';
import formValuesToDto from './api/dto/to/formValuesToDto';
import schedulingToDto from './api/dto/to/schedulingToDto';
import useInitialValues from './hooks/useInitialValues';
import BursarExportPlugin from './index';

jest.mock('./api/mutators/useManualSchedulerMutation', () => () => jest.fn());
jest.mock('./api/mutators/useAutomaticSchedulerMutation', () => () => jest.fn());
jest.mock('./api/dto/to', () => ({ formValuesToDto: jest.fn(), schedulingToDto: jest.fn() }));

jest.mock('./api/mutators', () => ({
useManualSchedulerMutation: () => jest.fn(),
useAutomaticSchedulerMutation: () => jest.fn(),
}));
jest.mock('./hooks/useInitialValues', () => jest.fn());
jest.mock('@folio/stripes/final-form', () => ({
__esModule: true,
Expand All @@ -34,17 +37,10 @@ const transferAccount = {
desc: 'Test description',
};

jest.mock('./api/queries/useFeeFineOwners', () => ({
__esModule: true,
default: () => ({ data: [feeFineOwner], isSuccess: true }),
}));

jest.mock('./api/queries/useTransferAccounts', () => ({
__esModule: true,
default: () => ({ data: [transferAccount], isSuccess: true }),
jest.mock('./api/queries', () => ({
useFeeFineOwners: () => ({ data: [feeFineOwner], isSuccess: true }),
useTransferAccounts: () => ({ data: [transferAccount], isSuccess: true }),
}));
jest.mock('./api/dto/to/formValuesToDto', () => jest.fn());
jest.mock('./api/dto/to/schedulingToDto', () => jest.fn());

describe('BursarExportPlugin', () => {
it('renders the plugin with null initial values', () => {
Expand Down
8 changes: 3 additions & 5 deletions src/BursarExportPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { useStripes } from '@folio/stripes/core';
import { FormApi } from 'final-form';
import React, { useCallback, useRef } from 'react';
import { FormattedMessage } from 'react-intl';
import formValuesToDto from './api/dto/to/formValuesToDto';
import schedulingToDto from './api/dto/to/schedulingToDto';
import useAutomaticSchedulerMutation from './api/mutators/useAutomaticSchedulerMutation';
import useManualSchedulerMutation from './api/mutators/useManualSchedulerMutation';
import { formValuesToDto, schedulingToDto } from './api/dto/to';
import { useAutomaticSchedulerMutation, useManualSchedulerMutation } from './api/mutators';
import ConfigurationForm from './components/ConfigurationForm';
import { FORM_ID } from './constants';
import useInitialValues from './hooks/useInitialValues';
import FormValues from './types/FormValues';
import { FORM_ID } from './constants';

export default function BursarExportPlugin() {
const stripes = useStripes();
Expand Down
1 change: 1 addition & 0 deletions src/api/dto/from/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './dtoToFormValues';
2 changes: 2 additions & 0 deletions src/api/dto/to/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as formValuesToDto } from './formValuesToDto';
export { default as schedulingToDto } from './schedulingToDto';
2 changes: 2 additions & 0 deletions src/api/mutators/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as useAutomaticSchedulerMutation } from './useAutomaticSchedulerMutation';
export { default as useManualSchedulerMutation } from './useManualSchedulerMutation';
10 changes: 10 additions & 0 deletions src/api/queries/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export { default as useCampuses } from './useCampuses';
export { default as useCurrentConfig } from './useCurrentConfig';
export { default as useFeeFineOwners } from './useFeeFineOwners';
export { default as useFeeFineTypes } from './useFeeFineTypes';
export { default as useInstitutions } from './useInstitutions';
export { default as useLibraries } from './useLibraries';
export { default as useLocations } from './useLocations';
export { default as usePatronGroups } from './usePatronGroups';
export { default as useServicePoints } from './useServicePoints';
export { default as useTransferAccounts } from './useTransferAccounts';
11 changes: 3 additions & 8 deletions src/components/ConfigurationForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ jest.mock('@folio/stripes/final-form', () => ({
),
}));

jest.mock('../../api/queries/useFeeFineOwners', () => ({
__esModule: true,
default: () => ({ data: [], isSuccess: true }),
}));

jest.mock('../../api/queries/useTransferAccounts', () => ({
__esModule: true,
default: () => ({ data: [], isSuccess: true }),
jest.mock('../api/queries', () => ({
useFeeFineOwners: () => ({ data: [], isSuccess: true }),
useTransferAccounts: () => ({ data: [], isSuccess: true }),
}));

describe('Configuration form section', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Criteria/CriteriaFeeFineOwner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Col, Select } from '@folio/stripes/components';
import React, { useMemo } from 'react';
import { Field } from 'react-final-form';
import { FormattedMessage } from 'react-intl';
import useFeeFineOwners from '../../api/queries/useFeeFineOwners';
import { useFeeFineOwners } from '../../api/queries';

export default function CriteriaFeeFineOwner({ prefix }: Readonly<{ prefix: string }>) {
const feeFineOwners = useFeeFineOwners();
Expand Down
3 changes: 1 addition & 2 deletions src/components/Criteria/CriteriaFeeFineType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Col, Select } from '@folio/stripes/components';
import React, { useMemo } from 'react';
import { Field, useField } from 'react-final-form';
import { FormattedMessage, useIntl } from 'react-intl';
import useFeeFineOwners from '../../api/queries/useFeeFineOwners';
import useFeeFineTypes from '../../api/queries/useFeeFineTypes';
import { useFeeFineOwners, useFeeFineTypes } from '../../api/queries';

export default function CriteriaFeeFineType({ prefix }: Readonly<{ prefix: string }>) {
const feeFineOwners = useFeeFineOwners();
Expand Down
5 changes: 1 addition & 4 deletions src/components/Criteria/CriteriaLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { Col, Select } from '@folio/stripes/components';
import React, { useMemo } from 'react';
import { Field, useField } from 'react-final-form';
import { FormattedMessage } from 'react-intl';
import useCampuses from '../../api/queries/useCampuses';
import useInstitutions from '../../api/queries/useInstitutions';
import useLibraries from '../../api/queries/useLibraries';
import useLocations from '../../api/queries/useLocations';
import { useCampuses, useInstitutions, useLibraries, useLocations } from '../../api/queries';

export default function CriteriaLocation({ prefix }: Readonly<{ prefix: string }>) {
const institutions = useInstitutions();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Criteria/CriteriaPatronGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Col, Select } from '@folio/stripes/components';
import React, { useMemo } from 'react';
import { Field } from 'react-final-form';
import { FormattedMessage } from 'react-intl';
import usePatronGroups from '../../api/queries/usePatronGroups';
import { usePatronGroups } from '../../api/queries';

export default function CriteriaPatronGroup({ prefix }: Readonly<{ prefix: string }>) {
const patronGroups = usePatronGroups();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Criteria/CriteriaServicePoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Col, Select } from '@folio/stripes/components';
import React, { useMemo } from 'react';
import { Field } from 'react-final-form';
import { FormattedMessage } from 'react-intl';
import useServicePoints from '../../api/queries/useServicePoints';
import { useServicePoints } from '../../api/queries';

export default function CriteriaServicePoint({ prefix }: Readonly<{ prefix: string }>) {
const servicePoints = useServicePoints();
Expand Down
3 changes: 1 addition & 2 deletions src/components/TransferAccountFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Col, Row, Select } from '@folio/stripes/components';
import React, { useMemo } from 'react';
import { Field, useField } from 'react-final-form';
import { FormattedMessage } from 'react-intl';
import useFeeFineOwners from '../api/queries/useFeeFineOwners';
import useTransferAccounts from '../api/queries/useTransferAccounts';
import { useFeeFineOwners, useTransferAccounts } from '../api/queries';

export default function TransferAccountFields({ prefix }: Readonly<{ prefix: string }>) {
const feeFineOwners = useFeeFineOwners();
Expand Down
13 changes: 3 additions & 10 deletions src/hooks/useInitialValues.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ import { renderHook, waitFor } from '@folio/jest-config-stripes/testing-library/
import React from 'react';
import useInitialValues from './useInitialValues';
import withIntlConfiguration from '../../test/util/withIntlConfiguration';
import useFeeFineTypes from '../api/queries/useFeeFineTypes';
import useCurrentConfig from '../api/queries/useCurrentConfig';
import useLocations from '../api/queries/useLocations';
import useTransferAccounts from '../api/queries/useTransferAccounts';
import { useFeeFineTypes, useCurrentConfig, useLocations, useTransferAccounts } from '../api/queries';

jest.mock('../api/dto/from/dtoToFormValues', () => () => 'values');

jest.mock('../api/queries/useCurrentConfig');
jest.mock('../api/queries/useFeeFineTypes');
jest.mock('../api/queries/useLocations');
jest.mock('../api/queries/useTransferAccounts');
jest.mock('../api/dto/from', () => () => 'values');

jest.mock('../api/queries');
(useCurrentConfig as any).mockReturnValue({ isSuccess: false });
(useFeeFineTypes as any).mockReturnValue({ isSuccess: false });
(useLocations as any).mockReturnValue({ isSuccess: false });
Expand Down
7 changes: 2 additions & 5 deletions src/hooks/useInitialValues.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { useEffect, useState } from 'react';
import { useIntl } from 'react-intl';
import { useStripes } from '@folio/stripes/core';
import dtoToFormValues from '../api/dto/from/dtoToFormValues';
import useCurrentConfig from '../api/queries/useCurrentConfig';
import useFeeFineTypes from '../api/queries/useFeeFineTypes';
import useLocations from '../api/queries/useLocations';
import useTransferAccounts from '../api/queries/useTransferAccounts';
import dtoToFormValues from '../api/dto/from';
import { useCurrentConfig, useFeeFineTypes, useLocations, useTransferAccounts } from '../api/queries';
import FormValues from '../types/FormValues';
import useLocaleWeekdays from './useLocaleWeekdays';

Expand Down

0 comments on commit 3a2a72d

Please sign in to comment.