我是React-Redux的新手,我想在Jest中为我的React组件编写单元测试用例。但是,我不知道如何为React容器组件编写测试用例。
import CombinedPanels from '../containers/CombinedPanels';
export class DapDropdowns extends Component {
componentDidMount() {
const { selectedDivision } = this.props;
this.props.fetchDap(selectedDivision);
this.props.fetchReportType();
}
componentWillReceiveProps(nextProps) {
if (nextProps.selectedDivision !== this.props.selectedDivision) {
const { selectedDivision } = nextProps;
this.props.fetchDap(selectedDivision);
}
}
onDivisionChange = (nextDivision) => {
this.props.selectDivision(nextDivision);
}
onBranchChange = (nextBranch) => {
this.props.selectBranch(nextBranch);
const { selectedDivision, fiscalYear } = this.props;
this.props.fetchFiscalYear(selectedDivision, nextBranch, fiscalYear);
}
render() {
const { selectedDivision, reportType, fiscalYear, divisionBranchDropdown } = this.props;
let branchesData = divisionBranchDropdown.filter(dap => dap.sbuid == selectedDivision);
return (
<div>
<CombinedPanels />
</div>
);
}
}
export default DapDropdowns;
这里的ter代码`