-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: antd-issue-51248 #541
Merged
+77
−1
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
866a7e5
fix: antd-issue-51248
dongbanban 3995580
feat: add test for 51248
dongbanban 9c2b525
feat: update test for limit
dongbanban 124d7c9
feat: update test for limit
dongbanban b717b24
feat: update test for limit
dongbanban d524f04
feat: update test for limit
dongbanban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import Cascader from '../src'; | ||
import type { ReactWrapper } from './enzyme'; | ||
import { mount } from './enzyme'; | ||
|
||
describe('Cascader.Search', () => { | ||
function doSearch(wrapper: ReactWrapper, search: string) { | ||
wrapper.find('input').simulate('change', { | ||
target: { | ||
value: search, | ||
}, | ||
}); | ||
} | ||
const options = [ | ||
{ | ||
region: 'Asia', | ||
children: [], | ||
isParent: true, | ||
label: 'Asia', | ||
value: 'Asia', | ||
}, | ||
]; | ||
for (let i = 0; i < 100; i++) { | ||
options[0].children.push({ | ||
id: i, | ||
label: 'label' + i, | ||
value: 'value' + i, | ||
}); | ||
} | ||
|
||
it('limit', () => { | ||
const wrapper = mount( | ||
<Cascader | ||
options={options} | ||
open | ||
showSearch={{ | ||
limit: false, | ||
}} | ||
/>, | ||
); | ||
|
||
doSearch(wrapper, 'as'); | ||
const itemList = wrapper.find('div.rc-cascader-menu-item-content'); | ||
expect(itemList).toHaveLength(itemList.length); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 测试用例可以更具体和描述性。 当前的测试用例结构正确,但可以进行以下改进:
这些改进将使测试更加健壮和有意义。 如果您需要,我可以帮助您重写这个测试用例。 |
||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是用 0 比较好, pr修复的是<= 0的情况下,limit变成undefined然后又重新默认值50了,false本身是好的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
定位的问题出在limit = false时会走进 if的判断,导致 limit被 delete,所以测试用例里是用的limit:false, 或者直接再加一层判断,规避上述场景,这样原本的逻辑没变,false也可以当 no limit处理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果误导你了不好意思,还是等大佬们建议。我评论的是测试用例用个
limit: 0,
,因为之前limit: false
的情况本来就是好的,是limit:0才出了问题, 感觉这里面的业务逻辑是searchConfig.limit = 0;
orsearchConfig.limit = false;
可能都行。你改回了这个delete不是又导致了被默认赋值50的问题。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试用例我加上 limit:0/false/20 了,limit:false 是有问题的,实际使用依然会走进 if,大佬你可以试一下,官网 demo 里改成limit:false 依然是50 条
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete之后会变成undefined所以重新赋值了,所以是不是给个默认复制
0
可以呢There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以这里的逻辑 limit = false或者<=0都是展示全量数据,我最开始的修改进入判断后都是直接limit设为 false应该就可以的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样就可以了吧