import React from 'react'; import FloatButton from '..'; import { fireEvent, render } from '../../../tests/utils'; describe('FloatButtonGroup', () => { it('should correct render', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); it('support shape', () => { const [defaultShape, squareShape] = ['circle', 'square'] as const; const { container, rerender } = render( , ); expect(container.querySelectorAll(`.ant-float-btn-${defaultShape}`)).toHaveLength(3); rerender( , ); expect(container.querySelectorAll(`.ant-float-btn-${squareShape}`)).toHaveLength(3); }); it('support onOpenChange for click', () => { const onOpenChange = vi.fn(); const { container } = render( , ); fireEvent.click(container.querySelector('.ant-float-btn')!); expect(onOpenChange).toHaveBeenCalled(); }); it('support onOpenChange for hover', () => { const onOpenChange = vi.fn(); const { container } = render( , ); fireEvent.mouseEnter(container.querySelector('.ant-float-btn-group')!); fireEvent.mouseLeave(container.querySelector('.ant-float-btn-group')!); expect(onOpenChange).toHaveBeenCalled(); }); it('support click floatButtonGroup not close', () => { const onOpenChange = vi.fn(); const { container } = render( , ); fireEvent.click(container.querySelector('.ant-float-btn')!); fireEvent.click(container.querySelector('.ant-float-btn-group')!); expect(onOpenChange).toHaveBeenCalledTimes(1); }); it('support click out auto close', () => { const onOpenChange = vi.fn(); const { container } = render( , ); fireEvent.click(container.querySelector('.ant-float-btn')!); fireEvent.click(container); expect(onOpenChange).toHaveBeenCalledTimes(2); }); });