Skip to content

Commit

Permalink
Add test for multiple select of correct answer
Browse files Browse the repository at this point in the history
  • Loading branch information
leung018 committed Dec 4, 2023
1 parent e6bbec7 commit 4b00d03
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/components/mc/editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,25 @@ describe('QuestionSetEditorUIService', () => {
},
])
})

it('should only choose one correct answer no matter how many are clicked', () => {
const interactor = new UIServiceInteractor({})

interactor
.setQuestionNumberFocus(1)
.inputQuestionDescription({ description: '1 + 1 = ?' })
.inputAnswer({ choiceNumber: 1, answer: '0' })
.inputAnswer({ choiceNumber: 2, answer: '2' })
.clickAddChoice()
.inputAnswer({ choiceNumber: 3, answer: '1' })

interactor
.clickCorrectAnswer({ choiceNumber: 1 })
.clickCorrectAnswer({ choiceNumber: 3 })
.clickCorrectAnswer({ choiceNumber: 2 })
.clickSave()

const actualQuestionSet = interactor.getSavedQuestionSet()
expect(actualQuestionSet.questions[0].mc.correctChoiceIndex).toBe(1)
})
})

0 comments on commit 4b00d03

Please sign in to comment.