ant-design/components/image/__tests__/index.test.js
叶枫 19c8c426e5
fix: image prefix (#29394)
* fix: image

* fix: image group

* fix: image package

* chore: test
2021-02-20 22:24:44 +08:00

52 lines
1.7 KiB
JavaScript

import React from 'react';
import { mount } from 'enzyme';
import Image from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png';
describe('Image', () => {
mountTest(Image);
rtlTest(Image);
it('Default preview props', () => {
const wrapper = mount(<Image src={src} preview={{ visible: true }} />);
expect(wrapper.find('Preview').prop('transitionName')).toBe('ant-zoom');
expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('ant-fade');
});
it('Default Group preview props', () => {
const wrapper = mount(
<Image.PreviewGroup preview={{ visible: true }}>
<Image src={src} />
</Image.PreviewGroup>,
);
expect(wrapper.find('Preview').prop('transitionName')).toBe('ant-zoom');
expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('ant-fade');
});
it('Customize preview props', () => {
const wrapper = mount(
<Image
src={src}
preview={{ visible: true, transitionName: 'abc', maskTransitionName: 'def' }}
/>,
);
expect(wrapper.find('Preview').prop('transitionName')).toBe('abc');
expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('def');
});
it('Customize Group preview props', () => {
const wrapper = mount(
<Image.PreviewGroup
preview={{ visible: true, transitionName: 'abc', maskTransitionName: 'def' }}
>
<Image src={src} />
</Image.PreviewGroup>,
);
expect(wrapper.find('Preview').prop('transitionName')).toBe('abc');
expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('def');
});
});