Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ const Preview: React.FC<PreviewProps> = props => {
return (
<div
className={clsx(prefixCls, rootClassName, classNames.root, motionClassName, {
[`${prefixCls}-movable`]: movable,
[`${prefixCls}-moving`]: isMoving,
})}
style={mergedStyle}
Expand Down
24 changes: 22 additions & 2 deletions tests/preview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import RotateLeftOutlined from '@ant-design/icons/RotateLeftOutlined';
import RotateRightOutlined from '@ant-design/icons/RotateRightOutlined';
import ZoomInOutlined from '@ant-design/icons/ZoomInOutlined';
import ZoomOutOutlined from '@ant-design/icons/ZoomOutOutlined';
import Dialog from '@rc-component/dialog';
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
import { act, createEvent, fireEvent, render } from '@testing-library/react';
import React, { useState } from 'react';
import Dialog from '@rc-component/dialog';
import React from 'react';

jest.mock('../src/Preview', () => {
const MockPreview = (props: any) => {
Expand Down Expand Up @@ -378,6 +378,26 @@ describe('Preview', () => {
});
});

it('should render movable className correctly according to movable prop', () => {
const { rerender } = render(
<Image
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
preview={{ open: true }}
/>,
);

expect(document.querySelector('.rc-image-preview')).toHaveClass('rc-image-preview-movable');

rerender(
<Image
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
preview={{ open: true, movable: false }}
/>,
);

expect(document.querySelector('.rc-image-preview')).not.toHaveClass('rc-image-preview-movable');
});

it('Mouse Event', () => {
const clientWidthMock = jest
.spyOn(document.documentElement, 'clientWidth', 'get')
Expand Down
Loading