Skip to content

Commit b7dbd34

Browse files
committed
test: add extra test case
1 parent c5f9d01 commit b7dbd34

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

test/useWizard.test.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('useWizard', () => {
161161
expect(result.current.isLastStep).toBe(false);
162162
});
163163

164-
test('should thrown error on nextStep', async () => {
164+
test('should thrown error on async nextStep', async () => {
165165
const { result } = renderUseWizardHook();
166166

167167
act(() => {
@@ -177,4 +177,23 @@ describe('useWizard', () => {
177177
});
178178
});
179179
});
180+
181+
test('should thrown error on sync nextStep', async () => {
182+
const { result } = renderUseWizardHook();
183+
184+
act(() => {
185+
result.current.handleStep(() => {
186+
throw Error('Sync gotcha');
187+
});
188+
189+
try {
190+
result.current.nextStep();
191+
} catch (error) {
192+
expect(error).toEqual(Error('Sync gotcha'));
193+
expect(error).toEqual(Error('Sync gotcha'));
194+
expect(result.current.activeStep).toBe(0);
195+
expect(result.current.isFirstStep).toBe(true);
196+
}
197+
});
198+
});
180199
});

0 commit comments

Comments
 (0)