【发布时间】:2016-06-14 17:05:59
【问题描述】:
我已经用enzyme 尝试了所有方法,但是,我在下面找不到测试这些属性的正确方法。请记住,这个组件被包裹在一个虚拟的 Provider 组件中,以便我可以传递必要的道具(即Store)以进行安装。
1) 挂载后,在实例上设置一个属性(例如this.property)
2) 添加了一个事件监听器
3) 在事件监听器上,someFunction 被调用
class SampleComponent extends Component {
componentDidMount() {
this.property = 'property';
window.addEventListener('scroll', this.someFunction, true);
}
someFunction = () => {
return 'hello';
};
render() {
return <h1>Sample</h1>;
}
}
export default EvalueeExposureList;
【问题讨论】: