Closed toearth closed 7 years ago
(btw i fixed your code highlighting; single backticks are for one-liners, triple backticks are for blocks)
No, your code won't work, because onPress
is already passed as a prop before you spy on it.
You have to do two things: 1) spyOn(Telephone.prototype, 'onPress')
BEFORE you shallow-render it, and 2) never use class properties for functions, and instead make it a normal prototype method, but do this.onPress = this.onPress.bind(this);
in the constructor.
Thanks a lot
I got this error:
My test:
Teltphone component:
It should work, doesn't it ?