chore: auto merge branchs (#35111)

chore: sync master into feature
This commit is contained in:
github-actions[bot] 2022-04-20 03:19:09 +00:00 committed by GitHub
commit a79dc2fe65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
148 changed files with 3269 additions and 2891 deletions

View File

@ -15,6 +15,24 @@ timeline: true
---
## 4.20.0-alpha.1
`2022-04-18`
- Form
- 🔥 Form support `useWatch` to get current field value. [#35036](https://github.com/ant-design/ant-design/pull/35036)
- 🆕 Form support `useFormInstance` to get current context form instance. [#35039](https://github.com/ant-design/ant-design/pull/35039)
- 🆕 Image PreviewGroup Support top progress rendering. [#35038](https://github.com/ant-design/ant-design/pull/35038) [@zpc7](https://github.com/zpc7)
- Upload
- 🆕 Upload support `crossOrigin` for images in `picture-card` mode. [#34981](https://github.com/ant-design/ant-design/pull/34981) [@dragmove](https://github.com/dragmove)
- 🐞 Fix Upload `prefixCls` don't work on file list. [#34944](https://github.com/ant-design/ant-design/pull/34944) [@swchen](https://github.com/swchen)
- 💄 Improve Upload action styles. [#35052](https://github.com/ant-design/ant-design/pull/35052)
- 🐞 Fix Notification and Message throw `createRoot` warning in React 18. [#35030](https://github.com/ant-design/ant-design/pull/35030)
- 🐞 Fix Select and AutoComplete scroll abnormal behavior when navigate via keyboard.。[#35025](https://github.com/ant-design/ant-design/pull/35025)
- 🐞 Fix Cascader search result do not fill the entrie panel. [#35019](https://github.com/ant-design/ant-design/pull/35019) [@boomler](https://github.com/boomler)
- 💄 Fix Spin animation style being abnormally parsed in Parcel. [#35005](https://github.com/ant-design/ant-design/pull/35005)
- 💄 Arrow radius use fixed value `2px`. [#34999](https://github.com/ant-design/ant-design/pull/34999)
## 4.20.0-alpha.0
`2022-04-12`

View File

@ -15,6 +15,24 @@ timeline: true
---
## 4.20.0-alpha.1
`2022-04-18`
- Form
- 🔥 Form 添加 `useWatch` 支持获取当前字段值。[#35036](https://github.com/ant-design/ant-design/pull/35036)
- 🆕 Form 支持 `useFormInstance` 以获取当前上下文中的 Form 实例。[#35039](https://github.com/ant-design/ant-design/pull/35039)
- 🆕 Image PreviewGroup 支持顶部进度渲染。[#35038](https://github.com/ant-design/ant-design/pull/35038) [@zpc7](https://github.com/zpc7)
- Upload
- 🆕 Upload `picture-card` 模式支持配置图片的 `crossOrigin` 属性。[#34981](https://github.com/ant-design/ant-design/pull/34981) [@dragmove](https://github.com/dragmove)
- 🐞 修复 Upload `prefixCls` 对列表不生效的问题。[#34944](https://github.com/ant-design/ant-design/pull/34944) [@swchen](https://github.com/swchen)
- 💄 优化 Upload 操作按钮的样式细节。[#35052](https://github.com/ant-design/ant-design/pull/35052)
- 🐞 修复 Notification 和 Message 在 React 18 下抛出使用 `createRoot` 的警告信息。[#35030](https://github.com/ant-design/ant-design/pull/35030)
- 🐞 修复 Select 和 AutoComplete 使用键盘向下滚动时行为异常的问题。[#35025](https://github.com/ant-design/ant-design/pull/35025)
- 🐞 修复 Cascader 的搜索结果未占满整个面板的问题。[#35019](https://github.com/ant-design/ant-design/pull/35019) [@boomler](https://github.com/boomler)
- 💄 修复 Spin 动画样式在 Parcel 解析异常的问题。[#35005](https://github.com/ant-design/ant-design/pull/35005)
- 💄 箭头圆角固定为 `2px`。[#34999](https://github.com/ant-design/ant-design/pull/34999)
## 4.20.0-alpha.0
`2022-04-12`

View File

@ -148,7 +148,9 @@ describe('Test utils function', () => {
button
</button>
</Wave>,
).instance();
)
.find(Wave)
.instance();
expect(wrapper.bindAnimationEvent()).toBe(undefined);
});
@ -159,7 +161,9 @@ describe('Test utils function', () => {
button
</button>
</Wave>,
).instance();
)
.find(Wave)
.instance();
expect(wrapper.bindAnimationEvent()).toBe(undefined);
});
@ -168,7 +172,9 @@ describe('Test utils function', () => {
<Wave>
<input />
</Wave>,
).instance();
)
.find(Wave)
.instance();
expect(wrapper.bindAnimationEvent()).toBe(undefined);
});

View File

@ -4,4 +4,9 @@ export { resetWarned };
export default (valid: boolean, component: string, message: string): void => {
devWarning(valid, `[antd: ${component}] ${message}`);
// StrictMode will inject console which will not throw warning in React 17.
if (process.env.NODE_ENV === 'test') {
resetWarned();
}
};

View File

@ -5,7 +5,7 @@ import { getObserverEntities } from '../utils';
import Button from '../../button';
import rtlTest from '../../../tests/shared/rtlTest';
import accessibilityTest from '../../../tests/shared/accessibilityTest';
import { sleep } from '../../../tests/utils';
import { sleep, render } from '../../../tests/utils';
const events: Partial<Record<keyof HTMLElementEventMap, (ev: Partial<Event>) => void>> = {};
@ -97,57 +97,47 @@ describe('Affix Render', () => {
};
it('Anchor render perfectly', async () => {
document.body.innerHTML = '<div id="mounter" />';
affixMounterWrapper = mount(<AffixMounter />, { attachTo: document.getElementById('mounter') });
const { container } = render(<AffixMounter />);
await sleep(20);
await movePlaceholder(0);
expect(affixMounterWrapper.instance().affix.state.affixStyle).toBeFalsy();
expect(container.querySelector('.ant-affix')).toBeFalsy();
await movePlaceholder(-100);
expect(affixMounterWrapper.instance().affix.state.affixStyle).toBeTruthy();
expect(container.querySelector('.ant-affix')).toBeTruthy();
await movePlaceholder(0);
expect(affixMounterWrapper.instance().affix.state.affixStyle).toBeFalsy();
expect(container.querySelector('.ant-affix')).toBeFalsy();
});
it('support offsetBottom', async () => {
document.body.innerHTML = '<div id="mounter" />';
affixMounterWrapper = mount(<AffixMounter offsetBottom={0} />, {
attachTo: document.getElementById('mounter'),
});
const { container } = render(<AffixMounter offsetBottom={0} />);
await sleep(20);
await movePlaceholder(300);
expect(affixMounterWrapper.instance().affix.state.affixStyle).toBeTruthy();
expect(container.querySelector('.ant-affix')).toBeTruthy();
await movePlaceholder(0);
expect(affixMounterWrapper.instance().affix.state.affixStyle).toBeFalsy();
expect(container.querySelector('.ant-affix')).toBeFalsy();
await movePlaceholder(300);
expect(affixMounterWrapper.instance().affix.state.affixStyle).toBeTruthy();
expect(container.querySelector('.ant-affix')).toBeTruthy();
});
it('updatePosition when offsetTop changed', async () => {
document.body.innerHTML = '<div id="mounter" />';
const onChange = jest.fn();
affixMounterWrapper = mount(<AffixMounter offsetTop={0} onChange={onChange} />, {
attachTo: document.getElementById('mounter'),
});
const { container, rerender } = render(<AffixMounter offsetTop={0} onChange={onChange} />);
await sleep(20);
await movePlaceholder(-100);
expect(onChange).toHaveBeenLastCalledWith(true);
expect(affixMounterWrapper.instance().affix.state.affixStyle?.top).toBe(0);
affixMounterWrapper.setProps({
offsetTop: 10,
});
expect(container.querySelector('.ant-affix')).toHaveStyle({ top: 0 });
rerender(<AffixMounter offsetTop={10} onChange={onChange} />);
await sleep(20);
expect(affixMounterWrapper.instance().affix.state.affixStyle?.top).toBe(10);
expect(container.querySelector('.ant-affix')).toHaveStyle({ top: `10px` });
});
describe('updatePosition when target changed', () => {
@ -201,7 +191,9 @@ describe('Affix Render', () => {
await sleep(20);
await movePlaceholder(300);
expect(affixMounterWrapper.instance().affix.state.affixStyle).toBeTruthy();
expect(
(affixMounterWrapper.find(AffixMounter).instance() as any).affix.state.affixStyle,
).toBeTruthy();
await sleep(20);
affixMounterWrapper.update();

View File

@ -3,7 +3,6 @@ import classNames from 'classnames';
import memoizeOne from 'memoize-one';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import Affix from '../affix';
import AnchorLink from './AnchorLink';
import { ConfigContext, ConfigConsumerProps } from '../config-provider';
import scrollTo from '../_util/scrollTo';
import getScroll from '../_util/getScroll';
@ -62,6 +61,10 @@ export interface AnchorProps {
onChange?: (currentActiveLink: string) => void;
}
interface InternalAnchorProps extends AnchorProps {
anchorPrefixCls: string;
}
export interface AnchorState {
activeLink: null | string;
}
@ -84,9 +87,7 @@ export interface AntAnchor {
) => void;
}
export default class Anchor extends React.Component<AnchorProps, AnchorState, ConfigConsumerProps> {
static Link: typeof AnchorLink;
class Anchor extends React.Component<InternalAnchorProps, AnchorState, ConfigConsumerProps> {
static defaultProps = {
affix: true,
showInkInFixed: false,
@ -268,9 +269,9 @@ export default class Anchor extends React.Component<AnchorProps, AnchorState, Co
);
render() {
const { getPrefixCls, direction } = this.context;
const { direction } = this.context;
const {
prefixCls: customizePrefixCls,
anchorPrefixCls: prefixCls,
className = '',
style,
offsetTop,
@ -281,8 +282,6 @@ export default class Anchor extends React.Component<AnchorProps, AnchorState, Co
} = this.props;
const { activeLink } = this.state;
const prefixCls = getPrefixCls('anchor', customizePrefixCls);
// To support old version react.
// Have to add prefixCls on the instance.
// https://github.com/facebook/react/issues/12397
@ -335,3 +334,22 @@ export default class Anchor extends React.Component<AnchorProps, AnchorState, Co
);
}
}
// just use in test
export type InternalAnchorClass = Anchor;
const AnchorFC = React.forwardRef<Anchor, AnchorProps>((props, ref) => {
const { prefixCls: customizePrefixCls } = props;
const { getPrefixCls } = React.useContext(ConfigContext);
const anchorPrefixCls = getPrefixCls('anchor', customizePrefixCls);
const anchorProps: InternalAnchorProps = {
...props,
anchorPrefixCls,
};
return <Anchor {...anchorProps} ref={ref} />;
});
export default AnchorFC;

View File

@ -1,7 +1,8 @@
import React from 'react';
import { mount } from 'enzyme';
import Anchor from '..';
import { sleep } from '../../../tests/utils';
import type { InternalAnchorClass } from '../Anchor';
import { sleep, render } from '../../../tests/utils';
const { Link } = Anchor;
@ -47,41 +48,42 @@ describe('Anchor Render', () => {
it('Anchor render perfectly', () => {
const hash = getHashUrl();
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
wrapper.find(`a[href="#${hash}"]`).simulate('click');
wrapper.instance().handleScroll();
expect(wrapper.instance().state).not.toBe(null);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScroll();
expect(anchorInstance.state).not.toBe(null);
});
it('Anchor render perfectly for complete href - click', () => {
const hash = getHashUrl();
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`http://www.example.com/#${hash}`} title={hash} />
</Anchor>,
);
wrapper.find(`a[href="http://www.example.com/#${hash}"]`).simulate('click');
expect(wrapper.instance().state.activeLink).toBe(`http://www.example.com/#${hash}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
expect(anchorInstance.state.activeLink).toBe(`http://www.example.com/#${hash}`);
});
it('Anchor render perfectly for complete href - hash router', async () => {
const root = createDiv();
const scrollToSpy = jest.spyOn(window, 'scrollTo');
mount(<div id="/faq?locale=en#Q1">Q1</div>, { attachTo: root });
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href="/#/faq?locale=en#Q1" title="Q1" />
</Anchor>,
);
wrapper.instance().handleScrollTo('/#/faq?locale=en#Q1');
expect(wrapper.instance().state.activeLink).toBe('/#/faq?locale=en#Q1');
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScrollTo('/#/faq?locale=en#Q1');
expect(anchorInstance.state.activeLink).toBe('/#/faq?locale=en#Q1');
expect(scrollToSpy).not.toHaveBeenCalled();
await sleep(1000);
expect(scrollToSpy).toHaveBeenCalled();
@ -91,13 +93,15 @@ describe('Anchor Render', () => {
const hash = getHashUrl();
const root = createDiv();
mount(<div id={hash}>Hello</div>, { attachTo: root });
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`http://www.example.com/#${hash}`} title={hash} />
</Anchor>,
);
wrapper.instance().handleScroll();
expect(wrapper.instance().state.activeLink).toBe(`http://www.example.com/#${hash}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScroll();
expect(anchorInstance.state.activeLink).toBe(`http://www.example.com/#${hash}`);
});
it('Anchor render perfectly for complete href - scrollTo', async () => {
@ -105,13 +109,15 @@ describe('Anchor Render', () => {
const scrollToSpy = jest.spyOn(window, 'scrollTo');
const root = createDiv();
mount(<div id={`#${hash}`}>Hello</div>, { attachTo: root });
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`##${hash}`} title={hash} />
</Anchor>,
);
wrapper.instance().handleScrollTo(`##${hash}`);
expect(wrapper.instance().state.activeLink).toBe(`##${hash}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScrollTo(`##${hash}`);
expect(anchorInstance.state.activeLink).toBe(`##${hash}`);
const calls = scrollToSpy.mock.calls.length;
await sleep(1000);
expect(scrollToSpy.mock.calls.length).toBeGreaterThan(calls);
@ -119,47 +125,49 @@ describe('Anchor Render', () => {
it('should remove listener when unmount', async () => {
const hash = getHashUrl();
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
const removeListenerSpy = jest.spyOn((wrapper.instance() as any).scrollEvent, 'remove');
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
const removeListenerSpy = jest.spyOn((anchorInstance as any).scrollEvent, 'remove');
wrapper.unmount();
expect(removeListenerSpy).toHaveBeenCalled();
});
it('should unregister link when unmount children', async () => {
it('should unregister link when unmount children', () => {
const hash = getHashUrl();
const wrapper = mount<Anchor>(
const { container, rerender } = render(
<Anchor>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
expect((wrapper.instance() as any).links).toEqual([`#${hash}`]);
wrapper.setProps({ children: null });
expect((wrapper.instance() as any).links).toEqual([]);
expect(container.querySelectorAll('.ant-anchor-link-title')).toHaveLength(1);
expect(container.querySelector('.ant-anchor-link-title')).toHaveAttribute('href', `#${hash}`);
rerender(<Anchor />);
expect(container.querySelector('.ant-anchor-link-title')).toBeFalsy();
});
it('should update links when link href update', async () => {
const hash = getHashUrl();
let anchorInstance: Anchor | null = null;
function AnchorUpdate({ href }: { href: string }) {
return (
<Anchor
ref={c => {
anchorInstance = c;
}}
>
<Anchor>
<Link href={href} title={hash} />
</Anchor>
);
}
const wrapper = mount(<AnchorUpdate href={`#${hash}`} />);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
if (anchorInstance == null) {
throw new Error('anchorInstance should not be null');
}
expect((anchorInstance as any).links).toEqual([`#${hash}`]);
wrapper.setProps({ href: `#${hash}_1` });
expect((anchorInstance as any).links).toEqual([`#${hash}_1`]);
@ -180,7 +188,7 @@ describe('Anchor Render', () => {
const href = `#${hash}`;
const title = hash;
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor onClick={handleClick}>
<Link href={href} title={title} />
</Anchor>,
@ -188,7 +196,9 @@ describe('Anchor Render', () => {
wrapper.find(`a[href="${href}"]`).simulate('click');
wrapper.instance().handleScroll();
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScroll();
expect(event).not.toBe(undefined);
expect(link).toEqual({ href, title });
});
@ -200,12 +210,14 @@ describe('Anchor Render', () => {
const getContainerA = createGetContainer(hash);
const getContainerB = createGetContainer(hash);
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor getContainer={getContainerA}>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
const removeListenerSpy = jest.spyOn((wrapper.instance() as any).scrollEvent, 'remove');
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
const removeListenerSpy = jest.spyOn((anchorInstance as any).scrollEvent, 'remove');
await sleep(1000);
wrapper.setProps({ getContainer: getContainerB });
expect(removeListenerSpy).not.toHaveBeenCalled();
@ -224,13 +236,15 @@ describe('Anchor Render', () => {
);
const getContainerA = createGetContainer(hash1);
const getContainerB = createGetContainer(hash2);
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor getContainer={getContainerA}>
<Link href={`#${hash1}`} title={hash1} />
<Link href={`#${hash2}`} title={hash2} />
</Anchor>,
);
const removeListenerSpy = jest.spyOn((wrapper.instance() as any).scrollEvent, 'remove');
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
const removeListenerSpy = jest.spyOn((anchorInstance as any).scrollEvent, 'remove');
expect(removeListenerSpy).not.toHaveBeenCalled();
await sleep(1000);
wrapper.setProps({ getContainer: getContainerB });
@ -248,8 +262,10 @@ describe('Anchor Render', () => {
</Anchor>,
);
wrapper.find(`a[href="#${hash}"]`).simulate('click');
(wrapper.instance() as any).handleScroll();
expect(wrapper.instance().state).not.toBe(null);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
(anchorInstance as any).handleScroll();
expect(anchorInstance.state).not.toBe(null);
});
it('Same function returns different DOM', async () => {
@ -278,7 +294,9 @@ describe('Anchor Render', () => {
<Link href={`#${hash2}`} title={hash2} />
</Anchor>,
);
const removeListenerSpy = jest.spyOn((wrapper.instance() as any).scrollEvent, 'remove');
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
const removeListenerSpy = jest.spyOn((anchorInstance as any).scrollEvent, 'remove');
expect(removeListenerSpy).not.toHaveBeenCalled();
await sleep(1000);
holdContainer.container = document.getElementById(hash2);
@ -306,24 +324,26 @@ describe('Anchor Render', () => {
const scrollToSpy = jest.spyOn(window, 'scrollTo');
const root = createDiv();
mount(<h1 id={hash}>Hello</h1>, { attachTo: root });
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
wrapper.instance().handleScrollTo(`#${hash}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 1000);
dateNowMock = dataNowMockFn();
wrapper.setProps({ offsetTop: 100 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 900);
dateNowMock = dataNowMockFn();
wrapper.setProps({ targetOffset: 200 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 800);
@ -351,24 +371,26 @@ describe('Anchor Render', () => {
const scrollToSpy = jest.spyOn(window, 'scrollTo');
const root = createDiv();
mount(<h1 id={hash}>Hello</h1>, { attachTo: root });
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
wrapper.instance().handleScrollTo(`#${hash}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 1000);
dateNowMock = dataNowMockFn();
wrapper.setProps({ offsetTop: 100 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 900);
dateNowMock = dataNowMockFn();
wrapper.setProps({ targetOffset: 200 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 800);
@ -379,20 +401,22 @@ describe('Anchor Render', () => {
const hash1 = getHashUrl();
const hash2 = getHashUrl();
const onChange = jest.fn();
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor onChange={onChange}>
<Link href={`#${hash1}`} title={hash1} />
<Link href={`#${hash2}`} title={hash2} />
</Anchor>,
);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
expect(onChange).toHaveBeenCalledTimes(1);
wrapper.instance().handleScrollTo(hash2);
anchorInstance.handleScrollTo(hash2);
expect(onChange).toHaveBeenCalledTimes(2);
expect(onChange).toHaveBeenCalledWith(hash2);
});
it('invalid hash', async () => {
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href="notexsited" title="title" />
</Anchor>,
@ -400,8 +424,10 @@ describe('Anchor Render', () => {
wrapper.find(`a[href="notexsited"]`).simulate('click');
wrapper.instance().handleScrollTo('notexsited');
expect(wrapper.instance().state).not.toBe(null);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScrollTo('notexsited');
expect(anchorInstance.state).not.toBe(null);
});
it('test edge case when getBoundingClientRect return zero size', async () => {
@ -429,24 +455,26 @@ describe('Anchor Render', () => {
const scrollToSpy = jest.spyOn(window, 'scrollTo');
const root = createDiv();
mount(<h1 id={hash}>Hello</h1>, { attachTo: root });
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
wrapper.instance().handleScrollTo(`#${hash}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 1000);
dateNowMock = dataNowMockFn();
wrapper.setProps({ offsetTop: 100 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 900);
dateNowMock = dataNowMockFn();
wrapper.setProps({ targetOffset: 200 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 800);
@ -478,24 +506,26 @@ describe('Anchor Render', () => {
const scrollToSpy = jest.spyOn(window, 'scrollTo');
const root = createDiv();
mount(<h1 id={hash}>Hello</h1>, { attachTo: root });
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor getContainer={() => document.body}>
<Link href={`#${hash}`} title={hash} />
</Anchor>,
);
wrapper.instance().handleScrollTo(`#${hash}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 800);
dateNowMock = dataNowMockFn();
wrapper.setProps({ offsetTop: 100 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 800);
dateNowMock = dataNowMockFn();
wrapper.setProps({ targetOffset: 200 });
wrapper.instance().handleScrollTo(`#${hash}`);
anchorInstance.handleScrollTo(`#${hash}`);
await sleep(30);
expect(scrollToSpy).toHaveBeenLastCalledWith(0, 800);
@ -507,13 +537,15 @@ describe('Anchor Render', () => {
const hash1 = getHashUrl();
const hash2 = getHashUrl();
const getCurrentAnchor = () => `#${hash2}`;
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor getCurrentAnchor={getCurrentAnchor}>
<Link href={`#${hash1}`} title={hash1} />
<Link href={`#${hash2}`} title={hash2} />
</Anchor>,
);
expect(wrapper.instance().state.activeLink).toBe(`#${hash2}`);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
expect(anchorInstance.state.activeLink).toBe(`#${hash2}`);
});
// https://github.com/ant-design/ant-design/issues/30584
@ -521,14 +553,16 @@ describe('Anchor Render', () => {
const hash1 = getHashUrl();
const hash2 = getHashUrl();
const onChange = jest.fn();
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor onChange={onChange} getCurrentAnchor={() => hash1}>
<Link href={`#${hash1}`} title={hash1} />
<Link href={`#${hash2}`} title={hash2} />
</Anchor>,
);
const anchorInstance = wrapper.find('Anchor').last().instance() as any as InternalAnchorClass;
expect(onChange).toHaveBeenCalledTimes(1);
wrapper.instance().handleScrollTo(hash2);
anchorInstance.handleScrollTo(hash2);
expect(onChange).toHaveBeenCalledTimes(2);
expect(onChange).toHaveBeenCalledWith(hash2);
});
@ -538,7 +572,7 @@ describe('Anchor Render', () => {
const hash1 = getHashUrl();
const hash2 = getHashUrl();
const getCurrentAnchor = jest.fn();
const wrapper = mount<Anchor>(
const wrapper = mount(
<Anchor getCurrentAnchor={getCurrentAnchor}>
<Link href={`#${hash1}`} title={hash1} />
<Link href={`#${hash2}`} title={hash2} />

View File

@ -1,8 +1,16 @@
import Anchor from './Anchor';
import InternalAnchor from './Anchor';
import AnchorLink from './AnchorLink';
export { AnchorProps } from './Anchor';
export { AnchorLinkProps } from './AnchorLink';
type InternalAnchorType = typeof InternalAnchor;
interface AnchorInterface extends InternalAnchorType {
Link: typeof AnchorLink;
}
const Anchor = InternalAnchor as AnchorInterface;
Anchor.Link = AnchorLink;
export default Anchor;

View File

@ -34,7 +34,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -80,7 +80,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -163,7 +163,7 @@ exports[`renders ./components/auto-complete/demo/certain-category.md extend cont
<div>
<div
class="ant-select-dropdown certain-category-search-dropdown"
style="opacity:0;pointer-events:none;width:500px"
style="opacity:0;width:500px"
>
<div>
<div
@ -501,7 +501,7 @@ exports[`renders ./components/auto-complete/demo/custom.md extend context correc
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -571,7 +571,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -640,7 +640,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -785,7 +785,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -898,7 +898,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -993,7 +993,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1066,7 +1066,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1206,7 +1206,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1280,7 +1280,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1429,7 +1429,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1503,7 +1503,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1652,7 +1652,7 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1732,7 +1732,7 @@ exports[`renders ./components/auto-complete/demo/non-case-sensitive.md extend co
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1862,7 +1862,7 @@ exports[`renders ./components/auto-complete/demo/options.md extend context corre
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1915,7 +1915,7 @@ exports[`renders ./components/auto-complete/demo/status.md extend context correc
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1961,7 +1961,7 @@ exports[`renders ./components/auto-complete/demo/status.md extend context correc
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2045,7 +2045,7 @@ exports[`renders ./components/auto-complete/demo/uncertain-category.md extend co
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none;width:252px"
style="opacity:0;width:252px"
>
<div>
<div

View File

@ -32,7 +32,7 @@ exports[`AutoComplete legacy dataSource should accept react element option 1`] =
<div>
<div
class="ant-select-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: 0; width: 0px;"
style="opacity: 0; min-width: 0; width: 0px;"
>
<div>
<div

View File

@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { act } from 'react-dom/test-utils';
import { mount } from 'enzyme';
import { fireEvent, render } from '@testing-library/react';
import { render, fireEvent } from '../../../tests/utils';
import Avatar from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
@ -123,8 +123,8 @@ describe('Avatar Render', () => {
});
it('should calculate scale of avatar children correctly', () => {
const wrapper = mount(<Avatar>Avatar</Avatar>);
expect(wrapper.find('.ant-avatar-string').render()).toMatchSnapshot();
const { container, rerender } = render(<Avatar>Avatar</Avatar>);
expect(container.querySelector('.ant-avatar-string')).toMatchSnapshot();
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
get() {
@ -134,8 +134,9 @@ describe('Avatar Render', () => {
return 40;
},
});
wrapper.setProps({ children: 'xx' });
expect(wrapper.find('.ant-avatar-string').render()).toMatchSnapshot();
rerender(<Avatar>xx</Avatar>);
expect(container.querySelector('.ant-avatar-string')).toMatchSnapshot();
});
it('should calculate scale of avatar children correctly with gap', () => {

View File

@ -383,7 +383,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -468,7 +468,7 @@ Array [
<div>
<div
class="ant-popover ant-avatar-group-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -514,7 +514,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -604,7 +604,7 @@ Array [
<div>
<div
class="ant-popover ant-avatar-group-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -650,7 +650,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -740,7 +740,7 @@ Array [
<div>
<div
class="ant-popover ant-avatar-group-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -786,7 +786,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import { render } from '../../../tests/utils';
import Breadcrumb from '../index';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
@ -29,8 +29,7 @@ describe('Breadcrumb', () => {
<MyCom />
</Breadcrumb>,
);
expect(errorSpy.mock.calls).toHaveLength(1);
expect(errorSpy.mock.calls[0][0]).toMatch(
expect(errorSpy).toHaveBeenCalledWith(
"Warning: [antd: Breadcrumb] Only accepts Breadcrumb.Item and Breadcrumb.Separator as it's children",
);
});

View File

@ -134,7 +134,7 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light"
@ -162,7 +162,7 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -201,7 +201,7 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -240,7 +240,7 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -267,7 +267,7 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -289,7 +289,7 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -311,7 +311,7 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -1,166 +1,72 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`react router react router 3 1`] = `
<Breadcrumb
params={
Object {
"id": 1,
}
}
routes={
Array [
Object {
"breadcrumbName": "Home",
"childRoutes": Array [
Object {
"breadcrumbName": "Application List",
"childRoutes": Array [
Object {
"breadcrumbName": "Application:id",
"childRoutes": Array [
Object {
"breadcrumbName": "Detail",
"name": "detail",
"path": "detail",
},
],
"name": "app",
"path": ":id",
},
],
"name": "apps",
"path": "apps",
},
],
"name": "home",
"path": "/",
},
Object {
"breadcrumbName": "Application List",
"childRoutes": Array [
Object {
"breadcrumbName": "Application:id",
"childRoutes": Array [
Object {
"breadcrumbName": "Detail",
"name": "detail",
"path": "detail",
},
],
"name": "app",
"path": ":id",
},
],
"name": "apps",
"path": "apps",
},
Object {
"breadcrumbName": "Application:id",
"childRoutes": Array [
Object {
"breadcrumbName": "Detail",
"name": "detail",
"path": "detail",
},
],
"name": "app",
"path": ":id",
},
Object {
"breadcrumbName": "Detail",
"name": "detail",
"path": "detail",
},
]
}
<nav
class="ant-breadcrumb"
>
<nav
className="ant-breadcrumb"
>
<ol>
<BreadcrumbItem
key="Home"
separator="/"
<ol>
<li>
<span
class="ant-breadcrumb-link"
>
<li>
<span
className="ant-breadcrumb-link"
>
<a
href="#/"
>
Home
</a>
</span>
<span
className="ant-breadcrumb-separator"
>
/
</span>
</li>
</BreadcrumbItem>
<BreadcrumbItem
key="apps"
separator="/"
<a
href="#/"
>
Home
</a>
</span>
<span
class="ant-breadcrumb-separator"
>
<li>
<span
className="ant-breadcrumb-link"
>
<a
href="#/apps"
>
Application List
</a>
</span>
<span
className="ant-breadcrumb-separator"
>
/
</span>
</li>
</BreadcrumbItem>
<BreadcrumbItem
key="1"
separator="/"
/
</span>
</li>
<li>
<span
class="ant-breadcrumb-link"
>
<li>
<span
className="ant-breadcrumb-link"
>
<a
href="#/apps/1"
>
Application1
</a>
</span>
<span
className="ant-breadcrumb-separator"
>
/
</span>
</li>
</BreadcrumbItem>
<BreadcrumbItem
key="detail"
separator="/"
<a
href="#/apps"
>
Application List
</a>
</span>
<span
class="ant-breadcrumb-separator"
>
<li>
<span
className="ant-breadcrumb-link"
>
<span>
Detail
</span>
</span>
<span
className="ant-breadcrumb-separator"
>
/
</span>
</li>
</BreadcrumbItem>
</ol>
</nav>
</Breadcrumb>
/
</span>
</li>
<li>
<span
class="ant-breadcrumb-link"
>
<a
href="#/apps/1"
>
Application1
</a>
</span>
<span
class="ant-breadcrumb-separator"
>
/
</span>
</li>
<li>
<span
class="ant-breadcrumb-link"
>
<span>
Detail
</span>
</span>
<span
class="ant-breadcrumb-separator"
>
/
</span>
</li>
</ol>
</nav>
`;

View File

@ -144,6 +144,6 @@ describe('react router', () => {
},
];
const wrapper = mount(<Breadcrumb routes={routes} params={{ id: 1 }} />);
expect(wrapper).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@ -365,7 +365,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -448,7 +448,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -524,7 +524,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -599,7 +599,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -700,7 +700,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -783,7 +783,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -859,7 +859,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -934,7 +934,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1065,7 +1065,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1113,7 +1113,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1191,7 +1191,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1239,7 +1239,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1317,7 +1317,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1365,7 +1365,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1639,7 +1639,7 @@ Array [
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light"
@ -1661,7 +1661,7 @@ Array [
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1694,7 +1694,7 @@ Array [
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1727,7 +1727,7 @@ Array [
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1754,7 +1754,7 @@ Array [
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1776,7 +1776,7 @@ Array [
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1798,7 +1798,7 @@ Array [
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -1,6 +1,5 @@
import React, { Component } from 'react';
import { mount } from 'enzyme';
import { fireEvent, render } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { SearchOutlined } from '@ant-design/icons';
import { resetWarned } from 'rc-util/lib/warning';
@ -8,7 +7,7 @@ import Button from '..';
import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { sleep } from '../../../tests/utils';
import { sleep, render, fireEvent } from '../../../tests/utils';
import { SizeType } from '../../config-provider/SizeContext';
describe('Button', () => {
@ -85,22 +84,26 @@ describe('Button', () => {
it('renders Chinese characters correctly in HOC', () => {
const Text = ({ children }: { children: React.ReactNode }) => <span>{children}</span>;
const wrapper = mount(
const { container, rerender } = render(
<Button>
<Text></Text>
</Button>,
);
expect(wrapper.find('.ant-btn').hasClass('ant-btn-two-chinese-chars')).toBe(true);
wrapper.setProps({
children: <Text></Text>,
});
wrapper.update();
expect(wrapper.find('.ant-btn').hasClass('ant-btn-two-chinese-chars')).toBe(false);
wrapper.setProps({
children: <Text></Text>,
});
wrapper.update();
expect(wrapper.find('.ant-btn').hasClass('ant-btn-two-chinese-chars')).toBe(true);
expect(container.querySelector('.ant-btn')).toHaveClass('ant-btn-two-chinese-chars');
rerender(
<Button>
<Text></Text>
</Button>,
);
expect(container.querySelector('.ant-btn')).not.toHaveClass('ant-btn-two-chinese-chars');
rerender(
<Button>
<Text></Text>
</Button>,
);
expect(container.querySelector('.ant-btn')).toHaveClass('ant-btn-two-chinese-chars');
});
// https://github.com/ant-design/ant-design/issues/18118
@ -123,7 +126,7 @@ describe('Button', () => {
it('have static property for type detecting', () => {
const wrapper = mount(<Button>Button Text</Button>);
expect((wrapper.type() as any).__ANT_BUTTON).toBe(true);
expect((wrapper.find(Button).type() as any).__ANT_BUTTON).toBe(true);
});
it('should change loading state instantly by default', () => {

View File

@ -42,7 +42,7 @@ exports[`renders ./components/calendar/demo/basic.md extend context correctly 1`
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -489,7 +489,7 @@ exports[`renders ./components/calendar/demo/basic.md extend context correctly 1`
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1627,7 +1627,7 @@ exports[`renders ./components/calendar/demo/card.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2074,7 +2074,7 @@ exports[`renders ./components/calendar/demo/card.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3274,7 +3274,7 @@ exports[`renders ./components/calendar/demo/customize-header.md extend context c
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3724,7 +3724,7 @@ exports[`renders ./components/calendar/demo/customize-header.md extend context c
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -4819,7 +4819,7 @@ exports[`renders ./components/calendar/demo/notice-calendar.md extend context co
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5266,7 +5266,7 @@ exports[`renders ./components/calendar/demo/notice-calendar.md extend context co
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -6814,7 +6814,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -7261,7 +7261,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div

View File

@ -912,7 +912,7 @@ Array [
<div>
<div
class="ant-tabs-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
aria-label="expanded dropdown"
@ -1065,7 +1065,7 @@ Array [
<div>
<div
class="ant-tabs-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
aria-label="expanded dropdown"

View File

@ -4,6 +4,7 @@ import Card from '../index';
import Button from '../../button/index';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { render } from '../../../tests/utils';
describe('Card', () => {
mountTest(Card);
@ -84,20 +85,14 @@ describe('Card', () => {
});
it('get ref of card', () => {
class WrapperComponent extends React.Component {
render() {
return (
<Card
// eslint-disable-next-line react/no-string-refs
ref="firstRef"
title="Card title"
>
<p>Card content</p>
</Card>
);
}
}
const wrapper = mount(<WrapperComponent />);
expect(wrapper.ref('firstRef').className.includes('ant-card')).toBe(true);
const cardRef = React.createRef();
render(
<Card ref={cardRef} title="Card title">
<p>Card content</p>
</Card>,
);
expect(cardRef.current).toHaveClass('ant-card');
});
});

View File

@ -3,7 +3,7 @@ import { mount } from 'enzyme';
import Carousel from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { sleep } from '../../../tests/utils';
import { sleep, render } from '../../../tests/utils';
describe('Carousel', () => {
mountTest(Carousel);
@ -99,21 +99,28 @@ describe('Carousel', () => {
describe('should active when children change', () => {
it('should active', () => {
const wrapper = mount(<Carousel />);
wrapper.setProps({
children: <div />,
});
wrapper.update();
expect(wrapper.find('.slick-active').length).toBeTruthy();
const { rerender, container } = render(<Carousel />);
expect(container.querySelector('.slick-active')).toBeFalsy();
// Update children
rerender(
<Carousel>
<div />
</Carousel>,
);
expect(container.querySelector('.slick-active')).toBeTruthy();
});
it('should keep initialSlide', () => {
const wrapper = mount(<Carousel initialSlide={1} />);
wrapper.setProps({
children: [<div key="1" />, <div key="2" />, <div key="3" />],
});
wrapper.update();
expect(wrapper.find('.slick-dots li').at(1).hasClass('slick-active')).toBeTruthy();
const { rerender, container } = render(<Carousel initialSlide={1} />);
rerender(
<Carousel initialSlide={1}>
<div key="1" />
<div key="2" />
<div key="3" />
</Carousel>,
);
expect(container.querySelectorAll('.slick-dots li')[1]).toHaveClass('slick-active');
});
});

View File

@ -34,7 +34,7 @@ exports[`renders ./components/cascader/demo/basic.md extend context correctly 1`
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -182,7 +182,7 @@ exports[`renders ./components/cascader/demo/change-on-select.md extend context c
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -332,7 +332,7 @@ exports[`renders ./components/cascader/demo/custom-dropdown.md extend context co
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div>
@ -507,7 +507,7 @@ exports[`renders ./components/cascader/demo/custom-render.md extend context corr
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -660,7 +660,7 @@ exports[`renders ./components/cascader/demo/custom-trigger.md extend context cor
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -785,7 +785,7 @@ exports[`renders ./components/cascader/demo/default-value.md extend context corr
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -959,7 +959,7 @@ exports[`renders ./components/cascader/demo/disabled-option.md extend context co
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -1109,7 +1109,7 @@ exports[`renders ./components/cascader/demo/fields-name.md extend context correc
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -1257,7 +1257,7 @@ exports[`renders ./components/cascader/demo/hover.md extend context correctly 1`
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -1405,7 +1405,7 @@ exports[`renders ./components/cascader/demo/lazy.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -1570,7 +1570,7 @@ exports[`renders ./components/cascader/demo/multiple.md extend context correctly
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -1792,7 +1792,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -1940,7 +1940,7 @@ exports[`renders ./components/cascader/demo/search.md extend context correctly 1
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -2119,7 +2119,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -2310,7 +2310,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -2474,7 +2474,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -2621,7 +2621,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -2768,7 +2768,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -2928,7 +2928,7 @@ exports[`renders ./components/cascader/demo/status.md extend context correctly 1
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3080,7 +3080,7 @@ exports[`renders ./components/cascader/demo/status.md extend context correctly 1
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3192,7 +3192,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -3341,7 +3341,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -3472,7 +3472,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -3621,7 +3621,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div

View File

@ -3,7 +3,7 @@
exports[`Cascader can be selected 1`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: auto;"
style="opacity: 0; min-width: auto;"
>
<div>
<div
@ -135,7 +135,7 @@ exports[`Cascader can be selected 1`] = `
exports[`Cascader can be selected 2`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: auto;"
style="opacity: 0; min-width: auto;"
>
<div>
<div
@ -285,7 +285,7 @@ exports[`Cascader can be selected 2`] = `
exports[`Cascader can be selected 3`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-leave ant-slide-up-leave-start ant-slide-up"
style="pointer-events: none; min-width: auto;"
style="min-width: auto; pointer-events: none;"
>
<div>
<div
@ -435,7 +435,7 @@ exports[`Cascader can be selected 3`] = `
exports[`Cascader can be selected in RTL direction 1`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-cascader-dropdown-rtl ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: auto;"
style="opacity: 0; min-width: auto;"
>
<div>
<div
@ -567,7 +567,7 @@ exports[`Cascader can be selected in RTL direction 1`] = `
exports[`Cascader can be selected in RTL direction 2`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-cascader-dropdown-rtl ant-slide-up-leave ant-slide-up-leave-start ant-slide-up"
style="pointer-events: none; min-width: auto;"
style="min-width: auto; pointer-events: none;"
>
<div>
<div
@ -717,7 +717,7 @@ exports[`Cascader can be selected in RTL direction 2`] = `
exports[`Cascader can be selected in RTL direction 3`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-cascader-dropdown-rtl ant-slide-up-leave ant-slide-up-leave-start ant-slide-up"
style="pointer-events: none; min-width: auto;"
style="min-width: auto; pointer-events: none;"
>
<div>
<div
@ -914,7 +914,7 @@ exports[`Cascader legacy props should support showCheckedStrategy child 1`] = `
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: auto;"
style="opacity: 0; min-width: auto;"
>
<div>
<div
@ -1068,7 +1068,7 @@ exports[`Cascader legacy props should support showCheckedStrategy parent 1`] = `
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: auto;"
style="opacity: 0; min-width: auto;"
>
<div>
<div
@ -1175,7 +1175,7 @@ exports[`Cascader legacy props should support showCheckedStrategy parent 1`] = `
exports[`Cascader popup correctly with defaultValue 1`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: auto;"
style="opacity: 0; min-width: auto;"
>
<div>
<div
@ -1359,7 +1359,7 @@ exports[`Cascader popup correctly with defaultValue RTL 1`] = `
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-cascader-dropdown-rtl ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: auto;"
style="opacity: 0; min-width: auto;"
>
<div>
<div
@ -1622,7 +1622,7 @@ exports[`Cascader rtl render component should be rendered correctly in RTL direc
exports[`Cascader should highlight keyword and filter when search in Cascader 1`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: 0;"
style="opacity: 0; min-width: 0;"
>
<div>
<div
@ -1682,7 +1682,7 @@ exports[`Cascader should highlight keyword and filter when search in Cascader 1`
exports[`Cascader should highlight keyword and filter when search in Cascader with same field name of label and value 1`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: 0;"
style="opacity: 0; min-width: 0;"
>
<div>
<div
@ -1747,7 +1747,7 @@ exports[`Cascader should highlight keyword and filter when search in Cascader wi
exports[`Cascader should render not found content 1`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-select-dropdown-empty ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: 0;"
style="opacity: 0; min-width: 0;"
>
<div>
<div
@ -1823,7 +1823,7 @@ exports[`Cascader should render not found content 1`] = `
exports[`Cascader should show not found content when options.length is 0 1`] = `
<div
class="ant-select-dropdown ant-cascader-dropdown ant-select-dropdown-empty ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none; min-width: 0;"
style="opacity: 0; min-width: 0;"
>
<div>
<div

View File

@ -25,7 +25,7 @@ exports[`CheckboxGroup passes prefixCls down to checkbox 1`] = `
</label>
<label
class="my-checkbox-wrapper my-checkbox-group-item"
style="font-size:12px"
style="font-size: 12px;"
>
<span
class="my-checkbox"

View File

@ -1,10 +1,11 @@
import React, { useState } from 'react';
import { mount, render } from 'enzyme';
import { mount } from 'enzyme';
import Collapse from '../../collapse';
import Table from '../../table';
import Checkbox from '../index';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { render, fireEvent } from '../../../tests/utils';
import Input from '../../input';
describe('CheckboxGroup', () => {
@ -71,9 +72,9 @@ describe('CheckboxGroup', () => {
{ label: 'Orange', value: 'Orange', style: { fontSize: 12 } },
];
const wrapper = render(<Checkbox.Group prefixCls="my-checkbox" options={options} />);
const wrapper = mount(<Checkbox.Group prefixCls="my-checkbox" options={options} />);
expect(wrapper).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('should be controlled by value', () => {
@ -105,34 +106,38 @@ describe('CheckboxGroup', () => {
// https://github.com/ant-design/ant-design/issues/16376
it('onChange should filter removed value', () => {
const onChange = jest.fn();
const wrapper = mount(
const { container, rerender } = render(
<Checkbox.Group defaultValue={[1]} onChange={onChange}>
<Checkbox key={1} value={1} />
<Checkbox key={2} value={2} />
</Checkbox.Group>,
);
wrapper.setProps({
children: [<Checkbox key={2} value={2} />],
});
wrapper.find('.ant-checkbox-input').at(0).simulate('change');
rerender(
<Checkbox.Group defaultValue={[1]} onChange={onChange}>
<Checkbox key={2} value={2} />
</Checkbox.Group>,
);
fireEvent.click(container.querySelector('.ant-checkbox-input'));
expect(onChange).toHaveBeenCalledWith([2]);
});
it('checkbox should register value again after value changed', () => {
const onChange = jest.fn();
const wrapper = mount(
const { container, rerender } = render(
<Checkbox.Group defaultValue={[1]} onChange={onChange}>
<Checkbox key={1} value={1} />
</Checkbox.Group>,
);
wrapper.setProps({
children: [<Checkbox key={1} value={2} />],
});
expect(wrapper.find('.ant-checkbox-input').at(0).prop('checked')).toBe(false);
rerender(
<Checkbox.Group defaultValue={[1]} onChange={onChange}>
<Checkbox key={1} value={2} />
</Checkbox.Group>,
);
expect(container.querySelector('.ant-checkbox-input')).toHaveAttribute('checked');
});
// https://github.com/ant-design/ant-design/issues/17297

View File

@ -19,6 +19,7 @@ export interface CollapsePanelProps {
id?: string;
extra?: React.ReactNode;
collapsible?: CollapsibleType;
children?: React.ReactNode;
}
const CollapsePanel: React.FC<CollapsePanelProps> = props => {

View File

@ -814,7 +814,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div

View File

@ -41,7 +41,7 @@ exports[`renders ./components/comment/demo/basic.md extend context correctly 1`]
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -104,7 +104,7 @@ exports[`renders ./components/comment/demo/basic.md extend context correctly 1`]
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -156,7 +156,7 @@ exports[`renders ./components/comment/demo/basic.md extend context correctly 1`]
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -317,7 +317,7 @@ exports[`renders ./components/comment/demo/list.md extend context correctly 1`]
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -395,7 +395,7 @@ exports[`renders ./components/comment/demo/list.md extend context correctly 1`]
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -15582,12 +15582,12 @@ exports[`ConfigProvider components Modal configProvider 1`] = `
/>
<div
class="config-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="config-modal"
role="document"
role="dialog"
style="width:520px"
>
<div
@ -15674,12 +15674,12 @@ exports[`ConfigProvider components Modal configProvider componentSize large 1`]
/>
<div
class="config-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="config-modal"
role="document"
role="dialog"
style="width:520px"
>
<div
@ -15766,12 +15766,12 @@ exports[`ConfigProvider components Modal configProvider componentSize middle 1`]
/>
<div
class="config-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="config-modal"
role="document"
role="dialog"
style="width:520px"
>
<div
@ -15858,12 +15858,12 @@ exports[`ConfigProvider components Modal configProvider virtual and dropdownMatc
/>
<div
class="ant-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="ant-modal"
role="document"
role="dialog"
style="width:520px"
>
<div
@ -15950,12 +15950,12 @@ exports[`ConfigProvider components Modal normal 1`] = `
/>
<div
class="ant-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="ant-modal"
role="document"
role="dialog"
style="width:520px"
>
<div
@ -16042,12 +16042,12 @@ exports[`ConfigProvider components Modal prefixCls 1`] = `
/>
<div
class="prefix-Modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="prefix-Modal"
role="document"
role="dialog"
style="width:520px"
>
<div
@ -18054,7 +18054,7 @@ exports[`ConfigProvider components Popconfirm configProvider 1`] = `
<div>
<div
class="config-popover config-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-popover-content"
@ -18137,7 +18137,7 @@ exports[`ConfigProvider components Popconfirm configProvider componentSize large
<div>
<div
class="config-popover config-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-popover-content"
@ -18220,7 +18220,7 @@ exports[`ConfigProvider components Popconfirm configProvider componentSize middl
<div>
<div
class="config-popover config-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-popover-content"
@ -18303,7 +18303,7 @@ exports[`ConfigProvider components Popconfirm configProvider virtual and dropdow
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -18386,7 +18386,7 @@ exports[`ConfigProvider components Popconfirm normal 1`] = `
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -18469,7 +18469,7 @@ exports[`ConfigProvider components Popconfirm prefixCls 1`] = `
<div>
<div
class="prefix-Popconfirm prefix-Popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="prefix-Popconfirm-content"
@ -18552,7 +18552,7 @@ exports[`ConfigProvider components Popover configProvider 1`] = `
<div>
<div
class="config-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-popover-content"
@ -18584,7 +18584,7 @@ exports[`ConfigProvider components Popover configProvider componentSize large 1`
<div>
<div
class="config-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-popover-content"
@ -18616,7 +18616,7 @@ exports[`ConfigProvider components Popover configProvider componentSize middle 1
<div>
<div
class="config-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-popover-content"
@ -18648,7 +18648,7 @@ exports[`ConfigProvider components Popover configProvider virtual and dropdownMa
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -18680,7 +18680,7 @@ exports[`ConfigProvider components Popover normal 1`] = `
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -18712,7 +18712,7 @@ exports[`ConfigProvider components Popover prefixCls 1`] = `
<div>
<div
class="prefix-Popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="prefix-Popover-content"
@ -21018,7 +21018,7 @@ exports[`ConfigProvider components Select configProvider 1`] = `
<div>
<div
class="config-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -21146,7 +21146,7 @@ exports[`ConfigProvider components Select configProvider componentSize large 1`]
<div>
<div
class="config-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -21274,7 +21274,7 @@ exports[`ConfigProvider components Select configProvider componentSize middle 1`
<div>
<div
class="config-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -21402,7 +21402,7 @@ exports[`ConfigProvider components Select configProvider virtual and dropdownMat
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -21530,7 +21530,7 @@ exports[`ConfigProvider components Select normal 1`] = `
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -21658,7 +21658,7 @@ exports[`ConfigProvider components Select prefixCls 1`] = `
<div>
<div
class="prefix-Select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -21947,7 +21947,7 @@ exports[`ConfigProvider components Slider configProvider 1`] = `
<div>
<div
class="config-tooltip config-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-tooltip-content"
@ -21998,7 +21998,7 @@ exports[`ConfigProvider components Slider configProvider componentSize large 1`]
<div>
<div
class="config-tooltip config-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-tooltip-content"
@ -22049,7 +22049,7 @@ exports[`ConfigProvider components Slider configProvider componentSize middle 1`
<div>
<div
class="config-tooltip config-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-tooltip-content"
@ -22100,7 +22100,7 @@ exports[`ConfigProvider components Slider configProvider virtual and dropdownMat
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -22151,7 +22151,7 @@ exports[`ConfigProvider components Slider normal 1`] = `
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -22202,7 +22202,7 @@ exports[`ConfigProvider components Slider prefixCls 1`] = `
<div>
<div
class="prefix-Slider-tooltip prefix-Slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="prefix-Slider-tooltip-content"
@ -22958,7 +22958,7 @@ exports[`ConfigProvider components Table configProvider 1`] = `
<div>
<div
class="config-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-table-filter-dropdown"
@ -23238,7 +23238,7 @@ exports[`ConfigProvider components Table configProvider componentSize large 1`]
<div>
<div
class="config-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-table-filter-dropdown"
@ -23518,7 +23518,7 @@ exports[`ConfigProvider components Table configProvider componentSize middle 1`]
<div>
<div
class="config-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-table-filter-dropdown"
@ -23798,7 +23798,7 @@ exports[`ConfigProvider components Table configProvider virtual and dropdownMatc
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-table-filter-dropdown"
@ -24078,7 +24078,7 @@ exports[`ConfigProvider components Table normal 1`] = `
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-table-filter-dropdown"
@ -24358,7 +24358,7 @@ exports[`ConfigProvider components Table prefixCls 1`] = `
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="prefix-Table-filter-dropdown"
@ -25165,7 +25165,7 @@ Array [
<div>
<div
class="config-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-picker-panel-container"
@ -26576,7 +26576,7 @@ Array [
<div>
<div
class="config-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-picker-panel-container"
@ -27987,7 +27987,7 @@ Array [
<div>
<div
class="config-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-picker-panel-container"
@ -29398,7 +29398,7 @@ Array [
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -30809,7 +30809,7 @@ Array [
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -32220,7 +32220,7 @@ Array [
<div>
<div
class="prefix-TimePicker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="prefix-TimePicker-panel-container"
@ -33726,7 +33726,7 @@ Array [
<div>
<div
class="config-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-tooltip-content"
@ -33760,7 +33760,7 @@ Array [
<div>
<div
class="config-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-tooltip-content"
@ -33794,7 +33794,7 @@ Array [
<div>
<div
class="config-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="config-tooltip-content"
@ -33828,7 +33828,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -33862,7 +33862,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -33896,7 +33896,7 @@ Array [
<div>
<div
class="prefix-Tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="prefix-Tooltip-content"
@ -36515,7 +36515,7 @@ exports[`ConfigProvider components TreeSelect configProvider 1`] = `
<div>
<div
class="config-select-dropdown config-tree-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>
@ -36651,7 +36651,7 @@ exports[`ConfigProvider components TreeSelect configProvider componentSize large
<div>
<div
class="config-select-dropdown config-tree-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>
@ -36787,7 +36787,7 @@ exports[`ConfigProvider components TreeSelect configProvider componentSize middl
<div>
<div
class="config-select-dropdown config-tree-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>
@ -36923,7 +36923,7 @@ exports[`ConfigProvider components TreeSelect configProvider virtual and dropdow
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>
@ -37059,7 +37059,7 @@ exports[`ConfigProvider components TreeSelect normal 1`] = `
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>
@ -37195,7 +37195,7 @@ exports[`ConfigProvider components TreeSelect prefixCls 1`] = `
<div>
<div
class="prefix-TreeSelect-dropdown prefix-TreeSelect-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>

View File

@ -1,7 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { render } from '../../../tests/utils';
import ConfigProvider from '..';
import zhCN from '../../locale/zh_CN';
import Form from '../../form';

View File

@ -70,22 +70,12 @@ describe('ConfigProvider.Locale', () => {
// https://github.com/ant-design/ant-design/issues/31592
it('should not reset the component state when switching locale', () => {
class App extends React.Component {
state = {
locale: zhCN,
};
render() {
return (
<ConfigProvider locale={this.state.locale}>
<DatePicker />
<Pagination total={50} />
</ConfigProvider>
);
}
}
const wrapper = mount(<App />);
const wrapper = mount(
<ConfigProvider locale={zhCN}>
<DatePicker />
<Pagination total={50} />
</ConfigProvider>,
);
const datepickerInitProps = wrapper.find('.ant-picker-input input').props();
expect(datepickerInitProps.value).toBe('');
@ -100,7 +90,7 @@ describe('ConfigProvider.Locale', () => {
expect(wrapper.find('.ant-picker-input input').props().value).not.toBe('');
wrapper.setState({ locale: {} });
wrapper.setProps({ locale: {} });
wrapper.find('.ant-pagination-item-3').simulate('click');
const datepickerProps = wrapper.find('.ant-picker-input input').props();

View File

@ -70,9 +70,7 @@ describe('RangePicker', () => {
openPicker(wrapper, 1);
selectCell(wrapper, 'Feb');
closePicker(wrapper, 1);
const { value } = wrapper.state();
const { value } = wrapper.find(Test).state();
expect(value[0].isSame(value[1], 'date')).toBeTruthy();
});
});

View File

@ -44,7 +44,7 @@ Array [
<div>
<div
class="ant-picker-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none;"
style="opacity: 0;"
>
<div
class="ant-picker-panel-container"
@ -667,7 +667,7 @@ Array [
<div>
<div
class="ant-picker-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none;"
style="opacity: 0;"
>
<div
class="ant-picker-panel-container"

View File

@ -147,7 +147,7 @@ Array [
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none;"
style="opacity: 0;"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"

View File

@ -50,7 +50,7 @@ exports[`renders ./components/date-picker/demo/basic.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -648,7 +648,7 @@ exports[`renders ./components/date-picker/demo/basic.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -1282,7 +1282,7 @@ exports[`renders ./components/date-picker/demo/basic.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -1516,7 +1516,7 @@ exports[`renders ./components/date-picker/demo/basic.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -1663,7 +1663,7 @@ exports[`renders ./components/date-picker/demo/basic.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -1904,7 +1904,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -2502,7 +2502,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -3136,7 +3136,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -3370,7 +3370,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -3646,7 +3646,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -4829,7 +4829,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-week-range-wrapper"
@ -6102,7 +6102,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-month-range-wrapper"
@ -6572,7 +6572,7 @@ exports[`renders ./components/date-picker/demo/bordered.md extend context correc
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-year-range-wrapper"
@ -7008,7 +7008,7 @@ exports[`renders ./components/date-picker/demo/date-render.md extend context cor
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -7649,7 +7649,7 @@ exports[`renders ./components/date-picker/demo/date-render.md extend context cor
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -8802,7 +8802,7 @@ exports[`renders ./components/date-picker/demo/disabled.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -9401,7 +9401,7 @@ exports[`renders ./components/date-picker/demo/disabled.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -9679,7 +9679,7 @@ exports[`renders ./components/date-picker/demo/disabled.md extend context correc
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -10885,7 +10885,7 @@ exports[`renders ./components/date-picker/demo/disabled.md extend context correc
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -12033,7 +12033,7 @@ exports[`renders ./components/date-picker/demo/disabled-date.md extend context c
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -13984,7 +13984,7 @@ exports[`renders ./components/date-picker/demo/disabled-date.md extend context c
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -14260,7 +14260,7 @@ exports[`renders ./components/date-picker/demo/disabled-date.md extend context c
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -15442,7 +15442,7 @@ exports[`renders ./components/date-picker/demo/disabled-date.md extend context c
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -16937,7 +16937,7 @@ exports[`renders ./components/date-picker/demo/extra-footer.md extend context co
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -17540,7 +17540,7 @@ exports[`renders ./components/date-picker/demo/extra-footer.md extend context co
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -19538,7 +19538,7 @@ exports[`renders ./components/date-picker/demo/extra-footer.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -20730,7 +20730,7 @@ exports[`renders ./components/date-picker/demo/extra-footer.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -22690,7 +22690,7 @@ exports[`renders ./components/date-picker/demo/extra-footer.md extend context co
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -22964,7 +22964,7 @@ exports[`renders ./components/date-picker/demo/format.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -23586,7 +23586,7 @@ exports[`renders ./components/date-picker/demo/format.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -24208,7 +24208,7 @@ exports[`renders ./components/date-picker/demo/format.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -24466,7 +24466,7 @@ exports[`renders ./components/date-picker/demo/format.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -25165,7 +25165,7 @@ exports[`renders ./components/date-picker/demo/format.md extend context correctl
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -26329,7 +26329,7 @@ exports[`renders ./components/date-picker/demo/format.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -26934,7 +26934,7 @@ exports[`renders ./components/date-picker/demo/mode.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -28393,7 +28393,7 @@ exports[`renders ./components/date-picker/demo/mode.md extend context correctly
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -28725,7 +28725,7 @@ Array [
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -29362,7 +29362,7 @@ Array [
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -30551,7 +30551,7 @@ exports[`renders ./components/date-picker/demo/presetted-ranges.md extend contex
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -31759,7 +31759,7 @@ exports[`renders ./components/date-picker/demo/presetted-ranges.md extend contex
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -33782,7 +33782,7 @@ exports[`renders ./components/date-picker/demo/range-picker.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -34965,7 +34965,7 @@ exports[`renders ./components/date-picker/demo/range-picker.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -36963,7 +36963,7 @@ exports[`renders ./components/date-picker/demo/range-picker.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-week-range-wrapper"
@ -38236,7 +38236,7 @@ exports[`renders ./components/date-picker/demo/range-picker.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-month-range-wrapper"
@ -38707,7 +38707,7 @@ exports[`renders ./components/date-picker/demo/range-picker.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-quarter-range-wrapper"
@ -39005,7 +39005,7 @@ exports[`renders ./components/date-picker/demo/range-picker.md extend context co
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-year-range-wrapper"
@ -39477,7 +39477,7 @@ Array [
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -40691,7 +40691,7 @@ exports[`renders ./components/date-picker/demo/size.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -41289,7 +41289,7 @@ exports[`renders ./components/date-picker/demo/size.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -41565,7 +41565,7 @@ exports[`renders ./components/date-picker/demo/size.md extend context correctly
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -42705,7 +42705,7 @@ exports[`renders ./components/date-picker/demo/size.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -43346,7 +43346,7 @@ exports[`renders ./components/date-picker/demo/start-end.md extend context corre
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -45296,7 +45296,7 @@ exports[`renders ./components/date-picker/demo/start-end.md extend context corre
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -47256,7 +47256,7 @@ exports[`renders ./components/date-picker/demo/status.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -47855,7 +47855,7 @@ exports[`renders ./components/date-picker/demo/status.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -48496,7 +48496,7 @@ exports[`renders ./components/date-picker/demo/status.md extend context correctl
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -49679,7 +49679,7 @@ exports[`renders ./components/date-picker/demo/status.md extend context correctl
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -50827,7 +50827,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -51425,7 +51425,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -51701,7 +51701,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -52842,7 +52842,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -53458,7 +53458,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -54038,7 +54038,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -54296,7 +54296,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -55418,7 +55418,7 @@ exports[`renders ./components/date-picker/demo/suffix.md extend context correctl
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -56052,7 +56052,7 @@ exports[`renders ./components/date-picker/demo/switchable.md extend context corr
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -56275,7 +56275,7 @@ exports[`renders ./components/date-picker/demo/switchable.md extend context corr
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -57691,7 +57691,7 @@ exports[`renders ./components/date-picker/demo/time.md extend context correctly
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -59683,7 +59683,7 @@ exports[`renders ./components/date-picker/demo/time.md extend context correctly
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"

View File

@ -4,7 +4,7 @@ exports[`MonthPicker and WeekPicker render MonthPicker 1`] = `
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -197,7 +197,7 @@ exports[`MonthPicker and WeekPicker render WeekPicker 1`] = `
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"

View File

@ -92,6 +92,7 @@ export interface RowProps {
bordered?: boolean;
colon: boolean;
index: number;
children?: React.ReactNode;
}
const Row: React.FC<RowProps> = props => {

View File

@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import { render } from '../../../tests/utils';
import Drawer from '..';
import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';

View File

@ -1,118 +1,67 @@
import React from 'react';
import { mount } from 'enzyme';
import Drawer from '..';
import Button from '../../button';
class DrawerEventTester extends React.Component {
constructor(props) {
super(props);
this.state = { visible: false };
}
componentDidMount() {
this.setState({ visible: true }); // eslint-disable-line react/no-did-mount-set-state
}
onClose = () => {
this.setState({
visible: false,
});
};
open = () => {
this.setState({
visible: true,
});
};
render() {
const { visible } = this.state;
return (
<div>
<Button onClick={this.open}>open</Button>
<Drawer visible={visible} onClose={this.onClose} getContainer={false} {...this.props}>
Here is content of Drawer
</Drawer>
</div>
);
}
}
import { render, fireEvent } from '../../../tests/utils';
describe('Drawer', () => {
const getDrawer = props => (
<Drawer visible getContainer={false} {...props}>
Here is content of Drawer
</Drawer>
);
it('render correctly', () => {
const wrapper = mount(<DrawerEventTester />);
const body = wrapper.find('.ant-drawer-body').exists();
const { container, asFragment, rerender } = render(getDrawer());
expect(container.querySelector('.ant-drawer-body')).toBeTruthy();
expect(body).toBe(true);
wrapper.find('button.ant-btn').simulate('click');
rerender(getDrawer({ visible: false }));
const content = wrapper.find('.ant-drawer-body').getDOMNode().innerHTML;
expect(content).toBe('Here is content of Drawer');
expect(container.querySelector('.ant-drawer-body').textContent).toEqual(
'Here is content of Drawer',
);
expect(wrapper.render()).toMatchSnapshot();
expect(asFragment().firstChild).toMatchSnapshot();
});
it('mask trigger onClose', () => {
const wrapper = mount(<DrawerEventTester />);
const onClose = jest.fn();
const { container } = render(getDrawer({ onClose }));
wrapper.find('button.ant-btn').simulate('click');
expect(wrapper.instance().state.visible).toBe(true);
wrapper.find('.ant-drawer-mask').simulate('click');
expect(wrapper.instance().state.visible).toBe(false);
fireEvent.click(container.querySelector('.ant-drawer-mask'));
expect(onClose).toHaveBeenCalled();
});
it('close button trigger onClose', () => {
const wrapper = mount(<DrawerEventTester />);
const onClose = jest.fn();
const { container } = render(getDrawer({ onClose }));
wrapper.find('button.ant-btn').simulate('click');
expect(wrapper.instance().state.visible).toBe(true);
wrapper.find('.ant-drawer-close').simulate('click');
expect(wrapper.instance().state.visible).toBe(false);
fireEvent.click(container.querySelector('.ant-drawer-close'));
expect(onClose).toHaveBeenCalled();
});
it('maskClosable no trigger onClose', () => {
const wrapper = mount(<DrawerEventTester maskClosable={false} />);
const onClose = jest.fn();
const { container } = render(getDrawer({ onClose, maskClosable: false }));
wrapper.find('button.ant-btn').simulate('click');
expect(wrapper.instance().state.visible).toBe(true);
wrapper.find('.ant-drawer-mask').simulate('click');
expect(wrapper.instance().state.visible).toBe(true);
fireEvent.click(container.querySelector('.ant-drawer-mask'));
expect(onClose).not.toHaveBeenCalled();
});
it('dom should be removed after close when destroyOnClose is true', () => {
const wrapper = mount(<DrawerEventTester destroyOnClose />);
wrapper.find('button.ant-btn').simulate('click');
expect(wrapper.find('.ant-drawer-wrapper-body').exists()).toBe(true);
const { container, rerender } = render(getDrawer({ destroyOnClose: true }));
wrapper.setState({
visible: false,
});
wrapper.find('.ant-drawer-wrapper-body').simulate('transitionend');
expect(wrapper.find('.ant-drawer-wrapper-body').exists()).toBe(false);
rerender(getDrawer({ destroyOnClose: true, visible: false }));
fireEvent.transitionEnd(container.querySelector('.ant-drawer-wrapper-body'));
expect(container.querySelector('.ant-drawer-wrapper-body')).toBeFalsy();
});
it('dom should be existed after close when destroyOnClose is false', () => {
const wrapper = mount(<DrawerEventTester />);
wrapper.find('button.ant-btn').simulate('click');
expect(wrapper.find('.ant-drawer-wrapper-body').exists()).toBe(true);
const { container, rerender } = render(getDrawer());
expect(container.querySelector('.ant-drawer-wrapper-body')).toBeTruthy();
wrapper.setState({
visible: false,
});
wrapper.find('.ant-drawer-wrapper-body').simulate('transitionend');
expect(wrapper.find('.ant-drawer-wrapper-body').exists()).toBe(true);
});
rerender(getDrawer({ visible: false }));
fireEvent.transitionEnd(container.querySelector('.ant-drawer-wrapper-body'));
it('no mask and no closable', () => {
const wrapper = mount(<DrawerEventTester destroyOnClose />);
wrapper.find('button.ant-btn').simulate('click');
expect(wrapper.instance().state.visible).toBe(true);
wrapper.find('.ant-drawer-close').simulate('click');
expect(wrapper.instance().state.visible).toBe(false);
expect(container.querySelector('.ant-drawer-wrapper-body')).toBeTruthy();
});
});

View File

@ -101,6 +101,8 @@ class MultiDrawer extends React.Component {
</Button>
</div>
</Drawer>
<div className="childrenDrawer">{String(childrenDrawer)}</div>
</div>
);
}
@ -124,7 +126,7 @@ describe('Drawer', () => {
expect(translateX).toEqual('translateX(180px)');
expect(wrapper.find('#two_drawer_text').exists()).toBe(true);
wrapper.find('.Two-level .ant-drawer-close').simulate('click');
expect(wrapper.state().childrenDrawer).toBe(false);
expect(wrapper.find('.childrenDrawer').text()).toEqual('false');
});
it('render top MultiDrawer', () => {

View File

@ -1,74 +1,64 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Drawer render correctly 1`] = `
<div>
<button
class="ant-btn ant-btn-default"
type="button"
>
<span>
open
</span>
</button>
<div
class=""
>
<div
class=""
class="ant-drawer ant-drawer-right"
tabindex="-1"
>
<div
class="ant-drawer ant-drawer-right ant-drawer-open"
tabindex="-1"
class="ant-drawer-mask"
/>
<div
class="ant-drawer-content-wrapper"
style="width: 378px; transform: translateX(100%);"
>
<div
class="ant-drawer-mask"
/>
<div
class="ant-drawer-content-wrapper"
style="width: 378px;"
class="ant-drawer-content"
>
<div
class="ant-drawer-content"
class="ant-drawer-wrapper-body"
>
<div
class="ant-drawer-wrapper-body"
class="ant-drawer-header ant-drawer-header-close-only"
>
<div
class="ant-drawer-header ant-drawer-header-close-only"
class="ant-drawer-header-title"
>
<div
class="ant-drawer-header-title"
<button
aria-label="Close"
class="ant-drawer-close"
type="button"
>
<button
aria-label="Close"
class="ant-drawer-close"
type="button"
<span
aria-label="close"
class="anticon anticon-close"
role="img"
>
<span
aria-label="close"
class="anticon anticon-close"
role="img"
<svg
aria-hidden="true"
data-icon="close"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<svg
aria-hidden="true"
data-icon="close"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
/>
</svg>
</span>
</button>
</div>
</div>
<div
class="ant-drawer-body"
>
Here is content of Drawer
<path
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
/>
</svg>
</span>
</button>
</div>
</div>
<div
class="ant-drawer-body"
>
Here is content of Drawer
</div>
</div>
</div>
</div>

View File

@ -3,7 +3,7 @@ type: Feedback
category: Components
subtitle:
title: Drawer
cover: https://gw.alipayobjects.com/zos/alicdn/7z8NJQhFb/Drawer.svg
cover: https://img.alicdn.com/imgextra/i4/O1CN019djdZP1OHwXSRGCOW_!!6000000001681-55-tps-161-117.svg
---
A panel which slides in from the edge of the screen.

View File

@ -3,7 +3,7 @@ type: 反馈
category: Components
subtitle: 抽屉
title: Drawer
cover: https://gw.alipayobjects.com/zos/alicdn/7z8NJQhFb/Drawer.svg
cover: https://img.alicdn.com/imgextra/i4/O1CN019djdZP1OHwXSRGCOW_!!6000000001681-55-tps-161-117.svg
---
屏幕边缘滑出的浮层面板。

View File

@ -11,7 +11,7 @@ Array [
<div>
<div
class="ant-dropdown move-up-appear move-up-appear-prepare move-up"
style="opacity: 0; pointer-events: none;"
style="opacity: 0;"
>
<div>
menu
@ -32,7 +32,7 @@ Array [
<div>
<div
class="ant-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0; pointer-events: none;"
style="opacity: 0;"
>
<span>
string

View File

@ -62,7 +62,7 @@ describe('DropdownButton', () => {
</Menu>
);
const wrapper = mount(<Dropdown.Button overlay={menu} />);
expect(wrapper.type().__ANT_BUTTON).toBe(true);
expect(wrapper.find(Dropdown.Button).type().__ANT_BUTTON).toBe(true);
});
it('should pass mouseEnterDelay and mouseLeaveDelay to Dropdown', () => {

View File

@ -135,7 +135,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -255,7 +255,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -371,7 +371,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -519,7 +519,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light"
@ -541,7 +541,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -574,7 +574,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -601,7 +601,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -623,7 +623,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -806,7 +806,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light"
@ -828,7 +828,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -861,7 +861,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -888,7 +888,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -910,7 +910,7 @@ exports[`renders ./components/empty/demo/config-provider.md extend context corre
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -1,5 +1,5 @@
import React from 'react';
import { render, mount } from 'enzyme';
import { mount } from 'enzyme';
import Empty from '..';
import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';
@ -25,6 +25,6 @@ describe('Empty', () => {
<Empty />
</ConfigProvider>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@ -112,7 +112,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -364,7 +364,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1098,7 +1098,7 @@ exports[`renders ./components/form/demo/control-hooks.md extend context correctl
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1364,7 +1364,7 @@ exports[`renders ./components/form/demo/control-ref.md extend context correctly
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1605,7 +1605,7 @@ exports[`renders ./components/form/demo/customized-form-controls.md extend conte
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2613,7 +2613,7 @@ exports[`renders ./components/form/demo/dynamic-form-items-complex.md extend con
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -4536,7 +4536,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -4636,7 +4636,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -4850,7 +4850,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5110,7 +5110,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5278,7 +5278,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5388,7 +5388,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5779,7 +5779,7 @@ exports[`renders ./components/form/demo/required-mark.md extend context correctl
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -5858,7 +5858,7 @@ exports[`renders ./components/form/demo/required-mark.md extend context correctl
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -6112,7 +6112,7 @@ exports[`renders ./components/form/demo/size.md extend context correctly 1`] = `
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -6250,7 +6250,7 @@ exports[`renders ./components/form/demo/size.md extend context correctly 1`] = `
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>
@ -6428,7 +6428,7 @@ exports[`renders ./components/form/demo/size.md extend context correctly 1`] = `
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -6574,7 +6574,7 @@ exports[`renders ./components/form/demo/size.md extend context correctly 1`] = `
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -7375,7 +7375,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -7996,7 +7996,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -9970,7 +9970,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -10269,7 +10269,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -11475,7 +11475,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -13457,7 +13457,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -15095,7 +15095,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -15279,7 +15279,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -15585,7 +15585,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -16999,7 +16999,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -17645,7 +17645,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -19141,7 +19141,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -20295,7 +20295,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -20500,7 +20500,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -20647,7 +20647,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div>
@ -20863,7 +20863,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -21488,7 +21488,7 @@ exports[`renders ./components/form/demo/validate-static.md extend context correc
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"

View File

@ -1,6 +1,5 @@
import React, { Component, useState } from 'react';
import { mount } from 'enzyme';
import { render, fireEvent } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import scrollIntoView from 'scroll-into-view-if-needed';
import Form from '..';
@ -12,7 +11,7 @@ import Select from '../../select';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { sleep } from '../../../tests/utils';
import { sleep, render, fireEvent } from '../../../tests/utils';
import ConfigProvider from '../../config-provider';
import zhCN from '../../locale/zh_CN';
@ -453,6 +452,9 @@ describe('Form', () => {
</Form.Item>
</Form>
</div>,
{
strictMode: false,
},
);
expect(shouldNotRender).toHaveBeenCalledTimes(1);
@ -718,7 +720,9 @@ describe('Form', () => {
);
};
const wrapper = mount(<App />);
const wrapper = mount(<App />, {
strictMode: false,
});
for (let i = 0; i < 5; i += 1) {
wrapper.find('button').simulate('click');
}
@ -741,7 +745,9 @@ describe('Form', () => {
</Form>
);
const wrapper = mount(<Demo />);
const wrapper = mount(<Demo />, {
strictMode: false,
});
renderTimes = 0;
wrapper.find('input').simulate('change', {
@ -771,33 +777,25 @@ describe('Form', () => {
});
it('Remove Field should also reset error', async () => {
class Demo extends React.Component {
state = {
showA: true,
};
const Demo = ({ showA }) => (
<Form>
{showA ? (
<Form.Item name="a" help="error">
<input />
</Form.Item>
) : (
<Form.Item name="b">
<input />
</Form.Item>
)}
</Form>
);
render() {
return (
<Form>
{this.state.showA ? (
<Form.Item name="a" help="error">
<input />
</Form.Item>
) : (
<Form.Item name="b">
<input />
</Form.Item>
)}
</Form>
);
}
}
const wrapper = mount(<Demo />);
const wrapper = mount(<Demo showA />);
await Promise.resolve();
expect(wrapper.find('.ant-form-item').last().hasClass('ant-form-item-with-help')).toBeTruthy();
wrapper.setState({ showA: false });
wrapper.setProps({ showA: false });
await Promise.resolve();
wrapper.update();
expect(wrapper.find('.ant-form-item').last().hasClass('ant-form-item-with-help')).toBeFalsy();

View File

@ -1,10 +1,9 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { render, fireEvent } from '@testing-library/react';
import Form from '..';
import Input from '../../input';
import Button from '../../button';
import { sleep } from '../../../tests/utils';
import { sleep, render, fireEvent } from '../../../tests/utils';
describe('Form.List', () => {
async function change(wrapper, index, value) {
@ -85,6 +84,7 @@ describe('Form.List', () => {
</Form.Item>
));
// FIXME: @zombieJ React 18 StrictMode
testList('nest noStyle', field => (
<Form.Item key={field.key}>
<Form.Item noStyle {...field} rules={[{ required: true }]}>

View File

@ -19,7 +19,7 @@ import React from 'react';
import { Form, Input, InputNumber, Typography } from 'antd';
const Demo = () => {
const [form] = Form.useForm<{ user: { name: string; age: number } }>();
const [form] = Form.useForm<{ name: string; age: number }>();
const nameValue = Form.useWatch('name', form);
return (

View File

@ -12,13 +12,14 @@ export default function useFrameState<ValueType>(
const batchRef = useRef<Updater<ValueType>[]>([]);
const destroyRef = useRef(false);
React.useEffect(
() => () => {
React.useEffect(() => {
destroyRef.current = false;
return () => {
destroyRef.current = true;
raf.cancel(frameRef.current!);
},
[],
);
frameRef.current = null;
};
}, []);
function setFrameValue(updater: Updater<ValueType>) {
if (destroyRef.current) {

View File

@ -922,7 +922,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1042,7 +1042,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1162,7 +1162,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -1,7 +1,7 @@
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import { render } from '@testing-library/react';
import { mount } from 'enzyme';
import { render } from '../../../tests/utils';
import { Col, Row } from '..';
// eslint-disable-next-line no-unused-vars
import * as styleChecker from '../../_util/styleChecker';

View File

@ -286,6 +286,122 @@ Array [
]
`;
exports[`renders ./components/image/demo/preview-group-top-progress.md extend context correctly 1`] = `
Array [
<div
class="ant-image"
style="width:150px"
>
<img
class="ant-image-img"
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
/>
<div
class="ant-image-mask"
>
<div
class="ant-image-mask-info"
>
<span
aria-label="eye"
class="anticon anticon-eye"
role="img"
>
<svg
aria-hidden="true"
data-icon="eye"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"
/>
</svg>
</span>
Preview
</div>
</div>
</div>,
<div
class="ant-image"
style="width:150px"
>
<img
class="ant-image-img"
src="https://gw.alipayobjects.com/zos/antfincdn/aPkFc8Sj7n/method-draw-image.svg"
/>
<div
class="ant-image-mask"
>
<div
class="ant-image-mask-info"
>
<span
aria-label="eye"
class="anticon anticon-eye"
role="img"
>
<svg
aria-hidden="true"
data-icon="eye"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"
/>
</svg>
</span>
Preview
</div>
</div>
</div>,
<div
class="ant-image"
style="width:150px"
>
<img
class="ant-image-img"
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
/>
<div
class="ant-image-mask"
>
<div
class="ant-image-mask-info"
>
<span
aria-label="eye"
class="anticon anticon-eye"
role="img"
>
<svg
aria-hidden="true"
data-icon="eye"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"
/>
</svg>
</span>
Preview
</div>
</div>
</div>,
]
`;
exports[`renders ./components/image/demo/preview-group-visible.md extend context correctly 1`] = `
Array [
<div

View File

@ -286,6 +286,122 @@ Array [
]
`;
exports[`renders ./components/image/demo/preview-group-top-progress.md correctly 1`] = `
Array [
<div
class="ant-image"
style="width:150px"
>
<img
class="ant-image-img"
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
/>
<div
class="ant-image-mask"
>
<div
class="ant-image-mask-info"
>
<span
aria-label="eye"
class="anticon anticon-eye"
role="img"
>
<svg
aria-hidden="true"
data-icon="eye"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"
/>
</svg>
</span>
Preview
</div>
</div>
</div>,
<div
class="ant-image"
style="width:150px"
>
<img
class="ant-image-img"
src="https://gw.alipayobjects.com/zos/antfincdn/aPkFc8Sj7n/method-draw-image.svg"
/>
<div
class="ant-image-mask"
>
<div
class="ant-image-mask-info"
>
<span
aria-label="eye"
class="anticon anticon-eye"
role="img"
>
<svg
aria-hidden="true"
data-icon="eye"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"
/>
</svg>
</span>
Preview
</div>
</div>
</div>,
<div
class="ant-image"
style="width:150px"
>
<img
class="ant-image-img"
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
/>
<div
class="ant-image-mask"
>
<div
class="ant-image-mask-info"
>
<span
aria-label="eye"
class="anticon anticon-eye"
role="img"
>
<svg
aria-hidden="true"
data-icon="eye"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"
/>
</svg>
</span>
Preview
</div>
</div>
</div>,
]
`;
exports[`renders ./components/image/demo/preview-group-visible.md correctly 1`] = `
Array [
<div

View File

@ -0,0 +1,37 @@
---
order: 100
title:
zh-CN: 多图预览时顶部进度自定义
en-US: Top progress customization when previewing multiple images
debug: true
---
## zh-CN
多图预览时顶部展示进度, 支持自定义
## en-US
The progress is displayed at the top of the multi-image preview, and customization is supported
```jsx
import { Image } from 'antd';
const App = () => (
<Image.PreviewGroup
preview={{ countRender: (current, total) => `当前 ${current} / 总计 ${total}` }}
>
<Image width={150} src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" />
<Image
width={150}
src="https://gw.alipayobjects.com/zos/antfincdn/aPkFc8Sj7n/method-draw-image.svg"
/>
<Image
width={150}
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
/>
</Image.PreviewGroup>
);
export default App;
```

View File

@ -33,12 +33,12 @@ Previewable image.
{
visible?: boolean;
onVisibleChange?: (visible, prevVisible) => void;
getContainer?: string | HTMLElement | (() => HTMLElement); // V4.8.0
src?: string; // V4.10.0
mask?: ReactNode; // V4.9.0
maskClassName?: string; // V4.11.0
current?: number; // V4.12.0 Only support PreviewGroup
countRender?: (current: number, total: number) => string // Only support PreviewGroup
getContainer?: string | HTMLElement | (() => HTMLElement); // v4.8.0
src?: string; // v4.10.0
mask?: ReactNode; // v4.9.0
maskClassName?: string; // v4.11.0
current?: number; // v4.12.0 Only support PreviewGroup
countRender?: (current: number, total: number) => string // v4.20.0 Only support PreviewGroup
}
```

View File

@ -34,12 +34,12 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/D1dXz9PZqa/image.svg
{
visible?: boolean;
onVisibleChange?: (visible, prevVisible) => void;
getContainer?: string | HTMLElement | (() => HTMLElement); // V4.8.0
src?: string; // V4.10.0
mask?: ReactNode; // V4.9.0
maskClassName?: string; // V4.11.0
current?: number; // V4.12.0 仅支持 PreviewGroup
countRender?: (current: number, total: number) => string // 仅支持 PreviewGroup
getContainer?: string | HTMLElement | (() => HTMLElement); // v4.8.0
src?: string; // v4.10.0
mask?: ReactNode; // v4.9.0
maskClassName?: string; // v4.11.0
current?: number; // v4.12.0 仅支持 PreviewGroup
countRender?: (current: number, total: number) => string // v4.20.0 仅支持 PreviewGroup
}
```

View File

@ -135,6 +135,12 @@
}
}
&-progress {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
&-icon {
font-size: @image-preview-operation-size;
}

View File

@ -150,7 +150,7 @@ exports[`renders ./components/input-number/demo/addon.md extend context correctl
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -370,7 +370,7 @@ exports[`renders ./components/input-number/demo/addon.md extend context correctl
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -670,7 +670,7 @@ exports[`renders ./components/input-number/demo/addon.md extend context correctl
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div

View File

@ -80,7 +80,7 @@ exports[`renders ./components/input/demo/addon.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -230,7 +230,7 @@ exports[`renders ./components/input/demo/addon.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -493,7 +493,7 @@ exports[`renders ./components/input/demo/addon.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -668,7 +668,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -851,7 +851,7 @@ Array [
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -1448,7 +1448,7 @@ Array [
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -2846,7 +2846,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3018,7 +3018,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-tree-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3136,7 +3136,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -3360,7 +3360,7 @@ Array [
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -4496,7 +4496,7 @@ Array [
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -4758,7 +4758,7 @@ Array [
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5298,7 +5298,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -5359,7 +5359,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5666,7 +5666,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5905,7 +5905,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-picker-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-panel-container"
@ -6552,7 +6552,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-picker-dropdown ant-picker-dropdown-range"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-picker-range-wrapper ant-picker-date-range-wrapper"
@ -7686,7 +7686,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -7827,7 +7827,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -7973,7 +7973,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -8142,7 +8142,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -8280,7 +8280,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -8399,7 +8399,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -8539,7 +8539,7 @@ exports[`renders ./components/input/demo/group.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown ant-cascader-dropdown"
style="opacity:0;pointer-events:none;min-width:auto"
style="opacity:0;min-width:auto"
>
<div>
<div
@ -8812,7 +8812,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -9764,7 +9764,7 @@ Array [
<div>
<div
class="ant-tooltip numeric-input"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -3,6 +3,7 @@ import { mount } from 'enzyme';
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
import { InputRef } from '../Input';
import Input from '..';
import { render, fireEvent } from '../../../tests/utils';
const { TextArea } = Input;
@ -58,12 +59,11 @@ describe('Input.Focus', () => {
});
it('disabled should reset focus', () => {
const wrapper = mount(<Input allowClear />);
wrapper.find('input').simulate('focus');
expect(wrapper.exists('.ant-input-affix-wrapper-focused')).toBeTruthy();
const { rerender, container } = render(<Input allowClear />);
fireEvent.focus(container.querySelector('input')!);
expect(container.querySelector('.ant-input-affix-wrapper-focused')).toBeTruthy();
wrapper.setProps({ disabled: true });
wrapper.update();
expect(wrapper.exists('.ant-input-affix-wrapper-focused')).toBeFalsy();
rerender(<Input allowClear disabled />);
expect(container.querySelector('.ant-input-affix-wrapper-focused')).toBeFalsy();
});
});

View File

@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { mount } from 'enzyme';
import { render, fireEvent } from '@testing-library/react';
import { render, fireEvent } from '../../../tests/utils';
// eslint-disable-next-line import/no-unresolved
import Form from '../../form';
import Input, { InputProps, InputRef } from '..';

View File

@ -1,10 +1,9 @@
import React, { useState } from 'react';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import RcTextArea from 'rc-textarea';
import Input from '..';
import focusTest from '../../../tests/shared/focusTest';
import { sleep } from '../../../tests/utils';
import { sleep, render } from '../../../tests/utils';
const { TextArea } = Input;

View File

@ -96,9 +96,9 @@ Supports all props of `Input`.
## FAQ
### Why Input lose focus when change `prefix/suffix`
### Why Input lose focus when change `prefix/suffix/showCount`
When Input dynamic add or remove `prefix/suffix` will make React recreate the dom structure and new input will be not focused. You can set an empty `<span />` element to keep the dom structure:
When Input dynamic add or remove `prefix/suffix/showCount` will make React recreate the dom structure and new input will be not focused. You can set an empty `<span />` element to keep the dom structure:
```jsx
const suffix = condition ? <Icon type="smile" /> : <span />;

View File

@ -97,9 +97,9 @@ Input 的其他属性和 React 自带的 [input](https://reactjs.org/docs/dom-el
## FAQ
### 为什么我动态改变 `prefix/suffix` 时Input 会失去焦点?
### 为什么我动态改变 `prefix/suffix/showCount` 时Input 会失去焦点?
当 Input 动态添加或者删除 `prefix/suffix` 时React 会重新创建 DOM 结构而新的 input 是没有焦点的。你可以预设一个空的 `<span />` 来保持 DOM 结构不变:
当 Input 动态添加或者删除 `prefix/suffix/showCount` 时React 会重新创建 DOM 结构而新的 input 是没有焦点的。你可以预设一个空的 `<span />` 来保持 DOM 结构不变:
```jsx
const suffix = condition ? <Icon type="smile" /> : <span />;

View File

@ -37,47 +37,27 @@ exports[`Layout rtl render component should be rendered correctly in RTL directi
`;
exports[`Layout should be controlled by collapsed 1`] = `
<Sider>
<aside
className="ant-layout-sider ant-layout-sider-dark"
style={
Object {
"flex": "0 0 200px",
"maxWidth": "200px",
"minWidth": "200px",
"width": "200px",
}
}
<aside
class="ant-layout-sider ant-layout-sider-dark"
style="flex: 0 0 200px; max-width: 200px; min-width: 200px; width: 200px;"
>
<div
class="ant-layout-sider-children"
>
<div
className="ant-layout-sider-children"
>
Sider
</div>
</aside>
</Sider>
Sider
</div>
</aside>
`;
exports[`Layout should be controlled by collapsed 2`] = `
<Sider
collapsed={true}
<aside
class="ant-layout-sider ant-layout-sider-dark ant-layout-sider-collapsed"
style="max-width: 80px; min-width: 80px; width: 80px; flex: 0 0 80px;"
>
<aside
className="ant-layout-sider ant-layout-sider-dark ant-layout-sider-collapsed"
style={
Object {
"flex": "0 0 80px",
"maxWidth": "80px",
"minWidth": "80px",
"width": "80px",
}
}
<div
class="ant-layout-sider-children"
>
<div
className="ant-layout-sider-children"
>
Sider
</div>
</aside>
</Sider>
Sider
</div>
</aside>
`;

View File

@ -176,10 +176,10 @@ describe('Layout', () => {
it('should be controlled by collapsed', () => {
const wrapper = mount(<Sider>Sider</Sider>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
wrapper.setProps({ collapsed: true });
wrapper.update();
expect(wrapper).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('should not add ant-layout-has-sider when `hasSider` is `false`', () => {

View File

@ -1,5 +1,5 @@
import React from 'react';
import { render, mount } from 'enzyme';
import { mount } from 'enzyme';
import List from '..';
import ConfigProvider from '../../config-provider';
@ -126,7 +126,7 @@ describe('List Item Layout', () => {
/>
</ConfigProvider>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('rowKey could be string', () => {

View File

@ -396,7 +396,7 @@ exports[`List.pagination should change page size work 2`] = `
<div>
<div
class="ant-select-dropdown ant-slide-up-enter ant-slide-up-enter-prepare ant-slide-up"
style="pointer-events: none; min-width: 0; opacity: 0;"
style="min-width: 0; opacity: 0;"
>
<div>
<div

View File

@ -257,27 +257,19 @@ describe('Locale Provider', () => {
});
it('set moment locale when locale changes', () => {
class Test extends React.Component {
state = {
locale: zhCN,
};
const Test = ({ locale }) => (
<LocaleProvider locale={locale}>
<div>
<DatePicker defaultValue={moment()} open />
</div>
</LocaleProvider>
);
render() {
const { locale } = this.state;
return (
<LocaleProvider locale={locale}>
<div>
<DatePicker defaultValue={moment()} open />
</div>
</LocaleProvider>
);
}
}
const wrapper = mount(<Test />);
const wrapper = mount(<Test locale={zhCN} />);
expect(wrapper.render()).toMatchSnapshot();
wrapper.setState({ locale: frFR });
wrapper.setProps({ locale: frFR });
expect(wrapper.render()).toMatchSnapshot();
wrapper.setState({ locale: null });
wrapper.setProps({ locale: null });
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@ -7,13 +7,13 @@ import {
PieChartOutlined,
UserOutlined,
} from '@ant-design/icons';
import { render, fireEvent } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import Menu from '..';
import Layout from '../../layout';
import Tooltip from '../../tooltip';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { render, fireEvent } from '../../../tests/utils';
import collapseMotion from '../../_util/motion';
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
@ -792,13 +792,23 @@ describe('Menu', () => {
const onOpen = jest.fn();
const onClose = jest.fn();
render(
<Menu defaultOpenKeys={['1']} mode="inline" onOpen={onOpen} onClose={onClose}>
<SubMenu key="1" title="submenu1">
<Menu.Item key="submenu1">Option 1</Menu.Item>
<Menu.Item key="submenu2">Option 2</Menu.Item>
</SubMenu>
<Menu.Item key="2">menu2</Menu.Item>
</Menu>,
<Menu
defaultOpenKeys={['1']}
mode="inline"
onOpen={onOpen}
onClose={onClose}
items={[
{
key: '1',
label: 'submenu1',
children: [
{ key: 'submenu1', label: 'Option 1' },
{ key: 'submenu2', label: 'Option 2' },
],
},
{ key: '2', label: 'menu2' },
]}
/>,
);
expect(errorSpy.mock.calls.length).toBe(1);

View File

@ -75,7 +75,7 @@ const items = [
| disabled | 是否禁用 | boolean | false | |
| icon | 菜单图标 | ReactNode | - | |
| key | item 的唯一标志 | string | - | |
| label | 菜单项标题 | string | - | |
| label | 菜单项标题 | ReactNode | - | |
| title | 设置收缩时展示的悬浮标题 | string | - | |
> 注意:`icon` 是 `4.2.0` 新增的属性,之前的版本请使用下面的方式定义图标。

View File

@ -15,12 +15,12 @@ exports[`Modal render correctly 1`] = `
/>
<div
class="ant-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="ant-modal ant-zoom-appear ant-zoom-appear-prepare ant-zoom"
role="document"
role="dialog"
style="width: 520px;"
>
<div
@ -114,12 +114,12 @@ exports[`Modal render without footer 1`] = `
/>
<div
class="ant-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="ant-modal ant-zoom-appear ant-zoom-appear-prepare ant-zoom"
role="document"
role="dialog"
style="width: 520px;"
>
<div
@ -189,12 +189,12 @@ exports[`Modal support closeIcon 1`] = `
/>
<div
class="ant-modal-wrap"
role="dialog"
tabindex="-1"
>
<div
aria-modal="true"
class="ant-modal ant-zoom-appear ant-zoom-appear-prepare ant-zoom"
role="document"
role="dialog"
style="width: 520px;"
>
<div

View File

@ -733,7 +733,7 @@ exports[`renders ./components/page-header/demo/content.md extend context correct
<div>
<div
class="ant-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light"
@ -761,7 +761,7 @@ exports[`renders ./components/page-header/demo/content.md extend context correct
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -800,7 +800,7 @@ exports[`renders ./components/page-header/demo/content.md extend context correct
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -839,7 +839,7 @@ exports[`renders ./components/page-header/demo/content.md extend context correct
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -866,7 +866,7 @@ exports[`renders ./components/page-header/demo/content.md extend context correct
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -888,7 +888,7 @@ exports[`renders ./components/page-header/demo/content.md extend context correct
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -910,7 +910,7 @@ exports[`renders ./components/page-header/demo/content.md extend context correct
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1607,7 +1607,7 @@ exports[`renders ./components/page-header/demo/responsive.md extend context corr
<div>
<div
class="ant-tabs-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<ul
aria-label="expanded dropdown"

View File

@ -1,5 +1,5 @@
import React from 'react';
import { mount, render } from 'enzyme';
import { mount } from 'enzyme';
import PageHeader from '..';
import Breadcrumb from '../../breadcrumb';
import ConfigProvider from '../../config-provider';
@ -109,15 +109,13 @@ describe('PageHeader', () => {
});
it('pageHeader should support className', () => {
const wrapper = render(
<PageHeader title="Page Title" className="not-works" backIcon={false} />,
);
expect(wrapper).toMatchSnapshot();
const wrapper = mount(<PageHeader title="Page Title" className="not-works" backIcon={false} />);
expect(wrapper.render()).toMatchSnapshot();
});
it('pageHeader should not render blank dom', () => {
const wrapper = render(<PageHeader title={false} />);
expect(wrapper).toMatchSnapshot();
const wrapper = mount(<PageHeader title={false} />);
expect(wrapper.render()).toMatchSnapshot();
});
it('breadcrumbs and back icon can coexist', () => {
@ -149,7 +147,7 @@ describe('PageHeader', () => {
</ConfigProvider>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('change container width', async () => {

View File

@ -219,7 +219,7 @@ exports[`renders ./components/pagination/demo/all.md extend context correctly 1`
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -716,7 +716,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1073,7 +1073,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1516,7 +1516,7 @@ exports[`renders ./components/pagination/demo/itemRender.md extend context corre
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1875,7 +1875,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2243,7 +2243,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2690,7 +2690,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3142,7 +3142,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3562,7 +3562,7 @@ exports[`renders ./components/pagination/demo/more.md extend context correctly 1
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -4052,7 +4052,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -4364,7 +4364,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div

View File

@ -13,7 +13,7 @@ Array [
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -98,7 +98,7 @@ Array [
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -183,7 +183,7 @@ exports[`renders ./components/popconfirm/demo/dynamic-trigger.md extend context
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -284,7 +284,7 @@ Array [
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -373,7 +373,7 @@ Array [
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -466,7 +466,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -549,7 +549,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -632,7 +632,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -719,7 +719,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -802,7 +802,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -885,7 +885,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -972,7 +972,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -1055,7 +1055,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -1138,7 +1138,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -1225,7 +1225,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -1308,7 +1308,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -1391,7 +1391,7 @@ exports[`renders ./components/popconfirm/demo/placement.md extend context correc
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -1480,7 +1480,7 @@ Array [
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"

View File

@ -1,10 +1,9 @@
import React from 'react';
import { mount } from 'enzyme';
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import { render, fireEvent } from '@testing-library/react';
import Popconfirm from '..';
import mountTest from '../../../tests/shared/mountTest';
import { sleep } from '../../../tests/utils';
import { sleep, render, fireEvent } from '../../../tests/utils';
import rtlTest from '../../../tests/shared/rtlTest';
import Button from '../../button';

View File

@ -13,7 +13,7 @@ Array [
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -59,7 +59,7 @@ Array [
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -110,7 +110,7 @@ Array [
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -163,7 +163,7 @@ Array [
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -211,7 +211,7 @@ Array [
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -251,7 +251,7 @@ Array [
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -304,7 +304,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -354,7 +354,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -404,7 +404,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -458,7 +458,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -508,7 +508,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -558,7 +558,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -612,7 +612,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -662,7 +662,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -712,7 +712,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -766,7 +766,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -816,7 +816,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -866,7 +866,7 @@ exports[`renders ./components/popover/demo/placement.md extend context correctly
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -922,7 +922,7 @@ exports[`renders ./components/popover/demo/triggerType.md extend context correct
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -970,7 +970,7 @@ exports[`renders ./components/popover/demo/triggerType.md extend context correct
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -1018,7 +1018,7 @@ exports[`renders ./components/popover/demo/triggerType.md extend context correct
<div>
<div
class="ant-popover"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"

View File

@ -10,7 +10,7 @@ Array [
<div>
<div
class="ant-popover ant-popover-rtl ant-zoom-big-appear ant-zoom-big-appear-prepare ant-zoom-big"
style="opacity: 0; pointer-events: none;"
style="opacity: 0;"
>
<div
class="ant-popover-content"

View File

@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import { render } from '../../../tests/utils';
import Popover from '..';
import mountTest from '../../../tests/shared/mountTest';
import ConfigProvider from '../../config-provider';

View File

@ -1474,7 +1474,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1552,7 +1552,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1630,7 +1630,7 @@ Array [
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -2527,7 +2527,7 @@ exports[`renders ./components/rate/demo/text.md extend context correctly 1`] = `
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -2609,7 +2609,7 @@ exports[`renders ./components/rate/demo/text.md extend context correctly 1`] = `
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -2691,7 +2691,7 @@ exports[`renders ./components/rate/demo/text.md extend context correctly 1`] = `
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -2773,7 +2773,7 @@ exports[`renders ./components/rate/demo/text.md extend context correctly 1`] = `
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -2855,7 +2855,7 @@ exports[`renders ./components/rate/demo/text.md extend context correctly 1`] = `
<div>
<div
class="ant-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import { render } from '../../../tests/utils';
import Result from '..';
import Button from '../../button';
import mountTest from '../../../tests/shared/mountTest';

View File

@ -1,11 +1,10 @@
import React from 'react';
import { mount } from 'enzyme';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import Segmented from '../index';
import type { SegmentedValue } from '../index';
import { render } from '../../../tests/utils';
// Make CSSMotion working without transition
jest.mock('rc-motion/lib/util/motion', () => ({
@ -221,7 +220,7 @@ describe('Segmented', () => {
});
it('render segmented with className and other html attributes', () => {
const wrapper = mount(
const { container } = render(
<Segmented
options={['Daily', 'Monthly', 'Weekly']}
defaultValue="Weekly"
@ -230,8 +229,8 @@ describe('Segmented', () => {
/>,
);
expect(wrapper.hasClass('mock-cls')).toBeTruthy();
expect(wrapper.prop('data-test-id')).toBe('hello');
expect(container.querySelector('.mock-cls')).toBeTruthy();
expect(container.querySelector('[data-test-id]')).toHaveAttribute('data-test-id', 'hello');
});
it('render segmented with ref', () => {
@ -266,10 +265,10 @@ describe('Segmented', () => {
const wrapper = mount<typeof Demo>(<Demo />);
wrapper.find('Segmented').find(`.${prefixCls}-item-input`).at(0).simulate('change');
expect(wrapper.state().value).toBe('Map');
expect(wrapper.find(Demo).state().value).toBe('Map');
wrapper.find('Segmented').find(`.${prefixCls}-item-input`).at(1).simulate('change');
expect(wrapper.state().value).toBe('Transit');
expect(wrapper.find(Demo).state().value).toBe('Transit');
});
it('render segmented with options null/undefined', () => {

View File

@ -47,7 +47,7 @@ exports[`renders ./components/select/demo/automatic-tokenization.md extend conte
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -419,7 +419,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -597,7 +597,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -714,7 +714,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -831,7 +831,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -979,7 +979,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1140,7 +1140,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1262,7 +1262,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1404,7 +1404,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1566,7 +1566,7 @@ exports[`renders ./components/select/demo/custom-dropdown-menu.md extend context
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -1841,7 +1841,7 @@ exports[`renders ./components/select/demo/custom-tag-render.md extend context co
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2051,7 +2051,7 @@ exports[`renders ./components/select/demo/debug.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2295,7 +2295,7 @@ exports[`renders ./components/select/demo/debug.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2490,7 +2490,7 @@ exports[`renders ./components/select/demo/hide-selected.md extend context correc
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2619,7 +2619,7 @@ exports[`renders ./components/select/demo/label-in-value.md extend context corre
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -2857,7 +2857,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3346,7 +3346,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -3770,7 +3770,7 @@ exports[`renders ./components/select/demo/optgroup.md extend context correctly 1
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -4000,7 +4000,7 @@ exports[`renders ./components/select/demo/option-label-prop.md extend context co
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -4277,7 +4277,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -4474,7 +4474,7 @@ exports[`renders ./components/select/demo/responsive.md extend context correctly
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5004,7 +5004,7 @@ exports[`renders ./components/select/demo/responsive.md extend context correctly
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5502,7 +5502,7 @@ exports[`renders ./components/select/demo/search.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5660,7 +5660,7 @@ exports[`renders ./components/select/demo/search-box.md extend context correctly
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5707,7 +5707,7 @@ exports[`renders ./components/select/demo/search-sort.md extend context correctl
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -5935,7 +5935,7 @@ exports[`renders ./components/select/demo/select-users.md extend context correct
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -6051,7 +6051,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -6694,7 +6694,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -7204,7 +7204,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -7633,7 +7633,7 @@ exports[`renders ./components/select/demo/status.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -7755,7 +7755,7 @@ exports[`renders ./components/select/demo/status.md extend context correctly 1`]
<div>
<div
class="ant-select-dropdown ant-select-dropdown-empty"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -7882,7 +7882,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -8060,7 +8060,7 @@ Array [
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div
@ -8193,7 +8193,7 @@ exports[`renders ./components/select/demo/tags.md extend context correctly 1`] =
<div>
<div
class="ant-select-dropdown"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div>
<div

View File

@ -28,7 +28,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -76,7 +76,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -110,7 +110,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -176,7 +176,7 @@ exports[`renders ./components/slider/demo/dragableTrack.md extend context correc
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -210,7 +210,7 @@ exports[`renders ./components/slider/demo/dragableTrack.md extend context correc
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -262,7 +262,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -310,7 +310,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -344,7 +344,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -418,7 +418,7 @@ exports[`renders ./components/slider/demo/icon-slider.md extend context correctl
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -496,7 +496,7 @@ exports[`renders ./components/slider/demo/input-number.md extend context correct
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -633,7 +633,7 @@ exports[`renders ./components/slider/demo/input-number.md extend context correct
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -789,7 +789,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -884,7 +884,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -918,7 +918,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1012,7 +1012,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1110,7 +1110,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1208,7 +1208,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1291,7 +1291,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1339,7 +1339,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1373,7 +1373,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1439,7 +1439,7 @@ exports[`renders ./components/slider/demo/show-tooltip.md extend context correct
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1491,7 +1491,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1539,7 +1539,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1593,7 +1593,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1645,7 +1645,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1679,7 +1679,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1748,7 +1748,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -1782,7 +1782,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"

View File

@ -36,7 +36,7 @@ exports[`Slider should render in RTL direction 1`] = `
/>
<div
class="ant-slider-track"
style="right:0%;width:30%"
style="right: 0%; width: 30%;"
/>
<div
class="ant-slider-step"
@ -48,13 +48,13 @@ exports[`Slider should render in RTL direction 1`] = `
aria-valuenow="30"
class="ant-slider-handle ant-tooltip-open"
role="slider"
style="right:30%;transform:translateX(50%)"
style="right: 30%; transform: translateX(50%);"
tabindex="0"
/>
<div>
<div
class="ant-tooltip ant-slider-tooltip ant-tooltip-rtl"
style="opacity:0;pointer-events:none"
class="ant-tooltip ant-slider-tooltip ant-tooltip-rtl ant-zoom-down-appear ant-zoom-down-appear-prepare ant-zoom-down"
style="opacity: 0;"
>
<div
class="ant-tooltip-content"
@ -79,59 +79,157 @@ exports[`Slider should render in RTL direction 1`] = `
`;
exports[`Slider should show correct placement tooltip when set tooltipPlacement 1`] = `
<div>
Array [
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
>
aria-disabled="false"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="30"
class="ant-slider-handle ant-tooltip-open"
role="slider"
style="bottom: 30%; transform: translateY(50%);"
tabindex="0"
/>,
<div>
<div
class="ant-tooltip-content"
class="ant-tooltip ant-slider-tooltip ant-zoom-down-appear ant-zoom-down-appear-prepare ant-zoom-down"
style="opacity: 0;"
>
<div
class="ant-tooltip-arrow"
class="ant-tooltip-content"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
>
30
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
>
30
</div>
</div>
</div>
</div>
</div>
</div>,
]
`;
exports[`Slider should show correct placement tooltip when set tooltipPlacement 2`] = `<div />`;
exports[`Slider should show correct placement tooltip when set tooltipPlacement 2`] = `
Array [
<div
aria-disabled="false"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="30"
class="ant-slider-handle"
role="slider"
style="bottom: 30%; transform: translateY(50%);"
tabindex="0"
/>,
<div>
<div
class="ant-tooltip ant-slider-tooltip ant-zoom-down-leave ant-zoom-down-leave-start ant-zoom-down"
style="pointer-events: none;"
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
>
30
</div>
</div>
</div>
</div>,
]
`;
exports[`Slider should show tooltip when hovering slider handler 1`] = `
<div>
Array [
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
>
aria-disabled="false"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="30"
class="ant-slider-handle ant-tooltip-open"
role="slider"
style="left: 30%; transform: translateX(-50%);"
tabindex="0"
/>,
<div>
<div
class="ant-tooltip-content"
class="ant-tooltip ant-slider-tooltip ant-zoom-down-appear ant-zoom-down-appear-prepare ant-zoom-down"
style="opacity: 0;"
>
<div
class="ant-tooltip-arrow"
class="ant-tooltip-content"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
>
30
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
>
30
</div>
</div>
</div>
</div>
</div>
</div>,
]
`;
exports[`Slider should show tooltip when hovering slider handler 2`] = `<div />`;
exports[`Slider should show tooltip when hovering slider handler 2`] = `
Array [
<div
aria-disabled="false"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="30"
class="ant-slider-handle"
role="slider"
style="left: 30%; transform: translateX(-50%);"
tabindex="0"
/>,
<div>
<div
class="ant-tooltip ant-slider-tooltip ant-zoom-down-leave ant-zoom-down-leave-start ant-zoom-down"
style="pointer-events: none;"
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
>
30
</div>
</div>
</div>
</div>,
]
`;

View File

@ -1,5 +1,5 @@
import React from 'react';
import { render, mount } from 'enzyme';
import { mount } from 'enzyme';
import Slider from '..';
import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';
@ -16,17 +16,17 @@ describe('Slider', () => {
it('should show tooltip when hovering slider handler', () => {
const wrapper = mount(<Slider defaultValue={30} />);
wrapper.find('.ant-slider-handle').at(0).simulate('mouseEnter');
expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot();
expect(wrapper.find('Trigger').render()).toMatchSnapshot();
wrapper.find('.ant-slider-handle').at(0).simulate('mouseLeave');
expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot();
expect(wrapper.find('Trigger').render()).toMatchSnapshot();
});
it('should show correct placement tooltip when set tooltipPlacement', () => {
const wrapper = mount(<Slider vertical defaultValue={30} tooltipPlacement="left" />);
wrapper.find('.ant-slider-handle').at(0).simulate('mouseEnter');
expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot();
expect(wrapper.find('Trigger').render()).toMatchSnapshot();
wrapper.find('.ant-slider-handle').at(0).simulate('mouseLeave');
expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot();
expect(wrapper.find('Trigger').render()).toMatchSnapshot();
});
it('when tooltipVisible is true, tooltip should show always, or should never show', () => {
@ -84,7 +84,7 @@ describe('Slider', () => {
<Slider defaultValue={30} tooltipVisible />
</ConfigProvider>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('should keepAlign by calling forcePopupAlign', async () => {

View File

@ -242,7 +242,7 @@ exports[`renders ./components/space/demo/base.md extend context correctly 1`] =
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -346,7 +346,7 @@ Array [
<div>
<div
class="ant-tooltip ant-slider-tooltip"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-tooltip-content"
@ -472,7 +472,7 @@ exports[`renders ./components/space/demo/debug.md extend context correctly 1`] =
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"
@ -567,7 +567,7 @@ exports[`renders ./components/space/demo/debug.md extend context correctly 1`] =
<div>
<div
class="ant-popover ant-popconfirm"
style="opacity:0;pointer-events:none"
style="opacity:0"
>
<div
class="ant-popover-content"

View File

@ -8,13 +8,13 @@ exports[`Space should render correct with children 1`] = `
>
<div
class="ant-space-item"
style="margin-right:8px"
style="margin-right: 8px;"
>
text1
</div>
<div
class="ant-space-item"
style="margin-right:8px"
style="margin-right: 8px;"
>
<span>
text1
@ -35,7 +35,7 @@ Array [
>
<div
class="ant-space-item"
style="margin-right:24px"
style="margin-right: 24px;"
>
<span>
1
@ -54,7 +54,7 @@ Array [
>
<div
class="ant-space-item"
style="margin-right:16px"
style="margin-right: 16px;"
>
<span>
1
@ -73,7 +73,7 @@ Array [
>
<div
class="ant-space-item"
style="margin-right:24px"
style="margin-right: 24px;"
>
<span>
1
@ -97,7 +97,7 @@ Array [
>
<div
class="ant-space-item"
style="margin-left:8px"
style="margin-left: 8px;"
>
<span>
1
@ -116,7 +116,7 @@ Array [
>
<div
class="ant-space-item"
style="margin-left:16px"
style="margin-left: 16px;"
>
<span>
1
@ -135,7 +135,7 @@ Array [
>
<div
class="ant-space-item"
style="margin-left:24px"
style="margin-left: 24px;"
>
<span>
1
@ -158,19 +158,19 @@ exports[`Space split 1`] = `
>
<div
class="ant-space-item"
style="margin-right:4px"
style="margin-right: 4px;"
>
text1
</div>
<span
class="ant-space-item-split"
style="margin-right:4px"
style="margin-right: 4px;"
>
-
</span>
<div
class="ant-space-item"
style="margin-right:4px"
style="margin-right: 4px;"
>
<span>
text1
@ -178,7 +178,7 @@ exports[`Space split 1`] = `
</div>
<span
class="ant-space-item-split"
style="margin-right:4px"
style="margin-right: 4px;"
>
-
</span>

View File

@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { render, mount } from 'enzyme';
import { mount } from 'enzyme';
import { act } from 'react-dom/test-utils';
import Space from '..';
import ConfigProvider from '../../config-provider';
@ -34,7 +34,7 @@ describe('Space', () => {
</ConfigProvider>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('should render width rtl', () => {
@ -55,7 +55,7 @@ describe('Space', () => {
</ConfigProvider>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('should render width customize size', () => {
@ -102,7 +102,7 @@ describe('Space', () => {
</Space>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
it('should render with invalidElement', () => {
@ -170,6 +170,6 @@ describe('Space', () => {
</Space>,
);
expect(render(wrapper)).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@ -24,8 +24,8 @@ describe('delay spinning', () => {
it('should cancel debounce function when unmount', async () => {
const wrapper = mount(<Spin spinning delay={100} />);
const spy = jest.spyOn(wrapper.instance().updateSpinning, 'cancel');
expect(wrapper.instance().updateSpinning.cancel).toEqual(expect.any(Function));
const spy = jest.spyOn(wrapper.find(Spin).instance().updateSpinning, 'cancel');
expect(wrapper.find(Spin).instance().updateSpinning.cancel).toEqual(expect.any(Function));
expect(spy).not.toHaveBeenCalled();
wrapper.unmount();
expect(spy).toHaveBeenCalled();

Some files were not shown because too many files have changed in this diff Show More