Skip to content

Commit

Permalink
Refactor test of clicking multi correct answer
Browse files Browse the repository at this point in the history
  • Loading branch information
leung018 committed Dec 6, 2023
1 parent 6e97d43 commit d64b666
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/app/components/mc/editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('QuestionSetEditorUIService', () => {
])
})

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

interactor
Expand All @@ -309,22 +309,10 @@ describe('QuestionSetEditorUIService', () => {

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

it('should uncheck other previously checked correct answer after checking another answer', () => {
const interactor = new UIServiceInteractor({})

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

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

// also check that the UI is updated correctly
interactor.expectCorrectAnswerChecked({ choiceNumber: 2 })
interactor.expectCorrectAnswerUnchecked({ choiceNumber: 1 })
interactor.expectCorrectAnswerUnchecked({ choiceNumber: 3 })
})
})

0 comments on commit d64b666

Please sign in to comment.