freshyo/apps/user-ui/tests/components/location-wrapper.test.tsx
2026-10-08 19:48:14 +05:30

37 lines
1.2 KiB
TypeScript

/**
* LocationTestWrapper (components/LocationTestWrapper.tsx).
*
* It is now the region gate: once a region is selected it is a passthrough,
* otherwise it derives the region from location and falls back to the chooser.
* Under jest the platform constants read as a simulator, so with no region the
* chooser would show; this locks in the passthrough path with a region set.
*/
import React from 'react'
import { Text } from 'react-native'
import { screen } from '@testing-library/react-native'
import LocationTestWrapper from '@/components/LocationTestWrapper'
import { useRegionStore } from '@/src/store/regionStore'
import { resetStorage, setupApiMocks } from '../mocks/api'
import { renderWithProviders } from '../helpers/render'
describe('LocationTestWrapper', () => {
it('renders its children once a region is selected', async () => {
setupApiMocks()
await resetStorage()
useRegionStore
.getState()
.setRegion({ id: 1, name: 'Test Region', description: null })
renderWithProviders(
<LocationTestWrapper>
<Text>app content</Text>
</LocationTestWrapper>,
{ centralStores: false }
)
expect(screen.getByText('app content')).toBeVisible()
})
})