我对mock
函数有疑问
class MyScreen extends Component {
constructor(props) {
this.video = React.createRef();
}
render() {
return (
<VideoPlayer
ref={this.video}
onVideoSuccess={() => {
this.video.current.startVideo();
}}
/>);
}
}
我如何通过this.video.current.startVideo()
测试通过,但我不知道如何模拟组件startVideo()
的功能VideoPlayer
export default class VideoPlayer extends Component {
startVideo() { ... }
play() {...}
pause() {...}
stop() {...}
render() {
return <VideoPlayerView {...this.props} />
}
}