-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Improve testing #144
Improve testing #144
Conversation
@@ -97,7 +97,7 @@ const DropdownMenu = React.createClass({ | |||
|
|||
clonedMenuItems = menuItems.map(item => { | |||
if (item.type === MenuItemGroup) { | |||
const children = item.props.children.map(clone); | |||
const children = React.Children.map(item.props.children, clone); |
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.
这个不能改的,不能用 map 的,map 会修改 key
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.
不过很奇怪,我在测试里只给 MenuItemGroup
传一个 child 的话,这里的 item.props.children 就不是一个数组。但是实际使用的时候,只给一个 child 这里就是数组。
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.
奥,实际使用的时候,children 是从 FilterMixin 过来的,所以是数组。
@@ -364,6 +364,7 @@ const Select = React.createClass({ | |||
} | |||
} | |||
} else if (isMultipleOrTags(props) && inputValue) { | |||
// why not use setState? | |||
this.state.inputValue = this.getInputDOMNode().value = ''; |
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.
这里没看懂为什么没用 setState
。
fd9135a
to
e6b3bd9
Compare
@yiminghe 这样测试可以的话,后面再推广到其他组件吧。 |
覆盖率提高到了 96%。
另外这个 PR 依赖 react-component/trigger#33