diff --git a/src/taxonomy/tag-list/TagListTable.jsx b/src/taxonomy/tag-list/TagListTable.jsx index 0eeb5fe402..c131beb6ae 100644 --- a/src/taxonomy/tag-list/TagListTable.jsx +++ b/src/taxonomy/tag-list/TagListTable.jsx @@ -8,7 +8,7 @@ import Proptypes from 'prop-types'; import { useState } from 'react'; import messages from './messages'; -import { useTagListDataResponse, useTagListDataStatus } from './data/selectors'; +import { useTagListDataResponse, useTagListDataStatus } from './data/apiHooks'; const TagListTable = ({ taxonomyId }) => { const intl = useIntl(); diff --git a/src/taxonomy/tag-list/data/selectors.js b/src/taxonomy/tag-list/data/apiHooks.jsx similarity index 98% rename from src/taxonomy/tag-list/data/selectors.js rename to src/taxonomy/tag-list/data/apiHooks.jsx index 7f793f466c..eb4cd066d4 100644 --- a/src/taxonomy/tag-list/data/selectors.js +++ b/src/taxonomy/tag-list/data/apiHooks.jsx @@ -26,7 +26,6 @@ export const useTagListDataStatus = (taxonomyId, options) => { }; }; -// ToDo: fix types /** * @param {number} taxonomyId * @param {import("./types.mjs").QueryOptions} options diff --git a/src/taxonomy/tag-list/data/selectors.test.js b/src/taxonomy/tag-list/data/apiHooks.test.jsx similarity index 71% rename from src/taxonomy/tag-list/data/selectors.test.js rename to src/taxonomy/tag-list/data/apiHooks.test.jsx index 31a2450303..331d3a8ba6 100644 --- a/src/taxonomy/tag-list/data/selectors.test.js +++ b/src/taxonomy/tag-list/data/apiHooks.test.jsx @@ -1,13 +1,11 @@ +import { useQuery } from '@tanstack/react-query'; import { useTagListDataStatus, useTagListDataResponse, -} from './selectors'; -import { - useTagListData, -} from './api'; +} from './apiHooks'; -jest.mock('./api', () => ({ - useTagListData: jest.fn(), +jest.mock('@tanstack/react-query', () => ({ + useQuery: jest.fn(), })); describe('useTagListDataStatus', () => { @@ -20,7 +18,7 @@ describe('useTagListDataStatus', () => { isSuccess: true, }; - useTagListData.mockReturnValueOnce(status); + useQuery.mockReturnValueOnce(status); const result = useTagListDataStatus(0, {}); @@ -30,7 +28,7 @@ describe('useTagListDataStatus', () => { describe('useTagListDataResponse', () => { it('should return data when status is success', () => { - useTagListData.mockReturnValueOnce({ isSuccess: true, data: 'data' }); + useQuery.mockReturnValueOnce({ isSuccess: true, data: 'data' }); const result = useTagListDataResponse(0, {}); @@ -38,7 +36,7 @@ describe('useTagListDataResponse', () => { }); it('should return undefined when status is not success', () => { - useTagListData.mockReturnValueOnce({ isSuccess: false }); + useQuery.mockReturnValueOnce({ isSuccess: false }); const result = useTagListDataResponse(0, {}); diff --git a/src/taxonomy/taxonomy-detail/TaxonomyDetailPage.jsx b/src/taxonomy/taxonomy-detail/TaxonomyDetailPage.jsx index 6c39a0e23b..4c470c96ad 100644 --- a/src/taxonomy/taxonomy-detail/TaxonomyDetailPage.jsx +++ b/src/taxonomy/taxonomy-detail/TaxonomyDetailPage.jsx @@ -16,7 +16,7 @@ import TaxonomyDetailMenu from './TaxonomyDetailMenu'; import TaxonomyDetailSideCard from './TaxonomyDetailSideCard'; import { TagListTable } from '../tag-list'; import ExportModal from '../export-modal'; -import { useTaxonomyDetailDataResponse, useTaxonomyDetailDataStatus } from './data/selectors'; +import { useTaxonomyDetailDataResponse, useTaxonomyDetailDataStatus } from './data/apiHooks'; const TaxonomyDetailPage = () => { const intl = useIntl(); diff --git a/src/taxonomy/taxonomy-detail/data/selectors.js b/src/taxonomy/taxonomy-detail/data/apiHooks.jsx similarity index 100% rename from src/taxonomy/taxonomy-detail/data/selectors.js rename to src/taxonomy/taxonomy-detail/data/apiHooks.jsx diff --git a/src/taxonomy/taxonomy-detail/data/selectors.test.js b/src/taxonomy/taxonomy-detail/data/apiHooks.test.jsx similarity index 68% rename from src/taxonomy/taxonomy-detail/data/selectors.test.js rename to src/taxonomy/taxonomy-detail/data/apiHooks.test.jsx index 210afc40bf..e69232c363 100644 --- a/src/taxonomy/taxonomy-detail/data/selectors.test.js +++ b/src/taxonomy/taxonomy-detail/data/apiHooks.test.jsx @@ -1,14 +1,11 @@ -import { - useTaxonomyDetailData, -} from './api'; +import { useQuery } from '@tanstack/react-query'; import { useTaxonomyDetailDataStatus, useTaxonomyDetailDataResponse, -} from './selectors'; +} from './apiHooks'; -jest.mock('./api', () => ({ - __esModule: true, - useTaxonomyDetailData: jest.fn(), +jest.mock('@tanstack/react-query', () => ({ + useQuery: jest.fn(), })); describe('useTaxonomyDetailDataStatus', () => { @@ -20,7 +17,7 @@ describe('useTaxonomyDetailDataStatus', () => { isSuccess: true, }; - useTaxonomyDetailData.mockReturnValueOnce(status); + useQuery.mockReturnValueOnce(status); const result = useTaxonomyDetailDataStatus(0); @@ -30,7 +27,7 @@ describe('useTaxonomyDetailDataStatus', () => { describe('useTaxonomyDetailDataResponse', () => { it('should return data when status is success', () => { - useTaxonomyDetailData.mockReturnValueOnce({ isSuccess: true, data: 'data' }); + useQuery.mockReturnValueOnce({ isSuccess: true, data: 'data' }); const result = useTaxonomyDetailDataResponse(); @@ -38,7 +35,7 @@ describe('useTaxonomyDetailDataResponse', () => { }); it('should return undefined when status is not success', () => { - useTaxonomyDetailData.mockReturnValueOnce({ isSuccess: false }); + useQuery.mockReturnValueOnce({ isSuccess: false }); const result = useTaxonomyDetailDataResponse();