Skip to content

Commit ce94a41

Browse files
committed
chore: optimize test cases
1 parent 9a2ef31 commit ce94a41

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

Diff for: tests/Select.SearchInput.spec.js

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-undef */
22
import React, { useState } from 'react';
33
import { mount } from 'enzyme';
4-
import TreeSelect, { TreeNode, TreeSelectProps } from '../src';
4+
import TreeSelect, { TreeNode } from '../src';
55

66
describe('TreeSelect.SearchInput', () => {
77
it('select item will clean searchInput', () => {
@@ -154,30 +154,13 @@ describe('TreeSelect.SearchInput', () => {
154154
expect(called).toBe(0); // should not trrigger all nodes to load data
155155
});
156156

157-
it('not trigger loadData when clearing the search', () => {
157+
it('should trrigger `loadData` when click node', () => {
158158
let called = 0;
159-
const handleLoadData = jest.fn();
160159
const Demo = () => {
161160
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-
174161
const onLoadData = ({ id, ...rest }) =>
175162
new Promise(resolve => {
176163
called += 1;
177-
handleLoadData({ id, ...rest });
178-
setTreeData(
179-
treeData.concat([genTreeNode(id, false), genTreeNode(id, true), genTreeNode(id, true)]),
180-
);
181164
resolve(undefined);
182165
});
183166

0 commit comments

Comments
 (0)