Skip to content

Commit 912ce9e

Browse files
authored
Merge pull request #82 from devrnt/test/throw-error
test: add extra handleStep test case
2 parents e624749 + 75a0125 commit 912ce9e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/useWizard.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,21 @@ describe('useWizard', () => {
160160
expect(result.current.isFirstStep).toBe(true);
161161
expect(result.current.isLastStep).toBe(false);
162162
});
163+
164+
test('should thrown error on nextStep', async () => {
165+
const { result } = renderUseWizardHook();
166+
167+
act(() => {
168+
result.current.handleStep(() => {
169+
return Promise.reject(Error('Gotcha'));
170+
});
171+
172+
result.current.nextStep().catch((error) => {
173+
expect(error).toEqual(Error('Gotcha'));
174+
expect(result.error).toEqual(Error('Gotcha'));
175+
expect(result.current.activeStep).toBe(0);
176+
expect(result.current.isFirstStep).toBe(true);
177+
});
178+
});
179+
});
163180
});

0 commit comments

Comments
 (0)