|
1 | 1 | /* eslint-disable no-undef */ |
2 | 2 | import React, { useState } from 'react'; |
3 | 3 | import { mount } from 'enzyme'; |
4 | | -import TreeSelect, { TreeNode, TreeSelectProps } from '../src'; |
| 4 | +import TreeSelect, { TreeNode } from '../src'; |
5 | 5 |
|
6 | 6 | describe('TreeSelect.SearchInput', () => { |
7 | 7 | it('select item will clean searchInput', () => { |
@@ -154,30 +154,13 @@ describe('TreeSelect.SearchInput', () => { |
154 | 154 | expect(called).toBe(0); // should not trrigger all nodes to load data |
155 | 155 | }); |
156 | 156 |
|
157 | | - it('not trigger loadData when clearing the search', () => { |
| 157 | + it('should trrigger `loadData` when click node', () => { |
158 | 158 | let called = 0; |
159 | | - const handleLoadData = jest.fn(); |
160 | 159 | const Demo = () => { |
161 | 160 | const [value, setValue] = useState(); |
162 | | - |
163 | | - const genTreeNode = (parentId, isLeaf = false) => { |
164 | | - const random = Math.random().toString(36).substring(2, 6); |
165 | | - return { |
166 | | - id: random, |
167 | | - pId: parentId, |
168 | | - value: random, |
169 | | - title: isLeaf ? 'Tree Node' : 'Expand to load', |
170 | | - isLeaf, |
171 | | - }; |
172 | | - }; |
173 | | - |
174 | 161 | const onLoadData = ({ id, ...rest }) => |
175 | 162 | new Promise(resolve => { |
176 | 163 | called += 1; |
177 | | - handleLoadData({ id, ...rest }); |
178 | | - setTreeData( |
179 | | - treeData.concat([genTreeNode(id, false), genTreeNode(id, true), genTreeNode(id, true)]), |
180 | | - ); |
181 | 164 | resolve(undefined); |
182 | 165 | }); |
183 | 166 |
|
|
0 commit comments