test: moving to testing-library in Tree (#35674)

This commit is contained in:
Cong Zhang 2022-05-25 15:28:47 +08:00 committed by GitHub
parent 9a98a1c5db
commit 8b802bbbef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 368 additions and 595 deletions

View File

@ -8,7 +8,7 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
/>
@ -16,7 +16,7 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
<div
aria-hidden="true"
class="ant-tree-treenode"
style="position:absolute;pointer-events:none;visibility:hidden;height:0;overflow:hidden"
style="position: absolute; pointer-events: none; visibility: hidden; height: 0px; overflow: hidden;"
>
<div
class="ant-tree-indent"
@ -28,7 +28,7 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
</div>
<div
class="ant-tree-list"
style="position:relative"
style="position: relative;"
>
<div
class="ant-tree-list-holder"
@ -36,7 +36,7 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
<div>
<div
class="ant-tree-list-holder-inner"
style="display:flex;flex-direction:column"
style="display: flex; flex-direction: column;"
>
<div
aria-grabbed="false"
@ -242,7 +242,7 @@ exports[`Directory Tree defaultExpandAll 1`] = `
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
/>
@ -250,7 +250,7 @@ exports[`Directory Tree defaultExpandAll 1`] = `
<div
aria-hidden="true"
class="ant-tree-treenode"
style="position:absolute;pointer-events:none;visibility:hidden;height:0;overflow:hidden"
style="position: absolute; pointer-events: none; visibility: hidden; height: 0px; overflow: hidden;"
>
<div
class="ant-tree-indent"
@ -262,7 +262,7 @@ exports[`Directory Tree defaultExpandAll 1`] = `
</div>
<div
class="ant-tree-list"
style="position:relative"
style="position: relative;"
>
<div
class="ant-tree-list-holder"
@ -270,7 +270,7 @@ exports[`Directory Tree defaultExpandAll 1`] = `
<div>
<div
class="ant-tree-list-holder-inner"
style="display:flex;flex-direction:column"
style="display: flex; flex-direction: column;"
>
<div
aria-grabbed="false"
@ -619,7 +619,7 @@ exports[`Directory Tree defaultExpandParent 1`] = `
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
/>
@ -627,7 +627,7 @@ exports[`Directory Tree defaultExpandParent 1`] = `
<div
aria-hidden="true"
class="ant-tree-treenode"
style="position:absolute;pointer-events:none;visibility:hidden;height:0;overflow:hidden"
style="position: absolute; pointer-events: none; visibility: hidden; height: 0px; overflow: hidden;"
>
<div
class="ant-tree-indent"
@ -639,7 +639,7 @@ exports[`Directory Tree defaultExpandParent 1`] = `
</div>
<div
class="ant-tree-list"
style="position:relative"
style="position: relative;"
>
<div
class="ant-tree-list-holder"
@ -647,7 +647,7 @@ exports[`Directory Tree defaultExpandParent 1`] = `
<div>
<div
class="ant-tree-list-holder-inner"
style="display:flex;flex-direction:column"
style="display: flex; flex-direction: column;"
>
<div
aria-grabbed="false"
@ -893,109 +893,104 @@ exports[`Directory Tree expand click 1`] = `
</span>
</div>
<div
class="ant-tree-treenode-motion ant-motion-collapse-appear ant-motion-collapse-appear-start ant-motion-collapse"
style="height: 0px; opacity: 0;"
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
aria-hidden="true"
class="ant-tree-indent"
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
</div>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
@ -1174,111 +1169,6 @@ exports[`Directory Tree expand click 2`] = `
</span>
</span>
</div>
<div
class="ant-tree-treenode-motion ant-motion-collapse-leave ant-motion-collapse-leave-start ant-motion-collapse"
style="height: 0px;"
>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
@ -1457,109 +1347,104 @@ exports[`Directory Tree expand double click 1`] = `
</span>
</div>
<div
class="ant-tree-treenode-motion ant-motion-collapse-appear ant-motion-collapse-appear-start ant-motion-collapse"
style="height: 0px; opacity: 0;"
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
aria-hidden="true"
class="ant-tree-indent"
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
</div>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
@ -1738,111 +1623,6 @@ exports[`Directory Tree expand double click 2`] = `
</span>
</span>
</div>
<div
class="ant-tree-treenode-motion ant-motion-collapse-leave ant-motion-collapse-leave-start ant-motion-collapse"
style="height: 0px;"
>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-start"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
@ -2409,109 +2189,104 @@ exports[`Directory Tree expandedKeys update 1`] = `
</span>
</div>
<div
class="ant-tree-treenode-motion ant-motion-collapse-appear ant-motion-collapse-appear-start ant-motion-collapse"
style="height: 0px; opacity: 0;"
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close"
draggable="false"
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-end"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
class="ant-tree-indent-unit ant-tree-indent-unit-end"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
aria-hidden="true"
class="ant-tree-indent"
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-end"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
</div>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
draggable="false"
>
<span
aria-hidden="true"
class="ant-tree-indent"
>
<span
class="ant-tree-indent-unit ant-tree-indent-unit-end"
/>
</span>
<span
class="ant-tree-switcher ant-tree-switcher-noop"
/>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
title="---"
>
<span
class="ant-tree-iconEle ant-tree-icon__customize"
>
<span
aria-label="folder"
class="anticon anticon-folder"
role="img"
>
<svg
aria-hidden="true"
data-icon="folder"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
/>
</svg>
</span>
</span>
<span
class="ant-tree-title"
>
---
</span>
</span>
</div>
</div>
</div>

View File

@ -1,9 +1,9 @@
import React from 'react';
import { mount, render } from 'enzyme';
import debounce from 'lodash/debounce';
import Tree from '../index';
import React from 'react';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { fireEvent, render } from '../../../tests/utils';
import Tree from '../index';
const { DirectoryTree, TreeNode } = Tree;
@ -44,23 +44,27 @@ describe('Directory Tree', () => {
describe('expand', () => {
it('click', () => {
const wrapper = mount(createTree());
const { container, asFragment } = render(createTree());
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate('click');
expect(wrapper.render()).toMatchSnapshot();
fireEvent.click(container.querySelector('.ant-tree-node-content-wrapper'));
jest.runAllTimers();
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate('click');
expect(wrapper.render()).toMatchSnapshot();
expect(asFragment().firstChild).toMatchSnapshot();
jest.runAllTimers();
fireEvent.click(container.querySelector('.ant-tree-node-content-wrapper'));
jest.runAllTimers();
expect(asFragment().firstChild).toMatchSnapshot();
});
it('double click', () => {
const wrapper = mount(createTree({ expandAction: 'doubleClick' }));
const { container, asFragment } = render(createTree({ expandAction: 'doubleClick' }));
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate('doubleClick');
expect(wrapper.render()).toMatchSnapshot();
fireEvent.doubleClick(container.querySelector('.ant-tree-node-content-wrapper'));
jest.runAllTimers();
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate('doubleClick');
expect(wrapper.render()).toMatchSnapshot();
expect(asFragment().firstChild).toMatchSnapshot();
jest.runAllTimers();
fireEvent.doubleClick(container.querySelector('.ant-tree-node-content-wrapper'));
jest.runAllTimers();
expect(asFragment().firstChild).toMatchSnapshot();
});
describe('with state control', () => {
@ -86,21 +90,26 @@ describe('Directory Tree', () => {
}
}
['click', 'doubleClick'].forEach(action => {
it(action, () => {
const wrapper = mount(<StateDirTree expandAction={action} />);
it('click', () => {
const { container, asFragment } = render(<StateDirTree expandAction="click" />);
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate(action);
jest.runAllTimers();
expect(wrapper.render()).toMatchSnapshot();
});
fireEvent.click(container.querySelector('.ant-tree-node-content-wrapper'));
jest.runAllTimers();
expect(asFragment().firstChild).toMatchSnapshot();
});
it('doubleClick', () => {
const { container, asFragment } = render(<StateDirTree expandAction="doubleClick" />);
fireEvent.doubleClick(container.querySelector('.ant-tree-node-content-wrapper'));
jest.runAllTimers();
expect(asFragment().firstChild).toMatchSnapshot();
});
});
});
it('defaultExpandAll', () => {
const wrapper = render(createTree({ defaultExpandAll: true }));
expect(wrapper).toMatchSnapshot();
const { asFragment } = render(createTree({ defaultExpandAll: true }));
expect(asFragment().firstChild).toMatchSnapshot();
});
it('DirectoryTree should expend all when use treeData and defaultExpandAll is true', () => {
@ -123,90 +132,78 @@ describe('Directory Tree', () => {
],
},
];
const wrapper = render(createTree({ defaultExpandAll: true, treeData }));
expect(wrapper).toMatchSnapshot();
const { asFragment } = render(createTree({ defaultExpandAll: true, treeData }));
expect(asFragment().firstChild).toMatchSnapshot();
});
it('defaultExpandParent', () => {
const wrapper = render(createTree({ defaultExpandParent: true }));
expect(wrapper).toMatchSnapshot();
const { asFragment } = render(createTree({ defaultExpandParent: true }));
expect(asFragment().firstChild).toMatchSnapshot();
});
it('expandedKeys update', () => {
const wrapper = mount(createTree());
wrapper.setProps({ expandedKeys: ['0-1'] });
expect(wrapper.render()).toMatchSnapshot();
const { rerender, asFragment } = render(createTree());
rerender(createTree({ expandedKeys: ['0-1'] }));
jest.runAllTimers();
expect(asFragment().firstChild).toMatchSnapshot();
});
it('selectedKeys update', () => {
const wrapper = mount(createTree({ defaultExpandAll: true }));
wrapper.setProps({ selectedKeys: ['0-1-0'] });
expect(wrapper.render()).toMatchSnapshot();
const { rerender, asFragment } = render(createTree({ defaultExpandAll: true }));
rerender(createTree({ selectedKeys: ['0-1-0'] }));
expect(asFragment().firstChild).toMatchSnapshot();
});
it('group select', () => {
let nativeEventProto = null;
const onSelect = jest.fn();
const wrapper = mount(
const { container, asFragment } = render(
createTree({
defaultExpandAll: true,
expandAction: 'doubleClick',
multiple: true,
onClick: e => {
nativeEventProto = Object.getPrototypeOf(e.nativeEvent);
},
onSelect,
}),
);
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate('click');
fireEvent.click(container.querySelectorAll('.ant-tree-node-content-wrapper')[0]);
expect(onSelect.mock.calls[0][1].selected).toBeTruthy();
expect(onSelect.mock.calls[0][1].selectedNodes.length).toBe(1);
// Click twice should keep selected
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate('click');
fireEvent.click(container.querySelectorAll('.ant-tree-node-content-wrapper')[0]);
expect(onSelect.mock.calls[1][1].selected).toBeTruthy();
expect(onSelect.mock.calls[0][0]).toEqual(onSelect.mock.calls[1][0]);
expect(onSelect.mock.calls[1][1].selectedNodes.length).toBe(1);
// React not simulate full of NativeEvent. Hook it.
// Ref: https://github.com/facebook/react/blob/master/packages/react-dom/src/test-utils/ReactTestUtils.js#L360
nativeEventProto.ctrlKey = true;
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(1).simulate('click');
expect(wrapper.render()).toMatchSnapshot();
fireEvent.click(container.querySelectorAll('.ant-tree-node-content-wrapper')[1], {
ctrlKey: true,
});
expect(asFragment().firstChild).toMatchSnapshot();
expect(onSelect.mock.calls[2][0].length).toBe(2);
expect(onSelect.mock.calls[2][1].selected).toBeTruthy();
expect(onSelect.mock.calls[2][1].selectedNodes.length).toBe(2);
delete nativeEventProto.ctrlKey;
nativeEventProto.shiftKey = true;
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(4).simulate('click');
expect(wrapper.render()).toMatchSnapshot();
fireEvent.click(container.querySelectorAll('.ant-tree-node-content-wrapper')[4], {
shiftKey: true,
});
expect(asFragment().firstChild).toMatchSnapshot();
expect(onSelect.mock.calls[3][0].length).toBe(5);
expect(onSelect.mock.calls[3][1].selected).toBeTruthy();
expect(onSelect.mock.calls[3][1].selectedNodes.length).toBe(5);
delete nativeEventProto.shiftKey;
});
it('onDoubleClick', () => {
const onDoubleClick = jest.fn();
const wrapper = mount(createTree({ onDoubleClick }));
wrapper.find(TreeNode).find('.ant-tree-node-content-wrapper').at(0).simulate('doubleclick');
const { container } = render(createTree({ onDoubleClick }));
fireEvent.doubleClick(container.querySelector('.ant-tree-node-content-wrapper'));
expect(onDoubleClick).toBeCalled();
});
it('should not expand tree now when pressing ctrl', () => {
const onExpand = jest.fn();
const onSelect = jest.fn();
const wrapper = mount(createTree({ onExpand, onSelect }));
wrapper
.find(TreeNode)
.find('.ant-tree-node-content-wrapper')
.at(0)
.simulate('click', { ctrlKey: true });
const { container } = render(createTree({ onExpand, onSelect }));
fireEvent.click(container.querySelector('.ant-tree-node-content-wrapper'), { ctrlKey: true });
expect(onExpand).not.toHaveBeenCalled();
expect(onSelect).toHaveBeenCalledWith(
['0-0'],
@ -217,7 +214,7 @@ describe('Directory Tree', () => {
it('should not expand tree now when click leaf node', () => {
const onExpand = jest.fn();
const onSelect = jest.fn();
const wrapper = mount(
const { container } = render(
createTree({
onExpand,
onSelect,
@ -243,7 +240,8 @@ describe('Directory Tree', () => {
],
}),
);
wrapper.find(TreeNode).last().find('.ant-tree-node-content-wrapper').at(0).simulate('click');
const nodeList = container.querySelectorAll('.ant-tree-node-content-wrapper');
fireEvent.click(nodeList[nodeList.length - 1]);
expect(onExpand).not.toHaveBeenCalled();
expect(onSelect).toHaveBeenCalledWith(
['0-0-2'],
@ -253,7 +251,7 @@ describe('Directory Tree', () => {
it('ref support', () => {
const treeRef = React.createRef();
mount(createTree({ ref: treeRef }));
render(createTree({ ref: treeRef }));
expect('scrollTo' in treeRef.current).toBeTruthy();
});

View File

@ -1,4 +1,4 @@
import { mount } from 'enzyme';
import { render } from '../../../tests/utils';
import dropIndicatorRender, { offset } from '../utils/dropIndicator';
describe('dropIndicatorRender', () => {
@ -10,8 +10,8 @@ describe('dropIndicatorRender', () => {
prefixCls: 'ant',
direction: 'ltr',
});
const wrapper = mount(indicator);
expect(wrapper.find('div').props().style!.bottom).toEqual(-3);
const { container } = render(indicator);
expect(container.querySelector('div')?.style.bottom).toEqual('-3px');
});
it('work with dropPosition inner (-0)', () => {
const indicator = dropIndicatorRender({
@ -21,9 +21,9 @@ describe('dropIndicatorRender', () => {
prefixCls: 'ant',
direction: 'ltr',
});
const wrapper = mount(indicator);
expect(wrapper.find('div').props().style!.bottom).toEqual(-3);
expect(wrapper.find('div').props().style!.left).toEqual(24 + offset);
const { container } = render(indicator);
expect(container.querySelector('div')?.style.bottom).toEqual('-3px');
expect(container.querySelector('div')?.style.left).toEqual(`${24 + offset}px`);
});
it('work with dropPosition after (-1)', () => {
const indicator = dropIndicatorRender({
@ -33,8 +33,8 @@ describe('dropIndicatorRender', () => {
prefixCls: 'ant',
direction: 'ltr',
});
const wrapper = mount(indicator);
expect(wrapper.find('div').props().style!.top).toEqual(-3);
const { container } = render(indicator);
expect(container.querySelector('div')?.style.top).toEqual('-3px');
});
it('work with drop level', () => {
const indicator = dropIndicatorRender({
@ -44,8 +44,8 @@ describe('dropIndicatorRender', () => {
prefixCls: 'ant',
direction: 'ltr',
});
const wrapper = mount(indicator);
expect(wrapper.find('div').props().style!.left).toEqual(-2 * 24 + offset);
const { container } = render(indicator);
expect(container.querySelector('div')?.style.left).toEqual(`${-2 * 24 + offset}px`);
});
it('work with drop level (rtl)', () => {
const indicator = dropIndicatorRender({
@ -55,7 +55,7 @@ describe('dropIndicatorRender', () => {
prefixCls: 'ant',
direction: 'rtl',
});
const wrapper = mount(indicator);
expect(wrapper.find('div').props().style!.right).toEqual(-2 * 24 + offset);
const { container } = render(indicator);
expect(container.querySelector('div')?.style.right).toEqual(`${-2 * 24 + offset}px`);
});
});

View File

@ -1,12 +1,12 @@
import React from 'react';
import { mount } from 'enzyme';
import { render } from '../../../tests/utils';
import Tree from '../index';
const { TreeNode } = Tree;
describe('Tree', () => {
it('icon and switcherIcon of Tree with showLine should render correctly', () => {
const wrapper = mount(
const { asFragment } = render(
<Tree showLine showIcon>
<TreeNode icon="icon" switcherIcon="switcherIcon" key="0-0">
<TreeNode icon="icon" switcherIcon="switcherIcon" key="0-0-0" />
@ -28,11 +28,11 @@ describe('Tree', () => {
</TreeNode>
</Tree>,
);
expect(wrapper.render()).toMatchSnapshot();
expect(asFragment().firstChild).toMatchSnapshot();
});
it('switcherIcon in Tree should not render at leaf nodes', () => {
const wrapper = mount(
const { container } = render(
<Tree switcherIcon={<i className="switcherIcon" />} defaultExpandAll>
<TreeNode icon="icon">
<TreeNode id="node1" title="node1" icon="icon" key="0-0-2" />
@ -40,11 +40,11 @@ describe('Tree', () => {
</TreeNode>
</Tree>,
);
expect(wrapper.find('.switcherIcon').length).toBe(1);
expect(container.querySelectorAll('.switcherIcon').length).toBe(1);
});
it('switcherIcon in Tree could be string', () => {
const wrapper = mount(
const { asFragment } = render(
<Tree switcherIcon="switcherIcon" defaultExpandAll>
<TreeNode icon="icon">
<TreeNode id="node1" title="node1" icon="icon" key="0-0-2" />
@ -52,7 +52,7 @@ describe('Tree', () => {
</TreeNode>
</Tree>,
);
expect(wrapper.render()).toMatchSnapshot();
expect(asFragment().firstChild).toMatchSnapshot();
});
it('switcherIcon should be loading icon when loadData', () => {
@ -62,7 +62,7 @@ describe('Tree', () => {
resolve();
}, 1000);
});
const wrapper = mount(
const { asFragment } = render(
<Tree switcherIcon="switcherIcon" defaultExpandAll loadData={onLoadData}>
<TreeNode icon="icon">
<TreeNode id="node1" title="node1" icon="icon" key="0-0-2" />
@ -70,11 +70,11 @@ describe('Tree', () => {
</TreeNode>
</Tree>,
);
expect(wrapper.render()).toMatchSnapshot();
expect(asFragment().firstChild).toMatchSnapshot();
});
it('switcherIcon in Tree could be render prop function', () => {
const wrapper = mount(
const { container } = render(
<Tree
switcherIcon={expanded =>
expanded ? <span className="open" /> : <span className="close" />
@ -87,12 +87,12 @@ describe('Tree', () => {
</TreeNode>
</Tree>,
);
expect(wrapper.find('.open').length).toBe(1);
expect(container.querySelectorAll('.open').length).toBe(1);
});
// https://github.com/ant-design/ant-design/issues/23261
it('showLine is object type should render correctly', () => {
const wrapper = mount(
const { asFragment } = render(
<Tree showLine={{ showLeafIcon: false }} defaultExpandedKeys={['0-0-0']}>
<TreeNode title="parent 1" key="0-0">
<TreeNode title="parent 1-0" key="0-0-0">
@ -110,7 +110,7 @@ describe('Tree', () => {
</TreeNode>
</Tree>,
);
expect(wrapper.render()).toMatchSnapshot();
expect(asFragment().firstChild).toMatchSnapshot();
});
describe('draggable', () => {
@ -122,26 +122,26 @@ describe('Tree', () => {
];
it('hide icon', () => {
const wrapper = mount(<Tree treeData={dragTreeData} draggable={{ icon: false }} />);
expect(wrapper.exists('.anticon-holder')).toBeFalsy();
const { container } = render(<Tree treeData={dragTreeData} draggable={{ icon: false }} />);
expect(container.querySelector('.anticon-holder')).toBeFalsy();
});
it('customize icon', () => {
const wrapper = mount(
const { container } = render(
<Tree treeData={dragTreeData} draggable={{ icon: <span className="little" /> }} />,
);
expect(wrapper.exists('.little')).toBeTruthy();
expect(container.querySelector('.little')).toBeTruthy();
});
it('nodeDraggable', () => {
const nodeDraggable = jest.fn(() => false);
mount(<Tree treeData={dragTreeData} draggable={{ nodeDraggable }} />);
render(<Tree treeData={dragTreeData} draggable={{ nodeDraggable }} />);
expect(nodeDraggable).toHaveBeenCalledWith(dragTreeData[0]);
});
it('nodeDraggable func', () => {
const nodeDraggable = jest.fn(() => false);
mount(<Tree treeData={dragTreeData} draggable={nodeDraggable} />);
render(<Tree treeData={dragTreeData} draggable={nodeDraggable} />);
expect(nodeDraggable).toHaveBeenCalledWith(dragTreeData[0]);
});
});

View File

@ -1,11 +1,11 @@
import * as React from 'react';
import { mount } from 'enzyme';
import type { BasicDataNode } from 'rc-tree';
import * as React from 'react';
import { render } from '../../../tests/utils';
import Tree from '../index';
describe('Tree.TypeScript', () => {
it('without generic', () => {
const wrapper = mount(
const { container } = render(
<Tree
treeData={[
{
@ -22,7 +22,7 @@ describe('Tree.TypeScript', () => {
/>,
);
expect(wrapper).toBeTruthy();
expect(container).toBeTruthy();
});
it('support generic', () => {
@ -31,7 +31,7 @@ describe('Tree.TypeScript', () => {
list?: MyDataNode[];
}
const wrapper = mount(
const { container } = render(
<Tree<MyDataNode>
treeData={[
{
@ -46,6 +46,6 @@ describe('Tree.TypeScript', () => {
/>,
);
expect(wrapper).toBeTruthy();
expect(container).toBeTruthy();
});
});