mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
test: back of coverage (#34964)
* test: fix coverage * chore: bump bisheng * chore: clean up * chore: update deps * chore: test coverage
This commit is contained in:
parent
494c55df30
commit
688422b490
@ -1,50 +0,0 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import * as React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import type { Root } from 'react-dom/client';
|
||||
// import * as reactDomClient from 'react-dom/client';
|
||||
|
||||
let createRoot: (container: ContainerType) => Root;
|
||||
try {
|
||||
// eslint-disable-next-line global-require, import/no-unresolved
|
||||
createRoot = require('react-dom/client').createRoot;
|
||||
} catch (e) {
|
||||
// Do nothing;
|
||||
}
|
||||
|
||||
const MARK = '__antd_react_root__';
|
||||
|
||||
type ContainerType = (Element | DocumentFragment) & {
|
||||
[MARK]?: Root;
|
||||
};
|
||||
|
||||
export function reactRender(node: React.ReactElement, container: ContainerType) {
|
||||
// React 17 test will not reach here
|
||||
/* istanbul ignore next */
|
||||
if (createRoot !== undefined) {
|
||||
const root = container[MARK] || createRoot(container);
|
||||
root.render(node);
|
||||
|
||||
container[MARK] = root;
|
||||
return;
|
||||
}
|
||||
|
||||
render(node, container);
|
||||
}
|
||||
|
||||
export function reactUnmount(container: ContainerType) {
|
||||
// React 17 test will not reach here
|
||||
/* istanbul ignore next */
|
||||
if (createRoot !== undefined) {
|
||||
// Delay to unmount to avoid React 18 sync warning
|
||||
Promise.resolve().then(() => {
|
||||
container[MARK]?.unmount();
|
||||
|
||||
delete container[MARK];
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unmountComponentAtNode(container);
|
||||
}
|
@ -928,4 +928,16 @@ describe('Menu', () => {
|
||||
expect(wrapper.find('li.ant-menu-item-divider').length).toBe(2);
|
||||
expect(wrapper.find('li.ant-menu-item-divider-dashed').length).toBe(1);
|
||||
});
|
||||
|
||||
it('expandIcon', () => {
|
||||
const wrapper = mount(
|
||||
<Menu defaultOpenKeys={['1']} mode="inline" expandIcon={() => <span className="bamboo" />}>
|
||||
<SubMenu key="1" title="submenu1">
|
||||
<Menu.Item key="submenu1">Option 1</Menu.Item>
|
||||
</SubMenu>
|
||||
</Menu>,
|
||||
);
|
||||
|
||||
expect(wrapper.exists('.bamboo')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { render as reactRender, unmount as reactUnmount } from 'rc-util/lib/React/render';
|
||||
import InfoCircleOutlined from '@ant-design/icons/InfoCircleOutlined';
|
||||
import CheckCircleOutlined from '@ant-design/icons/CheckCircleOutlined';
|
||||
import CloseCircleOutlined from '@ant-design/icons/CloseCircleOutlined';
|
||||
@ -8,7 +9,6 @@ import type { ModalFuncProps } from './Modal';
|
||||
import ConfirmDialog from './ConfirmDialog';
|
||||
import { globalConfig } from '../config-provider';
|
||||
import devWarning from '../_util/devWarning';
|
||||
import { reactRender, reactUnmount } from '../_util/compatible';
|
||||
import destroyFns from './destroyFns';
|
||||
|
||||
let defaultRootPrefixCls = '';
|
||||
|
@ -154,7 +154,7 @@
|
||||
"rc-tree-select": "~5.1.1",
|
||||
"rc-trigger": "^5.2.10",
|
||||
"rc-upload": "~4.3.0",
|
||||
"rc-util": "^5.19.3",
|
||||
"rc-util": "^5.20.0",
|
||||
"scroll-into-view-if-needed": "^2.2.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -188,7 +188,7 @@
|
||||
"argos-cli": "^0.3.0",
|
||||
"array-move": "^4.0.0",
|
||||
"babel-plugin-add-react-displayname": "^0.0.5",
|
||||
"bisheng": "^3.2.0",
|
||||
"bisheng": "^3.2.1",
|
||||
"bisheng-plugin-description": "^0.1.4",
|
||||
"bisheng-plugin-react": "^1.2.0",
|
||||
"bisheng-plugin-toc": "^0.4.4",
|
||||
|
Loading…
Reference in New Issue
Block a user