我有一个看起来像这样的组件
async componentDidMount() { const { navigation } = this.props this.subs = [ navigation.addListener('didFocus', () => this.onComponentFocus()), ] } onComponentFocus() { const { dispatch } = this.props dispatch(fetchDevices()) }
现在,我想编写一个测试一次,让chekcs fetchDevice被调用一次。第一个想法是像这样模拟导航
常量导航= {导航:jest.fn(),}
但是现在我如何检查this.subs,以及如何检查fetchDevices被解雇了?
我有一个看起来像这样的组件componentDidMount(){const {navigation} = this.props this.subs = [navigation.addListener('didFocus',()=> this.onComponentFocus()),...
如果我们假设fetchDevices
来自库