-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa6566e
commit c206d08
Showing
5 changed files
with
182 additions
and
52 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/features/venueMap/components/FilterBannerContainer/FilterBannerContainer.native.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react' | ||
|
||
import { FILTERS_VENUE_TYPE_MAPPING } from 'features/venueMap/constant' | ||
import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag' | ||
import { render, screen } from 'tests/utils' | ||
|
||
import { FilterBannerContainer } from './FilterBannerContainer' | ||
|
||
const useFeatureFlagSpy = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag') | ||
|
||
describe('FilterBannerConainer', () => { | ||
beforeEach(() => { | ||
useFeatureFlagSpy.mockReturnValue(true) | ||
}) | ||
|
||
it('should render FilterCategoriesBannerContainer if FF is enabled', async () => { | ||
render(<FilterBannerContainer />) | ||
await screen.findAllByTestId(/[A-Z]+Label/) | ||
|
||
Object.keys(FILTERS_VENUE_TYPE_MAPPING).forEach((id) => { | ||
expect(screen.getByTestId(`${id}Label`)).toBeOnTheScreen() | ||
}) | ||
}) | ||
|
||
it('should render SingleFilterBannerContainer if FF is disabled', async () => { | ||
useFeatureFlagSpy.mockReturnValueOnce(false) | ||
|
||
render(<FilterBannerContainer />) | ||
|
||
expect(await screen.findByLabelText('Tous les lieux')).toBeOnTheScreen() | ||
}) | ||
}) |
50 changes: 50 additions & 0 deletions
50
...venueMap/components/FilterBannerContainer/FilterCategoriesBannerContainer.native.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
|
||
import { FILTERS_VENUE_TYPE_MAPPING } from 'features/venueMap/constant' | ||
import { render, screen, userEvent } from 'tests/utils' | ||
|
||
import { FilterCategoriesBannerContainer } from './FilterCategoriesBannerContainer' | ||
|
||
describe('FilterCategoriesBannerContainer', () => { | ||
const user = userEvent.setup() | ||
|
||
it('should render correctly', async () => { | ||
render(<FilterCategoriesBannerContainer />) | ||
|
||
await screen.findAllByTestId(/[A-Z]+Label/) | ||
|
||
Object.keys(FILTERS_VENUE_TYPE_MAPPING).forEach((id) => { | ||
expect(screen.getByTestId(`${id}Label`)).toBeOnTheScreen() | ||
}) | ||
}) | ||
|
||
it.each([ | ||
{ id: 'OUTINGS', label: 'Sorties : Filtre sélectionné' }, | ||
{ id: 'SHOPS', label: 'Boutiques : Filtre sélectionné' }, | ||
{ id: 'OTHERS', label: 'Autres : Filtre sélectionné' }, | ||
])(`should select $id group`, async ({ id, label }) => { | ||
jest.useFakeTimers() | ||
render(<FilterCategoriesBannerContainer />) | ||
|
||
await user.press(screen.getByTestId(`${id}Label`)) | ||
|
||
expect(await screen.findByLabelText(label)).toBeOnTheScreen() | ||
|
||
jest.useRealTimers() | ||
}) | ||
|
||
it('should deselect selected group', async () => { | ||
jest.useFakeTimers() | ||
render(<FilterCategoriesBannerContainer />) | ||
|
||
await user.press(screen.getByTestId('OUTINGSLabel')) | ||
|
||
await screen.findByLabelText('Sorties : Filtre sélectionné') | ||
|
||
await user.press(screen.getByTestId('OUTINGSLabel')) | ||
|
||
expect(screen.queryByLabelText('Sorties : Filtre sélectionné')).not.toBeOnTheScreen() | ||
|
||
jest.useRealTimers() | ||
}) | ||
}) |
41 changes: 41 additions & 0 deletions
41
...res/venueMap/components/FilterBannerContainer/SingleFilterBannerContainer.native.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react' | ||
|
||
import { VenueTypeCodeKey } from 'api/gen' | ||
import { | ||
useVenueTypeCode, | ||
useVenueTypeCodeActions, | ||
} from 'features/venueMap/store/venueTypeCodeStore' | ||
import { parseType } from 'libs/parsers/venueType' | ||
import { ellipseString } from 'shared/string/ellipseString' | ||
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 | ||
|
||
describe('SingleFilterBannerContainer', () => { | ||
beforeEach(() => { | ||
mockUseVenueTypeCode.mockReturnValue(VENUE_TYPE) | ||
}) | ||
|
||
it('should render correctly', async () => { | ||
render(<SingleFilterBannerContainer />) | ||
|
||
expect(screen.getByText(ellipseString(parseType(VENUE_TYPE), 20))).toBeOnTheScreen() | ||
}) | ||
|
||
it('Should filter with no venueCode', async () => { | ||
mockUseVenueTypeCode.mockReturnValueOnce(null) | ||
|
||
render(<SingleFilterBannerContainer />) | ||
|
||
expect(screen.getByText('Tous les lieux')).toBeOnTheScreen() | ||
}) | ||
}) |
87 changes: 52 additions & 35 deletions
87
src/features/venueMap/hook/useVenueMapFilters.native.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters