Skip to content

Commit 2129937

Browse files
committed
test: improve optional step use case
1 parent 382a45a commit 2129937

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

test/useWizard.test.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,22 @@ describe('useWizard', () => {
3838
expect(result.current.stepCount).toBe(2);
3939
});
4040

41-
test('should set step count to one when using falsy step', () => {
42-
const { result } = renderHook(() => useWizard(), {
43-
wrapper: ({ children }) => (
44-
<Wizard>
45-
<p>step 1 {children}</p>
46-
<p>step 2 {children}</p>
47-
{false && <p>step 3 {children}</p>}
48-
</Wizard>
49-
),
50-
});
41+
test.each([false, null, undefined])(
42+
'should set step count to two when using %s as step',
43+
(value) => {
44+
const { result } = renderHook(() => useWizard(), {
45+
wrapper: ({ children }) => (
46+
<Wizard>
47+
<p>step 1 {children}</p>
48+
<p>step 2 {children}</p>
49+
{value && <p>step 3 {children}</p>}
50+
</Wizard>
51+
),
52+
});
5153

52-
expect(result.current.stepCount).toBe(2);
53-
});
54+
expect(result.current.stepCount).toBe(2);
55+
},
56+
);
5457

5558
test('should set active step to one', () => {
5659
const { result } = renderUseWizardHook(1);

0 commit comments

Comments
 (0)