(value: string, config: Partial<TestTreeNode<string>>)
| 113 | } |
| 114 | |
| 115 | async function updateTreeItemByValue(value: string, config: Partial<TestTreeNode<string>>) { |
| 116 | const newNodes = JSON.parse(JSON.stringify(testComponent.nodes())); |
| 117 | const childrenList = [newNodes]; |
| 118 | while (childrenList.length > 0) { |
| 119 | const list = childrenList.shift()!; |
| 120 | for (const node of list) { |
| 121 | if (node.value === value) { |
| 122 | if (config.value !== undefined) node.value = config.value; |
| 123 | if (config.label !== undefined) node.label = config.label; |
| 124 | if (config.children !== undefined) node.children = config.children; |
| 125 | if (config.disabled !== undefined) node.disabled = config.disabled; |
| 126 | if (config.selectable !== undefined) node.selectable = config.selectable; |
| 127 | await updateTree({nodes: newNodes}); |
| 128 | return; |
| 129 | } |
| 130 | if (node.children) { |
| 131 | childrenList.push(node.children); |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | function getTreeItemElementByValue(value: string): HTMLElement | undefined { |
| 138 | return treeItemElements.find(el => el.getAttribute('data-value') === String(value)); |
no test coverage detected
searching dependent graphs…