Skip to content

Commit

Permalink
test corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
devinleighsmith committed Oct 11, 2023
1 parent 8c76f0d commit 38f8cae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useKeycloak } from '@react-keycloak/web';
import axios from 'axios';
import axios, { AxiosResponse } from 'axios';
import { createMemoryHistory } from 'history';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';

import * as API from '@/constants/API';
import { useApiGeocoder } from '@/hooks/pims-api/useApiGeocoder';
import { IPagedItems, IProperty } from '@/interfaces';
import filterSlice from '@/store/slices/filter/filterSlice';
import { ILookupCode, lookupCodesSlice } from '@/store/slices/lookupCodes';
import { act, cleanup, fireEvent, render, waitFor } from '@/utils/test-utils';
Expand All @@ -18,6 +20,12 @@ const onFilterChange = jest.fn<void, [IPropertyFilter]>();
//prevent web calls from being made during tests.
jest.mock('axios');
jest.mock('@react-keycloak/web');
jest.mock('@/hooks/pims-api/useApiGeocoder');

const mockApiGetSitePidsApi = jest.fn<Promise<AxiosResponse<IPagedItems<IProperty>>>, any>();
(useApiGeocoder as unknown as jest.Mock<Partial<typeof useApiGeocoder>>).mockReturnValue({
getSitePidsApi: mockApiGetSitePidsApi,
});

const mockedAxios = axios as jest.Mocked<typeof axios>;
const mockKeycloak = (claims: string[]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createMemoryHistory } from 'history';

import * as API from '@/constants/API';
import Claims from '@/constants/claims';
import { useApiGeocoder } from '@/hooks/pims-api/useApiGeocoder';
import { useApiProperties } from '@/hooks/pims-api/useApiProperties';
import { IPagedItems, IProperty } from '@/interfaces';
import { mockParcel } from '@/mocks/filterData.mock';
Expand All @@ -23,6 +24,11 @@ const mockApiGetPropertiesPagedApi = jest.fn<Promise<AxiosResponse<IPagedItems<I
getPropertiesPagedApi: mockApiGetPropertiesPagedApi,
});

const mockApiGetSitePidsApi = jest.fn<Promise<AxiosResponse<IPagedItems<IProperty>>>, any>();
(useApiGeocoder as unknown as jest.Mock<Partial<typeof useApiGeocoder>>).mockReturnValue({
getSitePidsApi: mockApiGetSitePidsApi,
});

const mockAxios = new MockAdapter(axios);
const history = createMemoryHistory();

Expand Down

0 comments on commit 38f8cae

Please sign in to comment.