import React from 'react'; import Image from '..'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { fireEvent, render } from '../../../tests/utils'; import ConfigProvider from '../../config-provider'; const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'; describe('Image', () => { mountTest(Image); rtlTest(Image); it('Image preview props set false', () => { const { container } = render(); fireEvent.click(container.querySelector('.ant-image')!); expect(container.querySelector('.ant-image-preview-root')).toBe(null); }); it('Group preview props set false', () => { const { container } = render( , ); fireEvent.click(container.querySelector('.ant-image')!); expect(container.querySelector('.ant-image-preview-root')).toBe(null); }); it('Default preview props', () => { const { container, baseElement } = render(); fireEvent.click(container.querySelector('.ant-image')!); expect(baseElement.querySelector('.ant-image-preview-mask')).toHaveClass('ant-fade'); expect(baseElement.querySelector('.ant-image-preview')).toHaveClass('ant-zoom'); }); it('Default Group preview props', () => { const { container, baseElement } = render( , ); fireEvent.click(container.querySelector('.ant-image')!); expect(baseElement.querySelector('.ant-image-preview-mask')).toHaveClass('ant-fade'); expect(baseElement.querySelector('.ant-image-preview')).toHaveClass('ant-zoom'); }); it('Customize preview props', () => { const { container, baseElement } = render( , ); fireEvent.click(container.querySelector('.ant-image')!); expect(baseElement.querySelector('.ant-image-preview')).toHaveClass('abc'); expect(baseElement.querySelector('.ant-image-preview-mask')).toHaveClass('def'); }); it('Customize Group preview props', () => { const { container, baseElement } = render( , ); fireEvent.click(container.querySelector('.ant-image')!); expect(baseElement.querySelector('.ant-image-preview')).toHaveClass('abc'); expect(baseElement.querySelector('.ant-image-preview-mask')).toHaveClass('def'); }); it('ConfigProvider getPopupContainer', () => { const { container, baseElement } = render( <>
document.querySelector('.container')!}> , ); fireEvent.click(container.querySelector('.ant-image')!); expect(baseElement.querySelector('.container')?.children.length).not.toBe(0); }); });