Javascript 如何测试使用jest和Ezyme调用其他两个函数的函数

Javascript 如何测试使用jest和Ezyme调用其他两个函数的函数,javascript,reactjs,testing,jestjs,enzyme,Javascript,Reactjs,Testing,Jestjs,Enzyme,我在我的react项目中使用了react dates组件,onDatesChange是一个函数,它将动作分配到redux存储两次,有人能帮我用jest和Ezyme测试这个函数吗 这是从react dates导入的DateRangeComponent <DateRangePicker startDate={this.props.filters.startDate} startDateId={this.state.startDateId} endDate={this.prop

我在我的react项目中使用了
react dates
组件,
onDatesChange
是一个函数,它将动作分配到
redux
存储两次,有人能帮我用
jest
Ezyme
测试这个函数吗

这是从
react dates
导入的
DateRangeComponent

<DateRangePicker
   startDate={this.props.filters.startDate}
   startDateId={this.state.startDateId}
   endDate={this.props.filters.endDate}
   endDateId={this.state.endDateId}
   onDatesChange={this.onDatesChange}
   focusedInput={this.state.calenderFocused}
   onFocusChange={this.onFocusChange}
   showClearDates={true}
   numberOfMonths={1}
   isOutsideRange={() => false}
/>

如何在此表单中测试此函数。我知道,如果我把它重构成
mapDispatchToProps
,我可以很容易地测试它,这是我不想做的。谢谢

你到底想测试什么?你试过什么?@MikeBell我想测试
onDatesChange
正在使用
startDate
endDate
调用。但是,当我生成
dispatch
mock函数并将其作为
prop
传递到组件中时,预期分派结果会返回两个函数调用(这是正确的),但我不知道如何测试它们。期望(调度)。被最后调用为(‘我应该在这里写什么?’);另外,
expect(dispatch)
提供函数体内部发生的函数调用。但是我还想测试
onDatesChange
是否被
startDate
endDate
调用。我不知道该怎么做。。
onDatesChange = ({ startDate, endDate }) => {
  this.props.dispatch(setStartDate(startDate));
  this.props.dispatch(setEndDate(endDate));
};