Skip to content

test(useQuiz): add navigation bounds and review-mode guard tests (#948) - #1124

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
vstudio79:fix/quiz-test-navigation-948
Jul 30, 2026
Merged

test(useQuiz): add navigation bounds and review-mode guard tests (#948)#1124
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
vstudio79:fix/quiz-test-navigation-948

Conversation

@vstudio79

Copy link
Copy Markdown
Contributor

Closes #948

What – Add test coverage for the following paths in useQuiz.tsx:

Navigation bounds (goNext/goPrevious, lines 231-237)

  • Calling goPrevious at the first question clamps to index 0
  • Calling goNext at the last question clamps to questions.length - 1
  • canGoNext / canGoPrevious correctly reflect boundary state

Review-mode guards (enterReviewMode/exitReviewMode, lines 362-370)

  • Both are no-ops before the quiz is completed (isCompleted is false)
  • enterReviewMode sets isReviewMode after complete() is called
  • exitReviewMode clears isReviewMode after completion

Why – Off-by-one navigation errors would let users skip past or re-answer questions. The review-mode guards prevent entering or leaving review before completion; untested they could allow invalid state transitions.

All 12 tests pass.

Add tests for:
- goPrevious clamping at index 0 when already at first question
- goNext clamping at questions.length - 1 when already at last question
- canGoNext/canGoPrevious boundary state reflection
- enterReviewMode no-op before completion
- exitReviewMode no-op before completion
- enterReviewMode sets review mode after completion
- exitReviewMode clears review mode after completion

Closes rinafcode#948
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@vstudio79 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit daf7599 into rinafcode:main Jul 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test useQuiz navigation bounds and review-mode transitions

2 participants