Skip to content

Commit

Permalink
(PC-32564) feat(culturalSurvey): fix cultural survey questions to dis…
Browse files Browse the repository at this point in the history
…play
  • Loading branch information
Lucasbeneston committed Oct 21, 2024
1 parent 680e885 commit c865559
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('CulturalSurveyQuestions page', () => {
const GoBackButton = screen.getByTestId('Revenir en arrière')
fireEvent.press(GoBackButton)

expect(dispatch).toHaveBeenCalledWith({
expect(dispatch).toHaveBeenNthCalledWith(1, {
type: 'SET_ANSWERS',
payload: {
questionId: navigationProps.route.params.question,
Expand All @@ -129,6 +129,22 @@ describe('CulturalSurveyQuestions page', () => {
})
})

it('should dispatch default questions on go back when current question is "sorties"', () => {
render(<CulturalSurveyQuestions {...navigationProps} />)

const GoBackButton = screen.getByTestId('Revenir en arrière')
fireEvent.press(GoBackButton)

expect(dispatch).toHaveBeenNthCalledWith(2, {
type: 'SET_QUESTIONS',
payload: [
CulturalSurveyQuestionEnum.SORTIES,
CulturalSurveyQuestionEnum.ACTIVITES,
CulturalSurveyQuestionEnum.PROJECTIONS,
],
})
})

it('should updateQuestionsToDisplay on checkbox press if answer pressed has sub_question', () => {
render(<CulturalSurveyQuestions {...navigationProps} />)

Expand Down
13 changes: 13 additions & 0 deletions src/features/culturalSurvey/pages/CulturalSurveyQuestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ export function CulturalSurveyQuestions({ route }: CulturalSurveyQuestionsProps)
answers: [],
},
})

if (currentQuestion === CulturalSurveyQuestionEnum.SORTIES) {
const INITIAL_CULTURAL_SURVEY_QUESTIONS = [
CulturalSurveyQuestionEnum.SORTIES,
CulturalSurveyQuestionEnum.ACTIVITES,
CulturalSurveyQuestionEnum.PROJECTIONS,
]

dispatch({
type: 'SET_QUESTIONS',
payload: INITIAL_CULTURAL_SURVEY_QUESTIONS,
})
}
}

function onScroll({ nativeEvent }: { nativeEvent: NativeScrollEvent }) {
Expand Down

0 comments on commit c865559

Please sign in to comment.