Skip to content

Commit 39b49ea

Browse files
committed
Add test case
1 parent f6a572e commit 39b49ea

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

packages/components/src/components/Stepper/__tests__/index.browser.test.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,38 @@ describe('Stepper', () => {
100100
useStepper: expect.any(Function),
101101
})
102102
})
103+
104+
it('should increase value when increase button is clicked', () => {
105+
const { container } = render(
106+
<Stepper>
107+
<StepperDecreaseButton />
108+
<StepperInput />
109+
<StepperIncreaseButton />
110+
</Stepper>,
111+
)
112+
const increaseButton = container.querySelector(
113+
'[aria-label="Increase button"]',
114+
)
115+
fireEvent.click(increaseButton!)
116+
expect(
117+
container.querySelector('[aria-label="Stepper value"]'),
118+
).toHaveAttribute('data-value', '1')
119+
})
120+
121+
it('should decrease value when decrease button is clicked', () => {
122+
const { container } = render(
123+
<Stepper defaultValue={1}>
124+
<StepperDecreaseButton />
125+
<StepperInput />
126+
<StepperIncreaseButton />
127+
</Stepper>,
128+
)
129+
const decreaseButton = container.querySelector(
130+
'[aria-label="Decrease button"]',
131+
)
132+
fireEvent.click(decreaseButton!)
133+
expect(
134+
container.querySelector('[aria-label="Stepper value"]'),
135+
).toHaveAttribute('data-value', '0')
136+
})
103137
})

0 commit comments

Comments
 (0)