【发布时间】:2016-05-30 10:03:15
【问题描述】:
不知道如何测试包含多个操作的 onClick 函数。
onButtonClick = function(action){
this.props.otherAction();
action();
}
...
<Button bsStyle="success" bsSize="small" onClick={onButtonClick.bind(this,someAction}>
Something
</Button>
而我目前的测试是这样的。
const onButtonClick = function (action) {
actions.otherAction();
action();
};
it('Should include a button with multiple actions on onClick event.', function () {
const button = shallowTestUtils.findAllWithType(_component, Button);
expect(button[0].props.onClick).to.equal(onButtonClick.bind(this, actions.someAction));
});
我得到的结果是这样的。
AssertionError: expected [Function] to equal [Function]
【问题讨论】:
标签: reactjs redux react-bootstrap reactjs-testutils