From 5d6d7af84216497cc193181f1917ec0a5f962af9 Mon Sep 17 00:00:00 2001 From: Xavier Le Cunff Date: Tue, 7 Jan 2025 11:54:44 +0100 Subject: [PATCH] fix: implement new created actions --- scripts/noUncheckedIndexedAccess_snapshot.txt | 5 ++-- .../modules/TrendsModule.native.test.tsx | 5 ---- .../home/components/modules/TrendsModule.tsx | 4 +-- .../modules/VenueListModule.native.test.tsx | 5 ---- .../components/modules/VenueListModule.tsx | 4 +-- .../identityCheck/api/useCreditActivation.ts | 2 +- .../VenueMapLocationModal.native.test.tsx | 17 ++++-------- .../components/VenueMapLocationModal.tsx | 8 +++--- .../useSearchResults.native.test.ts | 16 ++++-------- .../api/useSearchResults/useSearchResults.ts | 8 +++--- .../SearchListHeader.native.test.tsx | 6 ----- .../SearchResultsContent.native.test.tsx | 16 ++---------- .../SearchResultsContent.web.test.tsx | 6 ----- .../VenuePlaylist.native.test.tsx | 3 --- .../VenuePlaylist/VenuePlaylist.tsx | 4 +-- .../VenuePlaylist/VenuePlaylist.web.test.tsx | 5 ---- .../helpers/useSync/useSync.native.test.ts | 9 ------- .../SearchResults/SearchResults.web.test.tsx | 6 ----- ...ingleFilterBannerContainer.native.test.tsx | 9 +------ .../VenueMapBlock.native.test.tsx | 17 ++++-------- .../VenueMapBlock/VenueMapBlock.tsx | 8 +++--- .../VenueMapTypeFilter.native.test.tsx | 9 +------ .../VenueMapTypeFilter/VenueMapTypeFilter.tsx | 4 +-- .../VenueMapView/VenueMapView.native.test.tsx | 7 ++--- .../components/VenueMapView/VenueMapView.tsx | 4 +-- .../venueMap/hook/useVenueMapFilters.ts | 4 +-- .../hook/useVenuesMapData.native.test.ts | 13 ---------- .../venueMap/hook/useVenuesMapData.ts | 7 ++--- .../pages/VenueMap/VenueMap.native.test.tsx | 8 +----- .../venueMap/pages/VenueMap/VenueMapBase.tsx | 4 +-- .../VenueTypeModal.native.test.tsx | 7 +---- .../modals/VenueTypeModal/VenueTypeModal.tsx | 7 ++--- .../store/initialVenuesStore.native.test.ts | 8 ++---- .../store/selectedVenueStore.native.test.ts | 11 ++------ .../store/venueTypeCodeStore.native.test.ts | 12 +++------ .../store/venuesFilterStore.native.test.ts | 26 ++++++++----------- .../venueMap/store/venuesStore.native.test.ts | 9 +++---- .../venueMap/useGetAllVenues.native.test.ts | 3 --- src/features/venueMap/useGetAllVenues.ts | 4 +-- 39 files changed, 80 insertions(+), 230 deletions(-) diff --git a/scripts/noUncheckedIndexedAccess_snapshot.txt b/scripts/noUncheckedIndexedAccess_snapshot.txt index f538894c175..54a79de70f5 100644 --- a/scripts/noUncheckedIndexedAccess_snapshot.txt +++ b/scripts/noUncheckedIndexedAccess_snapshot.txt @@ -1,3 +1,4 @@ +$ grep --recursive --line-number ./src --regexp '// @ts-expect-error: because of noUncheckedIndexedAccess' | awk -F: '{print $1":"$2}' | sort ./src/cheatcodes/hooks/useSomeOfferId.ts:24 ./src/features/bookOffer/components/BookHourChoice.tsx:122 ./src/features/bookOffer/components/Calendar/useMarkedDates.native.test.ts:35 @@ -55,8 +56,8 @@ ./src/features/search/components/sections/Accessibility/Accessibility.tsx:33 ./src/features/search/pages/SuggestedPlacesOrVenues/SuggestedVenues.native.test.tsx:43 ./src/features/venue/components/OpeningHoursStatus/OpeningHoursStatus.native.test.tsx:68 -./src/features/venueMap/store/selectedVenueStore.native.test.ts:20 -./src/features/venueMap/store/selectedVenueStore.native.test.ts:31 +./src/features/venueMap/store/selectedVenueStore.native.test.ts:16 +./src/features/venueMap/store/selectedVenueStore.native.test.ts:26 ./src/libs/algolia/fetchAlgolia/buildAlgoliaParameters/getCategoriesFacetFilters.ts:26 ./src/libs/hooks/useShowReview.native.test.tsx:114 ./src/libs/hooks/useTimer.native.test.ts:34 diff --git a/src/features/home/components/modules/TrendsModule.native.test.tsx b/src/features/home/components/modules/TrendsModule.native.test.tsx index 339a865a395..567474bc284 100644 --- a/src/features/home/components/modules/TrendsModule.native.test.tsx +++ b/src/features/home/components/modules/TrendsModule.native.test.tsx @@ -35,11 +35,6 @@ jest.mock('libs/location', () => ({ })) const mockRemoveSelectedVenue = jest.fn() -jest.mock('features/venueMap/store/selectedVenueStore', () => ({ - useSelectedVenueActions: () => ({ - removeSelectedVenue: mockRemoveSelectedVenue, - }), -})) const mockShowModal = jest.fn() const useModalAPISpy = jest.spyOn(useModalAPI, 'useModal') diff --git a/src/features/home/components/modules/TrendsModule.tsx b/src/features/home/components/modules/TrendsModule.tsx index 6657d040beb..82be40219e3 100644 --- a/src/features/home/components/modules/TrendsModule.tsx +++ b/src/features/home/components/modules/TrendsModule.tsx @@ -6,7 +6,7 @@ import { Trend } from 'features/home/components/Trend' import { TrendBlock, TrendNavigationProps } from 'features/home/types' import { VenueMapLocationModal } from 'features/location/components/VenueMapLocationModal' import { useShouldDisplayVenueMap } from 'features/venueMap/hook/useShouldDisplayVenueMap' -import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { analytics } from 'libs/analytics' import { ContentTypes } from 'libs/contentful/types' import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag' @@ -34,7 +34,7 @@ export const TrendsModule = ({ index, moduleId, homeEntryId, items }: Trends) => visible: venueMapLocationModalVisible, hideModal: hideVenueMapLocationModal, } = useModal() - const { removeSelectedVenue } = useSelectedVenueActions() + const { removeSelectedVenue } = selectedVenueActions const isSmallScreen = width < 375 const shouldOpenMapDirectly = selectedLocationMode !== LocationMode.EVERYWHERE && !isWeb diff --git a/src/features/home/components/modules/VenueListModule.native.test.tsx b/src/features/home/components/modules/VenueListModule.native.test.tsx index a50972ccef7..41d31a7db80 100644 --- a/src/features/home/components/modules/VenueListModule.native.test.tsx +++ b/src/features/home/components/modules/VenueListModule.native.test.tsx @@ -35,11 +35,6 @@ jest.mock('libs/location', () => ({ useLocation: () => mockUseLocation(), })) const mockRemoveSelectedVenue = jest.fn() -jest.mock('features/venueMap/store/selectedVenueStore', () => ({ - useSelectedVenueActions: () => ({ - removeSelectedVenue: mockRemoveSelectedVenue, - }), -})) describe('', () => { it('should display venue list', () => { diff --git a/src/features/home/components/modules/VenueListModule.tsx b/src/features/home/components/modules/VenueListModule.tsx index ac31318f54a..002ac5012d3 100644 --- a/src/features/home/components/modules/VenueListModule.tsx +++ b/src/features/home/components/modules/VenueListModule.tsx @@ -4,7 +4,7 @@ import styled from 'styled-components/native' import { VenueListModuleItem } from 'features/home/components/modules/VenueListModuleItem' import { VenueMapLocationModal } from 'features/location/components/VenueMapLocationModal' -import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { VenueHit } from 'libs/algolia/types' import { analytics } from 'libs/analytics' import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag' @@ -25,7 +25,7 @@ type HeaderProps = { const ListHeaderComponent: FunctionComponent = ({ onPress }) => { const focusProps = useHandleFocus() - const { removeSelectedVenue } = useSelectedVenueActions() + const { removeSelectedVenue } = selectedVenueActions const handleOnBeforeNavigate = () => { removeSelectedVenue() diff --git a/src/features/identityCheck/api/useCreditActivation.ts b/src/features/identityCheck/api/useCreditActivation.ts index e249328b6b2..43c33155b47 100644 --- a/src/features/identityCheck/api/useCreditActivation.ts +++ b/src/features/identityCheck/api/useCreditActivation.ts @@ -9,7 +9,7 @@ const defaultState: CreditState = { activationDate: undefined, } -export const useCreditStore = createStore('credit', defaultState, { persist: true }) +const useCreditStore = createStore('credit', defaultState, { persist: true }) export const creditActions = createActions(useCreditStore, (set) => ({ setActivationDate: (date: Date) => set({ activationDate: date }), diff --git a/src/features/location/components/VenueMapLocationModal.native.test.tsx b/src/features/location/components/VenueMapLocationModal.native.test.tsx index f02958d1cc3..e8170840219 100644 --- a/src/features/location/components/VenueMapLocationModal.native.test.tsx +++ b/src/features/location/components/VenueMapLocationModal.native.test.tsx @@ -6,6 +6,7 @@ import { navigate } from '__mocks__/@react-navigation/native' import { SearchLocationModal } from 'features/location/components/SearchLocationModal' import { VenueMapLocationModal } from 'features/location/components/VenueMapLocationModal' import { DEFAULT_RADIUS } from 'features/search/constants' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { analytics } from 'libs/analytics' import { checkGeolocPermission, GeolocPermissionState, LocationWrapper } from 'libs/location' import { getGeolocPosition } from 'libs/location/geolocation/getGeolocPosition/getGeolocPosition' @@ -14,6 +15,7 @@ import { LocationMode } from 'libs/location/types' import { SuggestedPlace } from 'libs/place/types' import { MODAL_TO_HIDE_TIME, MODAL_TO_SHOW_TIME } from 'tests/constants' import { act, fireEvent, render, screen, userEvent, waitFor } from 'tests/utils' +// import * as selectedVenueModule from jest.useFakeTimers() @@ -62,18 +64,9 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => { } }) -const mockRemoveSelectedVenue = jest.fn() -jest.mock('features/venueMap/store/selectedVenueStore', () => ({ - useSelectedVenueActions: () => ({ - removeSelectedVenue: mockRemoveSelectedVenue, - }), -})) -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ - setInitialVenues: mockSetInitialVenues, - }), -})) +const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue') + +const mockSetInitialVenues = jest.spyOn(selectedVenueActions, 'setSelectedVenue') const user = userEvent.setup() jest.useFakeTimers() diff --git a/src/features/location/components/VenueMapLocationModal.tsx b/src/features/location/components/VenueMapLocationModal.tsx index 7cb1ca70f7a..3025f7f4e54 100644 --- a/src/features/location/components/VenueMapLocationModal.tsx +++ b/src/features/location/components/VenueMapLocationModal.tsx @@ -8,8 +8,8 @@ import { useLocationSubmit } from 'features/location/helpers/useLocationSubmit' import { usePlaceSelection } from 'features/location/helpers/usePlaceSelection' import { useRadiusChange } from 'features/location/helpers/useRadiusChange' import { Referrals, UseNavigationType } from 'features/navigation/RootNavigator/types' -import { useInitialVenuesActions } from 'features/venueMap/store/initialVenuesStore' -import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore' +import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { analytics } from 'libs/analytics' import { LocationMode } from 'libs/location/types' @@ -69,8 +69,8 @@ export const VenueMapLocationModal = ({ ...locationSubmitProps, }) - const { removeSelectedVenue } = useSelectedVenueActions() - const { setInitialVenues } = useInitialVenuesActions() + const { removeSelectedVenue } = selectedVenueActions + const { setInitialVenues } = initialVenuesActions useEffect(() => { setInitialVenues([]) diff --git a/src/features/search/api/useSearchResults/useSearchResults.native.test.ts b/src/features/search/api/useSearchResults/useSearchResults.native.test.ts index 8774f2da317..441a8451272 100644 --- a/src/features/search/api/useSearchResults/useSearchResults.native.test.ts +++ b/src/features/search/api/useSearchResults/useSearchResults.native.test.ts @@ -6,6 +6,8 @@ import { defaultDisabilitiesProperties } from 'features/accessibility/context/Ac import { useSearchInfiniteQuery } from 'features/search/api/useSearchResults/useSearchResults' import { Action, initialSearchState } from 'features/search/context/reducer' import { SearchState } from 'features/search/types' +import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import * as doAlgoliaRedirect from 'libs/algolia/doAlgoliaRedirect' import { offerAttributesToRetrieve } from 'libs/algolia/fetchAlgolia/buildAlgoliaParameters/offerAttributesToRetrieve' import * as fetchSearchResults from 'libs/algolia/fetchAlgolia/fetchSearchResults/fetchSearchResults' @@ -41,17 +43,9 @@ jest.mock('libs/location/LocationWrapper', () => ({ useLocation: () => mockUseLocation(), })) -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }), - useInitialVenues: jest.fn(), -})) -const mockRemoveSelectedVenue = jest.fn() -jest.mock('features/venueMap/store/selectedVenueStore', () => ({ - useSelectedVenueActions: () => ({ - removeSelectedVenue: mockRemoveSelectedVenue, - }), -})) +const mockSetInitialVenues = jest.spyOn(initialVenuesActions, 'setInitialVenues') + +const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue') const mockDispatch = jest.fn() const mockFetchSearchResultsResponse = { diff --git a/src/features/search/api/useSearchResults/useSearchResults.ts b/src/features/search/api/useSearchResults/useSearchResults.ts index 7fead1d1a2c..ad6aaaef7ef 100644 --- a/src/features/search/api/useSearchResults/useSearchResults.ts +++ b/src/features/search/api/useSearchResults/useSearchResults.ts @@ -10,8 +10,8 @@ import { useSearch } from 'features/search/context/SearchWrapper' import { useNavigateToSearch } from 'features/search/helpers/useNavigateToSearch/useNavigateToSearch' import { SearchState } from 'features/search/types' import { Venue } from 'features/venue/types' -import { useInitialVenuesActions } from 'features/venueMap/store/initialVenuesStore' -import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore' +import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { useSearchAnalyticsState } from 'libs/algolia/analytics/SearchAnalyticsWrapper' import { doAlgoliaRedirect } from 'libs/algolia/doAlgoliaRedirect' import { fetchSearchResults } from 'libs/algolia/fetchAlgolia/fetchSearchResults/fetchSearchResults' @@ -43,8 +43,8 @@ export const useSearchInfiniteQuery = (searchState: SearchState, dispatch: Dispa const transformHits = useTransformOfferHits() const { setCurrentQueryID } = useSearchAnalyticsState() const previousPageObjectIds = useRef([]) - const { setInitialVenues } = useInitialVenuesActions() - const { removeSelectedVenue } = useSelectedVenueActions() + const { setInitialVenues } = initialVenuesActions + const { removeSelectedVenue } = selectedVenueActions const { replaceToSearch: navigateToThematicSearch } = useNavigateToSearch('ThematicSearch') const { aroundPrecision } = useRemoteConfigContext() diff --git a/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx b/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx index cc6774b053f..2737549674c 100644 --- a/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx +++ b/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx @@ -77,12 +77,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({ useSearch: () => mockUseSearch(), })) -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }), - useInitialVenues: jest.fn(), -})) - jest.mock('@shopify/flash-list', () => { const ActualFlashList = jest.requireActual('@shopify/flash-list').FlashList class MockFlashList extends ActualFlashList { diff --git a/src/features/search/components/SearchResultsContent/SearchResultsContent.native.test.tsx b/src/features/search/components/SearchResultsContent/SearchResultsContent.native.test.tsx index 61e63999a2a..9f73452418c 100644 --- a/src/features/search/components/SearchResultsContent/SearchResultsContent.native.test.tsx +++ b/src/features/search/components/SearchResultsContent/SearchResultsContent.native.test.tsx @@ -10,6 +10,7 @@ import { SearchResultsContent } from 'features/search/components/SearchResultsCo import { initialSearchState } from 'features/search/context/reducer' import { MAX_RADIUS } from 'features/search/helpers/reducer.helpers' import { SearchState, UserData } from 'features/search/types' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { useGetAllVenues } from 'features/venueMap/useGetAllVenues' import { beneficiaryUser, nonBeneficiaryUser } from 'fixtures/user' import { venuesFixture } from 'libs/algolia/fetchAlgolia/fetchVenues/fixtures/venuesFixture' @@ -41,12 +42,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({ jest.mock('features/venueMap/useGetAllVenues') const mockUseGetAllVenues = useGetAllVenues as jest.Mock -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }), - useInitialVenues: jest.fn(), -})) - jest.mock('features/venueMap/helpers/zoomOutIfMapEmpty') jest.mock('features/accessibility/context/AccessibilityFiltersWrapper') @@ -174,14 +169,7 @@ jest.mock('libs/location/LocationWrapper', () => ({ useLocation: () => mockUseLocation(), })) -const mockRemoveSelectedVenue = jest.fn() -jest.mock('features/venueMap/store/selectedVenueStore', () => ({ - useSelectedVenueActions: () => ({ - removeSelectedVenue: mockRemoveSelectedVenue, - setSelectedVenue: jest.fn(), - }), - useSelectedVenue: jest.fn(), -})) +const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue') jest.mock('libs/subcategories/useSubcategories') diff --git a/src/features/search/components/SearchResultsContent/SearchResultsContent.web.test.tsx b/src/features/search/components/SearchResultsContent/SearchResultsContent.web.test.tsx index fd45eb10cfd..9ee745227d1 100644 --- a/src/features/search/components/SearchResultsContent/SearchResultsContent.web.test.tsx +++ b/src/features/search/components/SearchResultsContent/SearchResultsContent.web.test.tsx @@ -74,12 +74,6 @@ jest.mock('features/location/helpers/useLocationState', () => ({ }), })) -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }), - useInitialVenues: jest.fn(), -})) - jest.mock('features/venueMap/useGetAllVenues') const mockUseGetAllVenues = useGetAllVenues as jest.Mock diff --git a/src/features/search/components/VenuePlaylist/VenuePlaylist.native.test.tsx b/src/features/search/components/VenuePlaylist/VenuePlaylist.native.test.tsx index 95c380b4ca5..d4aecbe1d08 100644 --- a/src/features/search/components/VenuePlaylist/VenuePlaylist.native.test.tsx +++ b/src/features/search/components/VenuePlaylist/VenuePlaylist.native.test.tsx @@ -21,9 +21,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({ })) const mockSetVenueTypeCode = jest.fn() -jest.mock('features/venueMap/store/venueTypeCodeStore', () => ({ - useVenueTypeCodeActions: () => ({ setVenueTypeCode: mockSetVenueTypeCode }), -})) const user = userEvent.setup() diff --git a/src/features/search/components/VenuePlaylist/VenuePlaylist.tsx b/src/features/search/components/VenuePlaylist/VenuePlaylist.tsx index afd6822ecfd..36cf76428f2 100644 --- a/src/features/search/components/VenuePlaylist/VenuePlaylist.tsx +++ b/src/features/search/components/VenuePlaylist/VenuePlaylist.tsx @@ -10,7 +10,7 @@ import { SearchStackParamList } from 'features/navigation/SearchStackNavigator/t import { NumberOfResults } from 'features/search/components/NumberOfResults/NumberOfResults' import { SearchVenueItem } from 'features/search/components/SearchVenueItems/SearchVenueItem' import { useSearch } from 'features/search/context/SearchWrapper' -import { useVenueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore' +import { venueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore' import { AlgoliaVenue } from 'libs/algolia/types' import { analytics } from 'libs/analytics' import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag' @@ -60,7 +60,7 @@ export const VenuePlaylist: React.FC = ({ shouldDisplaySeparator = true, }) => { const { navigate } = useNavigation() - const { setVenueTypeCode } = useVenueTypeCodeActions() + const { setVenueTypeCode } = venueTypeCodeActions const { searchState: { searchId }, } = useSearch() diff --git a/src/features/search/components/VenuePlaylist/VenuePlaylist.web.test.tsx b/src/features/search/components/VenuePlaylist/VenuePlaylist.web.test.tsx index ef7a81b0ba6..7fc847406a0 100644 --- a/src/features/search/components/VenuePlaylist/VenuePlaylist.web.test.tsx +++ b/src/features/search/components/VenuePlaylist/VenuePlaylist.web.test.tsx @@ -16,11 +16,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({ useSearch: () => mockUseSearch(), })) -const mockSetVenueTypeCode = jest.fn() -jest.mock('features/venueMap/store/venueTypeCodeStore', () => ({ - useVenueTypeCodeActions: () => ({ setVenueTypeCode: mockSetVenueTypeCode }), -})) - jest.mock('react-native-safe-area-context', () => ({ ...(jest.requireActual('react-native-safe-area-context') as Record), useSafeAreaInsets: () => ({ bottom: 16, right: 16, left: 16, top: 16 }), diff --git a/src/features/search/helpers/useSync/useSync.native.test.ts b/src/features/search/helpers/useSync/useSync.native.test.ts index c8fe5693e27..6e60ba713f7 100644 --- a/src/features/search/helpers/useSync/useSync.native.test.ts +++ b/src/features/search/helpers/useSync/useSync.native.test.ts @@ -73,15 +73,6 @@ jest.mock('libs/location/LocationWrapper', () => ({ })) mockUseLocation.mockReturnValue(everywhereUseLocation) -const mockRemoveSelectedVenue = jest.fn() -jest.mock('features/venueMap/store/selectedVenueStore', () => ({ - useSelectedVenueActions: () => ({ - removeSelectedVenue: mockRemoveSelectedVenue, - setSelectedVenue: jest.fn(), - }), - useSelectedVenue: jest.fn(), -})) - // eslint-disable-next-line jest/no-disabled-tests describe.skip('useSync', () => { it('should update search state with locationType params when user has geolocPosition', async () => { diff --git a/src/features/search/pages/SearchResults/SearchResults.web.test.tsx b/src/features/search/pages/SearchResults/SearchResults.web.test.tsx index ef0f815fde4..e68925186b6 100644 --- a/src/features/search/pages/SearchResults/SearchResults.web.test.tsx +++ b/src/features/search/pages/SearchResults/SearchResults.web.test.tsx @@ -71,12 +71,6 @@ jest.mock('uuid', () => ({ jest.mock('libs/firebase/analytics/analytics') jest.mock('libs/firebase/remoteConfig/remoteConfig.services') -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }), - useInitialVenues: jest.fn(), -})) - jest.mock('features/venueMap/useGetAllVenues') const mockUseGetAllVenues = useGetAllVenues as jest.Mock diff --git a/src/features/venueMap/components/FilterBannerContainer/SingleFilterBannerContainer.native.test.tsx b/src/features/venueMap/components/FilterBannerContainer/SingleFilterBannerContainer.native.test.tsx index 740a8017b9f..d3aa973e5d7 100644 --- a/src/features/venueMap/components/FilterBannerContainer/SingleFilterBannerContainer.native.test.tsx +++ b/src/features/venueMap/components/FilterBannerContainer/SingleFilterBannerContainer.native.test.tsx @@ -1,10 +1,7 @@ import React from 'react' import { VenueTypeCodeKey } from 'api/gen' -import { - useVenueTypeCode, - useVenueTypeCodeActions, -} from 'features/venueMap/store/venueTypeCodeStore' +import { useVenueTypeCode } from 'features/venueMap/store/venueTypeCodeStore' import { parseType } from 'libs/parsers/venueType' import { ellipseString } from 'shared/string/ellipseString' import { render, screen } from 'tests/utils' @@ -12,11 +9,7 @@ import { render, screen } from 'tests/utils' import { SingleFilterBannerContainer } from './SingleFilterBannerContainer' jest.mock('features/venueMap/store/venueTypeCodeStore') -const mockSetVenueTypeCode = jest.fn() const mockUseVenueTypeCode = useVenueTypeCode as jest.Mock -const mockUseVenueTypeCodeActions = useVenueTypeCodeActions as jest.Mock - -mockUseVenueTypeCodeActions.mockReturnValue({ setVenueTypeCode: mockSetVenueTypeCode }) const VENUE_TYPE = VenueTypeCodeKey.MOVIE diff --git a/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.native.test.tsx b/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.native.test.tsx index 2734af716f2..f548dde2343 100644 --- a/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.native.test.tsx +++ b/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.native.test.tsx @@ -2,23 +2,16 @@ import React from 'react' import { navigate } from '__mocks__/@react-navigation/native' import { VenueMapBlock } from 'features/venueMap/components/VenueMapBlock/VenueMapBlock' +import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { analytics } from 'libs/analytics' import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags' import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types' import { fireEvent, render, screen, waitFor } from 'tests/utils' -const mockRemoveSelectedVenue = jest.fn() -jest.mock('features/venueMap/store/selectedVenueStore', () => ({ - useSelectedVenueActions: () => ({ - removeSelectedVenue: mockRemoveSelectedVenue, - }), -})) -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ - setInitialVenues: mockSetInitialVenues, - }), -})) +const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue') + +const mockSetInitialVenues = jest.spyOn(initialVenuesActions, 'setInitialVenues') describe('', () => { describe('When wipAppV2VenueMapBlock feature flag activated', () => { diff --git a/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.tsx b/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.tsx index 54e72586380..605a08797ae 100644 --- a/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.tsx +++ b/src/features/venueMap/components/VenueMapBlock/VenueMapBlock.tsx @@ -6,8 +6,8 @@ import styled from 'styled-components/native' import { Referrals } from 'features/navigation/RootNavigator/types' import { VENUE_MAP_BACKGROUND } from 'features/venueMap/components/VenueMapBlock/VenueMapBackground' import { VENUE_MAP_BACKGROUND_APP_V2 } from 'features/venueMap/components/VenueMapBlock/VenueMapBackgroundAppV2' -import { useInitialVenuesActions } from 'features/venueMap/store/initialVenuesStore' -import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore' +import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore' +import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore' import { analytics } from 'libs/analytics' import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag' import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types' @@ -28,8 +28,8 @@ export const VenueMapBlock: FunctionComponent = ({ onPress, from }) => { const enableAppV2VenueMapBlock = useFeatureFlag( RemoteStoreFeatureFlags.WIP_APP_V2_VENUE_MAP_BLOCK ) - const { removeSelectedVenue } = useSelectedVenueActions() - const { setInitialVenues } = useInitialVenuesActions() + const { removeSelectedVenue } = selectedVenueActions + const { setInitialVenues } = initialVenuesActions const TouchableContainer = onPress ? StyledTouchable : StyledInternalTouchableLink diff --git a/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.native.test.tsx b/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.native.test.tsx index 81565059126..90dd8b18fd3 100644 --- a/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.native.test.tsx +++ b/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.native.test.tsx @@ -6,7 +6,7 @@ import { VenueTypeCodeKey } from 'api/gen' import { VenueMapFiltersModalStackParamList } from 'features/navigation/VenueMapFiltersStackNavigator/types' import { VenueMapTypeFilter } from 'features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter' import { FILTERS_VENUE_TYPE_MAPPING } from 'features/venueMap/constant' -import { useVenuesFilter, useVenuesFilterActions } from 'features/venueMap/store/venuesFilterStore' +import { useVenuesFilter } from 'features/venueMap/store/venuesFilterStore' import { render, screen, userEvent } from 'tests/utils' const mockGoBack = jest.fn() @@ -40,13 +40,6 @@ mockUseVenuesFilter.mockReturnValue([]) const mockAddVenuesFilters = jest.fn() const mockRemoveVenuesFilters = jest.fn() -const mockSetVenuesFilters = jest.fn() -const mockUseVenuesFilterActions = useVenuesFilterActions as jest.Mock -mockUseVenuesFilterActions.mockReturnValue({ - addVenuesFilters: mockAddVenuesFilters, - removeVenuesFilters: mockRemoveVenuesFilters, - setVenuesFilters: mockSetVenuesFilters, -}) const user = userEvent.setup() diff --git a/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.tsx b/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.tsx index 4145052b28b..8dc7668dc1e 100644 --- a/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.tsx +++ b/src/features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter.tsx @@ -8,7 +8,7 @@ import { UseNavigationType } from 'features/navigation/RootNavigator/types' import { VenueMapFiltersModalStackParamList } from 'features/navigation/VenueMapFiltersStackNavigator/types' import { FILTERS_VENUE_TYPE_MAPPING } from 'features/venueMap/constant' import { VenueMapFiltersModal } from 'features/venueMap/pages/modals/VenueMapFiltersModal/VenueMapFiltersModal' -import { useVenuesFilterActions } from 'features/venueMap/store/venuesFilterStore' +import { venuesFilterActions } from 'features/venueMap/store/venuesFilterStore' import { MAP_VENUE_TYPE_TO_LABEL, VenueTypeCode } from 'libs/parsers/venueType' import { theme } from 'theme' import { Checkbox } from 'ui/components/inputs/Checkbox/Checkbox' @@ -38,7 +38,7 @@ export const VenueMapTypeFilter: FunctionComponent = ({ navigation, route const { title, filterGroup } = route.params const { navigate } = useNavigation() const { activeFilters: venueFilters, toggleMacroFilter } = useVenueMapFilters() - const { addVenuesFilters, removeVenuesFilters } = useVenuesFilterActions() + const { addVenuesFilters, removeVenuesFilters } = venuesFilterActions const hasAllFilters = FILTERS_VENUE_TYPE_MAPPING[filterGroup].every((filter) => venueFilters.includes(filter) diff --git a/src/features/venueMap/components/VenueMapView/VenueMapView.native.test.tsx b/src/features/venueMap/components/VenueMapView/VenueMapView.native.test.tsx index c4ee51fbfbd..6033616b5c4 100644 --- a/src/features/venueMap/components/VenueMapView/VenueMapView.native.test.tsx +++ b/src/features/venueMap/components/VenueMapView/VenueMapView.native.test.tsx @@ -12,6 +12,7 @@ import { GeolocatedVenue } from 'features/venueMap/components/VenueMapView/types import { VenueMapView } from 'features/venueMap/components/VenueMapView/VenueMapView' import { useCenterOnLocation } from 'features/venueMap/hook/useCenterOnLocation' import * as useVenueMapFilters from 'features/venueMap/hook/useVenueMapFilters' +import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore' import { useGetAllVenues } from 'features/venueMap/useGetAllVenues' import { venuesFixture } from 'libs/algolia/fetchAlgolia/fetchVenues/fixtures/venuesFixture' import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags' @@ -22,11 +23,7 @@ import { act, fireEvent, render, screen, userEvent, waitFor } from 'tests/utils' import * as constants from '../../constant' -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }), - useInitialVenues: jest.fn(), -})) +const mockSetInitialVenues = jest.spyOn(initialVenuesActions, 'setInitialVenues') const mockNavigate = jest.fn() jest.mock('@react-navigation/native', () => ({ diff --git a/src/features/venueMap/components/VenueMapView/VenueMapView.tsx b/src/features/venueMap/components/VenueMapView/VenueMapView.tsx index 9f38355270f..6661175f379 100644 --- a/src/features/venueMap/components/VenueMapView/VenueMapView.tsx +++ b/src/features/venueMap/components/VenueMapView/VenueMapView.tsx @@ -24,7 +24,7 @@ import { useGetDefaultRegion } from 'features/venueMap/hook/useGetDefaultRegion' import { useTrackMapSeenDuration } from 'features/venueMap/hook/useTrackMapSeenDuration' import { useTrackMapSessionDuration } from 'features/venueMap/hook/useTrackMapSessionDuration' import { useVenueMapFilters } from 'features/venueMap/hook/useVenueMapFilters' -import { useInitialVenuesActions } from 'features/venueMap/store/initialVenuesStore' +import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore' import { analytics } from 'libs/analytics' import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag' import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types' @@ -74,7 +74,7 @@ export const VenueMapView: FunctionComponent = ({ const { tabBarHeight } = useCustomSafeInsets() const { bottom } = useSafeAreaInsets() - const { setInitialVenues } = useInitialVenuesActions() + const { setInitialVenues } = initialVenuesActions const isPreviewEnabled = useFeatureFlag(RemoteStoreFeatureFlags.WIP_VENUE_MAP) const shouldDisplayPinV2 = useFeatureFlag(RemoteStoreFeatureFlags.WIP_VENUE_MAP_PIN_V2) const shouldNavigateToVenueOnFling = useFeatureFlag( diff --git a/src/features/venueMap/hook/useVenueMapFilters.ts b/src/features/venueMap/hook/useVenueMapFilters.ts index 34a66d86c83..e94b978471b 100644 --- a/src/features/venueMap/hook/useVenueMapFilters.ts +++ b/src/features/venueMap/hook/useVenueMapFilters.ts @@ -3,11 +3,11 @@ import { getActiveMacroFilters, getFiltersByMacro, } from 'features/venueMap/helpers/filtersVenueType/filtersVenueType' -import { useVenuesFilter, useVenuesFilterActions } from 'features/venueMap/store/venuesFilterStore' +import { useVenuesFilter, venuesFilterActions } from 'features/venueMap/store/venuesFilterStore' export const useVenueMapFilters = () => { const activeFilters = useVenuesFilter() - const { setVenuesFilters, addVenuesFilters, removeVenuesFilters } = useVenuesFilterActions() + const { setVenuesFilters, addVenuesFilters, removeVenuesFilters } = venuesFilterActions const addMacroFilter = (macro: keyof typeof FILTERS_VENUE_TYPE_MAPPING) => { const filters = getFiltersByMacro(macro) diff --git a/src/features/venueMap/hook/useVenuesMapData.native.test.ts b/src/features/venueMap/hook/useVenuesMapData.native.test.ts index 99649ac5f8f..50cb83e13c8 100644 --- a/src/features/venueMap/hook/useVenuesMapData.native.test.ts +++ b/src/features/venueMap/hook/useVenuesMapData.native.test.ts @@ -1,26 +1,13 @@ import { VenueTypeCodeKey } from 'api/gen' import { Venue } from 'features/venue/types' import { useVenuesMapData } from 'features/venueMap/hook/useVenuesMapData' -import { useVenuesActions } from 'features/venueMap/store/venuesStore' -import { useVenueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore' import { venuesFixture } from 'libs/algolia/fetchAlgolia/fetchVenues/fixtures/venuesFixture' import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC' import { renderHook } from 'tests/utils' -const mockSetInitialVenues = jest.fn() -jest.mock('features/venueMap/store/initialVenuesStore', () => ({ - useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }), - useInitialVenues: jest.fn(), -})) - jest.mock('features/venueMap/store/venueTypeCodeStore') -const mockUseVenueTypeCodeActions = useVenueTypeCodeActions as jest.Mock -mockUseVenueTypeCodeActions.mockReturnValue({ setVenueTypeCode: jest.fn() }) -const mockSetVenues = jest.fn() jest.mock('features/venueMap/store/venuesStore') -const mockUseVenuesActions = useVenuesActions as jest.MockedFunction -mockUseVenuesActions.mockReturnValue({ setVenues: mockSetVenues }) describe('useVenuesMapData', () => { it('should return default values without transformVenues', () => { diff --git a/src/features/venueMap/hook/useVenuesMapData.ts b/src/features/venueMap/hook/useVenuesMapData.ts index 4085f6ae362..919d4e453bf 100644 --- a/src/features/venueMap/hook/useVenuesMapData.ts +++ b/src/features/venueMap/hook/useVenuesMapData.ts @@ -3,16 +3,13 @@ import { useState } from 'react' import { Venue } from 'features/venue/types' import { useGetDefaultRegion } from 'features/venueMap/hook/useGetDefaultRegion' import { useGetVenuesInRegion } from 'features/venueMap/hook/useGetVenuesInRegion' -import { - useSelectedVenue, - useSelectedVenueActions, -} from 'features/venueMap/store/selectedVenueStore' +import { selectedVenueActions, useSelectedVenue } from 'features/venueMap/store/selectedVenueStore' import { useVenueTypeCode } from 'features/venueMap/store/venueTypeCodeStore' export const useVenuesMapData = (initialVenues: Venue[]) => { const selectedVenue = useSelectedVenue() const venueTypeCode = useVenueTypeCode() - const { setSelectedVenue, removeSelectedVenue } = useSelectedVenueActions() + const { setSelectedVenue, removeSelectedVenue } = selectedVenueActions const defaultRegion = useGetDefaultRegion() const [currentRegion, setCurrentRegion] = useState(defaultRegion) const [lastRegionSearched, setLastRegionSearched] = useState(defaultRegion) diff --git a/src/features/venueMap/pages/VenueMap/VenueMap.native.test.tsx b/src/features/venueMap/pages/VenueMap/VenueMap.native.test.tsx index e267b79ad1d..7c68166a7f9 100644 --- a/src/features/venueMap/pages/VenueMap/VenueMap.native.test.tsx +++ b/src/features/venueMap/pages/VenueMap/VenueMap.native.test.tsx @@ -4,10 +4,7 @@ import { VenueTypeCodeKey } from 'api/gen' import * as useGoBack from 'features/navigation/useGoBack' import { FILTERS_VENUE_TYPE_MAPPING } from 'features/venueMap/constant' import { VenueMap } from 'features/venueMap/pages/VenueMap/VenueMap' -import { - useVenueTypeCodeActions, - useVenueTypeCode, -} from 'features/venueMap/store/venueTypeCodeStore' +import { useVenueTypeCode } from 'features/venueMap/store/venueTypeCodeStore' import * as useFeatureFlag from 'libs/firebase/firestore/featureFlags/useFeatureFlag' import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC' import { fireEvent, render, screen } from 'tests/utils' @@ -24,9 +21,6 @@ jest.spyOn(useGoBack, 'useGoBack').mockReturnValue({ jest.mock('features/venueMap/store/venueTypeCodeStore') const mockSetVenueTypeCode = jest.fn() const mockUseVenueTypeCode = useVenueTypeCode as jest.Mock -const mockUseVenueTypeCodeActions = useVenueTypeCodeActions as jest.Mock - -mockUseVenueTypeCodeActions.mockReturnValue({ setVenueTypeCode: mockSetVenueTypeCode }) jest.mock('@gorhom/bottom-sheet', () => { const ActualBottomSheet = jest.requireActual('@gorhom/bottom-sheet/mock').default diff --git a/src/features/venueMap/pages/VenueMap/VenueMapBase.tsx b/src/features/venueMap/pages/VenueMap/VenueMapBase.tsx index 6a848fe4c98..84a1d70feb2 100644 --- a/src/features/venueMap/pages/VenueMap/VenueMapBase.tsx +++ b/src/features/venueMap/pages/VenueMap/VenueMapBase.tsx @@ -4,12 +4,12 @@ import styled from 'styled-components/native' import { getSearchStackConfig } from 'features/navigation/SearchStackNavigator/helpers' import { useGoBack } from 'features/navigation/useGoBack' import { FilterBannerContainer } from 'features/venueMap/components/FilterBannerContainer/FilterBannerContainer' -import { useVenueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore' +import { venueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore' import { PageHeaderWithoutPlaceholder } from 'ui/components/headers/PageHeaderWithoutPlaceholder' export const VenueMapBase: FunctionComponent = ({ children }) => { const { goBack } = useGoBack(...getSearchStackConfig('SearchLanding')) - const { setVenueTypeCode } = useVenueTypeCodeActions() + const { setVenueTypeCode } = venueTypeCodeActions const handleGoBack = () => { setVenueTypeCode(null) diff --git a/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.native.test.tsx b/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.native.test.tsx index 247114e3cab..12d97210b9e 100644 --- a/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.native.test.tsx +++ b/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.native.test.tsx @@ -3,10 +3,7 @@ import React from 'react' import { VenueTypeCodeKey } from 'api/gen' import { VenueTypeModal } from 'features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal' import { useVenues } from 'features/venueMap/store/venuesStore' -import { - useVenueTypeCode, - useVenueTypeCodeActions, -} from 'features/venueMap/store/venueTypeCodeStore' +import { useVenueTypeCode } from 'features/venueMap/store/venueTypeCodeStore' import { venuesFixture } from 'libs/algolia/fetchAlgolia/fetchVenues/fixtures/venuesFixture' import { analytics } from 'libs/analytics' import { act, fireEvent, render, screen, waitFor } from 'tests/utils' @@ -16,8 +13,6 @@ const mockHideModal = jest.fn() jest.mock('features/venueMap/store/venueTypeCodeStore') const mockUseVenueTypeCode = useVenueTypeCode as jest.Mock const mockSetVenueTypeCode = jest.fn() -const mockUseVenueTypeCodeActions = useVenueTypeCodeActions as jest.Mock -mockUseVenueTypeCodeActions.mockReturnValue({ setVenueTypeCode: mockSetVenueTypeCode }) jest.mock('features/venueMap/store/venuesStore') const mockUseVenues = useVenues as jest.Mock diff --git a/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.tsx b/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.tsx index 942bfad9332..b3047ef0b36 100644 --- a/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.tsx +++ b/src/features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal.tsx @@ -13,10 +13,7 @@ import { getVenueTypeLabel } from 'features/venueMap/helpers/getVenueTypeLabel/g import { venueTypesMapping } from 'features/venueMap/helpers/venueTypesMapping/venueTypesMapping' import { useSelectedVenue } from 'features/venueMap/store/selectedVenueStore' import { useVenues } from 'features/venueMap/store/venuesStore' -import { - useVenueTypeCode, - useVenueTypeCodeActions, -} from 'features/venueMap/store/venueTypeCodeStore' +import { useVenueTypeCode, venueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore' import { analytics } from 'libs/analytics' import { MAP_VENUE_TYPE_TO_LABEL, VenueTypeCode } from 'libs/parsers/venueType' import { Form } from 'ui/components/Form' @@ -46,7 +43,7 @@ export const VenueTypeModal: FunctionComponent = ({ hideModal, isVisible const venues = useVenues() const selectedVenue = useSelectedVenue() const defaultVenueTypeCode = useVenueTypeCode() - const { setVenueTypeCode } = useVenueTypeCodeActions() + const { setVenueTypeCode } = venueTypeCodeActions const { formState: { isSubmitting }, diff --git a/src/features/venueMap/store/initialVenuesStore.native.test.ts b/src/features/venueMap/store/initialVenuesStore.native.test.ts index a76c3d64416..8e569628645 100644 --- a/src/features/venueMap/store/initialVenuesStore.native.test.ts +++ b/src/features/venueMap/store/initialVenuesStore.native.test.ts @@ -1,7 +1,4 @@ -import { - useInitialVenues, - useInitialVenuesActions, -} from 'features/venueMap/store/initialVenuesStore' +import { initialVenuesActions, useInitialVenues } from 'features/venueMap/store/initialVenuesStore' import { geolocatedVenuesFixture } from 'fixtures/geolocatedVenues' import { act, renderHook } from 'tests/utils' @@ -14,10 +11,9 @@ describe('initialVenuesStore', () => { it('should handle setInitialVenues', async () => { const { result: venues } = renderHook(useInitialVenues) - const { result: actions } = renderHook(useInitialVenuesActions) await act(async () => { - actions.current.setInitialVenues(geolocatedVenuesFixture) + initialVenuesActions.setInitialVenues(geolocatedVenuesFixture) }) expect(venues.current).toEqual(geolocatedVenuesFixture) diff --git a/src/features/venueMap/store/selectedVenueStore.native.test.ts b/src/features/venueMap/store/selectedVenueStore.native.test.ts index 4f9a22b2b16..9dbda2926c3 100644 --- a/src/features/venueMap/store/selectedVenueStore.native.test.ts +++ b/src/features/venueMap/store/selectedVenueStore.native.test.ts @@ -1,7 +1,4 @@ -import { - useSelectedVenue, - useSelectedVenueActions, -} from 'features/venueMap/store/selectedVenueStore' +import { selectedVenueActions, useSelectedVenue } from 'features/venueMap/store/selectedVenueStore' import { geolocatedVenuesFixture } from 'fixtures/geolocatedVenues' import { act, renderHook } from 'tests/utils' @@ -14,7 +11,6 @@ describe('selectedVenueStore', () => { it('should handle setSelectedVenue', async () => { const { result: selectedVenue } = renderHook(useSelectedVenue) - const { result: actions } = renderHook(useSelectedVenueActions) await act(async () => { // @ts-expect-error: because of noUncheckedIndexedAccess @@ -26,15 +22,12 @@ describe('selectedVenueStore', () => { it('should handle removeSelectedVenue', async () => { const { result: selectedVenue } = renderHook(useSelectedVenue) - const { result: actions } = renderHook(useSelectedVenueActions) await act(async () => { // @ts-expect-error: because of noUncheckedIndexedAccess actions.current.setSelectedVenue(geolocatedVenuesFixture[0]) }) - await act(async () => { - actions.current.removeSelectedVenue() - }) + selectedVenueActions.removeSelectedVenue() expect(selectedVenue.current).toEqual(null) }) diff --git a/src/features/venueMap/store/venueTypeCodeStore.native.test.ts b/src/features/venueMap/store/venueTypeCodeStore.native.test.ts index 97c5cb87528..af699cf3f3a 100644 --- a/src/features/venueMap/store/venueTypeCodeStore.native.test.ts +++ b/src/features/venueMap/store/venueTypeCodeStore.native.test.ts @@ -1,9 +1,6 @@ import { VenueTypeCodeKey } from 'api/gen' -import { - useVenueTypeCode, - useVenueTypeCodeActions, -} from 'features/venueMap/store/venueTypeCodeStore' -import { act, renderHook } from 'tests/utils' +import { useVenueTypeCode, venueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore' +import { renderHook } from 'tests/utils' describe('venueTypeCodeStore', () => { it('should setTypeCode be null on init', async () => { @@ -14,11 +11,8 @@ describe('venueTypeCodeStore', () => { it('should handle setVenueTypeCode', async () => { const { result: venueTypeCode } = renderHook(useVenueTypeCode) - const { result: actions } = renderHook(useVenueTypeCodeActions) - await act(async () => { - actions.current.setVenueTypeCode(VenueTypeCodeKey.MOVIE) - }) + venueTypeCodeActions.setVenueTypeCode(VenueTypeCodeKey.MOVIE) expect(venueTypeCode.current).toEqual(VenueTypeCodeKey.MOVIE) }) diff --git a/src/features/venueMap/store/venuesFilterStore.native.test.ts b/src/features/venueMap/store/venuesFilterStore.native.test.ts index 58957002020..6661fe5a87b 100644 --- a/src/features/venueMap/store/venuesFilterStore.native.test.ts +++ b/src/features/venueMap/store/venuesFilterStore.native.test.ts @@ -1,7 +1,7 @@ import { VenueTypeCodeKey } from 'api/gen' import { renderHook } from 'tests/utils' -import { useVenuesFilter, useVenuesFilterActions } from './venuesFilterStore' +import { useVenuesFilter, venuesFilterActions } from './venuesFilterStore' describe('venuesFilterStore', () => { it('should get venuesFilters', async () => { @@ -11,8 +11,7 @@ describe('venuesFilterStore', () => { }) it('should set venuesFilters', async () => { - const { result } = renderHook(() => useVenuesFilterActions()) - result.current.setVenuesFilters([VenueTypeCodeKey.MOVIE]) + venuesFilterActions.setVenuesFilters([VenueTypeCodeKey.MOVIE]) const { result: state } = renderHook(() => useVenuesFilter()) @@ -20,10 +19,9 @@ describe('venuesFilterStore', () => { }) it('should add venuesFilters', async () => { - const { result } = renderHook(() => useVenuesFilterActions()) - result.current.setVenuesFilters([VenueTypeCodeKey.MOVIE]) - result.current.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE, VenueTypeCodeKey.MUSEUM]) - result.current.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE]) + venuesFilterActions.setVenuesFilters([VenueTypeCodeKey.MOVIE]) + venuesFilterActions.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE, VenueTypeCodeKey.MUSEUM]) + venuesFilterActions.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE]) const { result: state } = renderHook(() => useVenuesFilter()) @@ -35,10 +33,9 @@ describe('venuesFilterStore', () => { }) it('should remove venuesFilter', async () => { - const { result } = renderHook(() => useVenuesFilterActions()) - result.current.setVenuesFilters([VenueTypeCodeKey.MOVIE]) - result.current.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE]) - result.current.removeVenuesFilters([ + venuesFilterActions.setVenuesFilters([VenueTypeCodeKey.MOVIE]) + venuesFilterActions.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE]) + venuesFilterActions.removeVenuesFilters([ VenueTypeCodeKey.BOOKSTORE, VenueTypeCodeKey.MOVIE, VenueTypeCodeKey.MUSEUM, @@ -50,10 +47,9 @@ describe('venuesFilterStore', () => { }) it('should reset venuesFilter', async () => { - const { result } = renderHook(() => useVenuesFilterActions()) - result.current.setVenuesFilters([VenueTypeCodeKey.MOVIE]) - result.current.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE]) - result.current.reset() + venuesFilterActions.setVenuesFilters([VenueTypeCodeKey.MOVIE]) + venuesFilterActions.addVenuesFilters([VenueTypeCodeKey.BOOKSTORE]) + venuesFilterActions.reset() const { result: state } = renderHook(() => useVenuesFilter()) diff --git a/src/features/venueMap/store/venuesStore.native.test.ts b/src/features/venueMap/store/venuesStore.native.test.ts index cc059e0fcf9..fa85ee9ea77 100644 --- a/src/features/venueMap/store/venuesStore.native.test.ts +++ b/src/features/venueMap/store/venuesStore.native.test.ts @@ -1,6 +1,6 @@ -import { useVenues, useVenuesActions } from 'features/venueMap/store/venuesStore' +import { useVenues, venuesActions } from 'features/venueMap/store/venuesStore' import { geolocatedVenuesFixture } from 'fixtures/geolocatedVenues' -import { act, renderHook } from 'tests/utils' +import { renderHook } from 'tests/utils' describe('venuesStore', () => { it('should venues be empty on init', async () => { @@ -11,11 +11,8 @@ describe('venuesStore', () => { it('should handle setVenues', async () => { const { result: venues } = renderHook(useVenues) - const { result: actions } = renderHook(useVenuesActions) - await act(async () => { - actions.current.setVenues(geolocatedVenuesFixture) - }) + venuesActions.setVenues(geolocatedVenuesFixture) expect(venues.current).toEqual(geolocatedVenuesFixture) }) diff --git a/src/features/venueMap/useGetAllVenues.native.test.ts b/src/features/venueMap/useGetAllVenues.native.test.ts index 409c26c8487..05b15bf79f0 100644 --- a/src/features/venueMap/useGetAllVenues.native.test.ts +++ b/src/features/venueMap/useGetAllVenues.native.test.ts @@ -1,7 +1,6 @@ import algoliasearch from 'algoliasearch' import { mockAlgoliaVenues } from 'features/search/fixtures/mockAlgoliaVenues' -import { useVenuesActions } from 'features/venueMap/store/venuesStore' import { useVenueTypeCode } from 'features/venueMap/store/venueTypeCodeStore' import { adaptAlgoliaVenues } from 'libs/algolia/fetchAlgolia/fetchVenues/adaptAlgoliaVenues' import { Region } from 'libs/maps/maps' @@ -25,8 +24,6 @@ const mockUseVenueTypeCode = useVenueTypeCode as jest.MockedFunction -mockUseVenuesActions.mockReturnValue({ setVenues: mockSetVenues }) const region: Region = { latitude: 48.866667, diff --git a/src/features/venueMap/useGetAllVenues.ts b/src/features/venueMap/useGetAllVenues.ts index 632ab36d5b3..e0695429923 100644 --- a/src/features/venueMap/useGetAllVenues.ts +++ b/src/features/venueMap/useGetAllVenues.ts @@ -2,7 +2,7 @@ import { useEffect } from 'react' import { useQuery } from 'react-query' import { Venue } from 'features/venue/types' -import { useVenuesActions } from 'features/venueMap/store/venuesStore' +import { venuesActions } from 'features/venueMap/store/venuesStore' import { fetchVenues } from 'libs/algolia/fetchAlgolia/fetchVenues/fetchVenues' import { LocationMode } from 'libs/location/types' import { Region } from 'libs/maps/maps' @@ -15,7 +15,7 @@ type Props = { } export const useGetAllVenues = ({ region, radius, initialVenues }: Props) => { - const { setVenues } = useVenuesActions() + const { setVenues } = venuesActions const { data: fetchedVenues } = useQuery( [QueryKeys.VENUES, region],