diff --git a/frontend/src/hooks/useHousing.tsx b/frontend/src/hooks/useHousing.tsx index 5e72e8253..deabe3a2d 100644 --- a/frontend/src/hooks/useHousing.tsx +++ b/frontend/src/hooks/useHousing.tsx @@ -1,9 +1,11 @@ +import _ from 'lodash'; import { useParams } from 'react-router-dom'; import { useMemo } from 'react'; +import { assert } from 'ts-essentials'; + import { useFindEventsByHousingQuery } from '../services/event.service'; import { useFindNotesByHousingQuery } from '../services/note.service'; import { useFindOwnersByHousingQuery } from '../services/owner.service'; -import _ from 'lodash'; import { useCampaignList } from './useCampaignList'; import { useCountHousingQuery, @@ -14,6 +16,7 @@ import { isDefined } from '../utils/compareUtils'; export function useHousing() { const { housingId } = useParams<{ housingId: string }>(); + assert(housingId !== undefined, 'housingId is undefined'); const { data: housing } = useGetHousingQuery(housingId); diff --git a/frontend/src/hooks/useOwner.tsx b/frontend/src/hooks/useOwner.tsx index a60f1a770..0061f6fb6 100644 --- a/frontend/src/hooks/useOwner.tsx +++ b/frontend/src/hooks/useOwner.tsx @@ -1,4 +1,6 @@ import { useParams } from 'react-router-dom'; +import { assert } from 'ts-essentials'; + import { useFindEventsByOwnerQuery } from '../services/event.service'; import { useGetOwnerQuery } from '../services/owner.service'; import { @@ -12,6 +14,7 @@ interface UseOwnerOptions { export function useOwner(options?: UseOwnerOptions) { const { ownerId } = useParams<{ ownerId: string }>(); + assert(ownerId !== undefined, 'ownerId is undefined'); const { data: owner } = useGetOwnerQuery(ownerId); diff --git a/frontend/src/utils/test/storeUtils.tsx b/frontend/src/utils/test/storeUtils.tsx index 3d9226d8c..8d865378b 100644 --- a/frontend/src/utils/test/storeUtils.tsx +++ b/frontend/src/utils/test/storeUtils.tsx @@ -7,19 +7,31 @@ interface TestStoreOptions { } function configureTestStore(opts?: TestStoreOptions) { - const preloadedState = opts?.withAuth - ? { - authentication: { authUser: genAuthUser() }, - } - : {}; - return configureStore({ reducer: applicationReducer, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ - serializableCheck: false, + serializableCheck: false }).concat(applicationMiddlewares), - preloadedState, + preloadedState: opts?.withAuth + ? { + authentication: { + logIn: { + data: genAuthUser(), + isError: false, + isLoading: false, + isSuccess: true, + isUninitialized: false + }, + changeEstablishment: { + isError: false, + isLoading: false, + isSuccess: false, + isUninitialized: true + } + } + } + : undefined }); }