I have a component like that:
<Parent>
<Child/>
</Parent>
and <Child/>
component have a method foo
. I want test the foo
method but I don't know how to access it. I tried:
mount(<Parent><Child/></Parent>).props().children.foo
or
mount(<Parent><Child/></Parent>).children().foo
but both them are undefined
. I can't use .instance()
because it's not root. I can't mount <Child/>
only because the <Parent>
add something (react-router's context.router
) on context
and I need them when init <Child/>
. Any idea with this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…