import React from 'react'; import Result from '..'; import Button from '../../button'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { render } from '../../../tests/utils'; describe('Result', () => { mountTest(Result); rtlTest(Result); it('🙂 successPercent should decide the progress status when it exists', () => { const { container: wrapper } = render( Go Console , , ]} />, ); expect(wrapper.querySelectorAll('.anticon-check-circle')).toHaveLength(1); }); it('🙂 different status, different class', () => { const { container: wrapper, rerender } = render(); expect(wrapper.querySelectorAll('.ant-result-warning')).toHaveLength(1); rerender(); expect(wrapper.querySelectorAll('.ant-result-error')).toHaveLength(1); rerender(); expect(wrapper.querySelectorAll('.ant-result-500')).toHaveLength(1); }); it('🙂 When status = 404, the icon is an image', () => { const { container: wrapper } = render(); expect(wrapper.querySelectorAll('.ant-result-404 .ant-result-image')).toHaveLength(1); }); it('🙂 When extra is undefined, the extra dom is undefined', () => { const { container: wrapper } = render(); expect(wrapper.querySelectorAll('.ant-result-extra')).toHaveLength(0); }); it('🙂 result should support className', () => { const { container: wrapper } = render( , ); expect(wrapper.querySelectorAll('.ant-result.my-result')).toHaveLength(1); }); it('should warning when pass a string as icon props', () => { const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); render(); expect(warnSpy).not.toHaveBeenCalled(); render(); expect(warnSpy).toHaveBeenCalledWith( `Warning: [antd: Result] \`icon\` is using ReactNode instead of string naming in v4. Please check \`smile\` at https://ant.design/components/icon`, ); warnSpy.mockRestore(); }); });