称为反应功能的酶在返回中未定义?它被调用了,但是我可以用下面的道具来调用它的间谍功能吗?我正在用柴加酶。
//class
export class MyComponent extends Component {
printSomething = () => 'output'
render() {
return (
<div></div>
);
}
}
//spec
describe.only('"handleChange" method', () => {
beforeEach(() => {
const MyComponent = mount(<MyComponent />)
sinon.spy(MyComponent.instance(), 'printSomething')
})
it('should call and test printSomething output', () => {
//some simutlation..
//called
expect(MyComponent.instance().printSomething).to.have.been.called()
//failed here? got undefined?
expect(MyComponent.instance().printSomething()).to.be.equal('output')
})