能否请您告诉我如何进行函数调用存根?
MainComponent:
foo = (arrFav, symbol) => {
const { arrowResourcesInfo } = this.props;
const isFavoriteChecked = this.checkFavoriteElement(arrFav, symbol);
const objectNMT = this.createNMTObjectFavorites([...arrFav], new Date().getTime(), symbol);
Wrapper(this.timeFrame, this.symbolData, this.showFullCurrencyPair, this.dialogOpenDeals, this.openDetailInfo, this.getFullSymbolName, this.selectorIcon, isFavoriteChecked, this.changeFavoritesTechAnalysis, this.clearDataFromTechDetailWindow, objectNMT, arrowResourcesInfo, this.createDirectionImage);
};
和测试用例:
const instance = shallow(<MainComponent { ...props }/>).instance();
instance.state.activeCategory = 'favorites';
const spy = sandbox.spy(instance, 'foo');
instance.foo(favorites, 'param');
sandbox.assert.calledOnce(spy);
测试是错误的,因为包装器想要在他的体内放置参数。但是我想把他的话存根。