Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/hooks/__tests__/useQuiz.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ describe('quiz grading helpers', () => {
});

describe('useQuiz', () => {
it('ignores a second answer to an already-answered question', () => {
const { result } = renderHook(() => useQuiz({ quiz: quizFixture, autoStart: false }));

act(() => {
result.current.actions.answerQuestion('mc-1', 'b'); // correct
});

const firstAnswer = result.current.answers['mc-1'];

act(() => {
result.current.actions.answerQuestion('mc-1', 'a'); // attempt to change to wrong
});

expect(result.current.answers['mc-1']).toBe(firstAnswer);
expect(result.current.score).toBe(2);
});

it('tracks partial code-credit and regular grading without regressing score updates', () => {
const { result } = renderHook(() => useQuiz({ quiz: quizFixture, autoStart: false }));

Expand Down
Loading