ant-design/components/float-button/__tests__/group.test.tsx
lijianan a05b9d92c5
feat: Float Button (#37520)
* feat: add FloatButton

* feat: add FloatButton

* feat: FloatButton

* feat: FloatButton

* fix: fix

* feat: FloatButton

* feat: FloatButton

* feat: FloatButton

* feat: FloatButton

* feat: FloatButton

* fix: add groupShape

* feat: mergeShape

* fix: fix

* fix: fix style

* fix: style fix

* fix: fix

* fix: style fix

* fix: fix

* fix: fix

* fix: fix

* fix: fix style

* fix: fix style

* fix: fix style

* fix: style fix

* feat: back-top

* fix: style bug fix

* fix: fix erroe

* fix: add tiggerElement

* fix: add tiggerElement

* fix: add tiggerElement

* fix: add tiggerElement

* feat: add useMemo

* docs: add docs

* fix: bugFix

* fix: bugFix

* fix: bugfix

* fix: style fix

* fix: bugfix

* test: add test case

* fix: style fix

* fix: style fix

* fix: fix style

* fix: fix style

* fix: fix trigger action

* fix: fix style

* feat: add demo

* fix: add demo

* feat: add docs

* fix: style ifx

* feat: update maxSize of bundlesize

* feat: add animation for group

* fix: fix

* fix: fix style

* fix: fix test case

* fix: fix test case

* fix: fix type

* fix: fix type

* fix: update bundlesize

* fix: fix

* fix: fix style

* fix: fix style

* fix: updata snap

* fix: fix CI

* fix: fix style

* fix: rename float button motion

* fix: fix style

* fix: bugFix

* fix: fix style

* fix: bugFix

* fix: update docs

* refactor: float button trigger

* test: fix test case & update snapshot

* fix: delete rest

* docs: update demo

* test: update snapshot

* fix: fix eslint error

* test: update snapshot

* style: update icon fontSize to 18

* fix: fix style

* fix: style fix

* fix: test case fix

* test: add test case

* fix: style fix

* test: update snap

* fix: style fix

* fix: style fix

* fix: style fix

* docs: demo update

* fix: style fix

* docs: update demo

* test: update snapshot

Co-authored-by: 黑雨 <wangning4567@163.com>
Co-authored-by: MadCcc <1075746765@qq.com>
2022-09-23 14:31:16 +08:00

62 lines
1.9 KiB
TypeScript

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