Skip to content

Commit 0b75785

Browse files
author
刘欢
committed
test: add explicit wheel:true test case for codecov
1 parent 5b89a7c commit 0b75785

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎tests/preview.test.tsx‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,36 @@ describe('Preview', () => {
290290
});
291291
});
292292

293+
it('should zoom with wheel when wheel is explicitly true', () => {
294+
const { container } = render(
295+
<Image
296+
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
297+
preview={{
298+
open: true,
299+
wheel: true,
300+
}}
301+
/>,
302+
);
303+
304+
expect(document.querySelector('.rc-image-preview-img')).toHaveStyle({
305+
transform: 'translate3d(0px, 0px, 0) scale3d(1, 1, 1) rotate(0deg)',
306+
});
307+
308+
// Wheel zoom should work when wheel is true
309+
fireEvent.wheel(document.querySelector('.rc-image-preview-img'), {
310+
deltaY: -50,
311+
});
312+
313+
act(() => {
314+
jest.runAllTimers();
315+
});
316+
317+
// Scale should change to 1.25
318+
expect(document.querySelector('.rc-image-preview-img')).toHaveStyle({
319+
transform: 'translate3d(-128px, -96px, 0) scale3d(1.25, 1.25, 1) rotate(0deg)',
320+
});
321+
});
322+
293323
it('should not zoom with wheel when wheel is false', () => {
294324
const { container } = render(
295325
<Image

0 commit comments

Comments
 (0)