我们说我有以下组件实例:
<ParentComponentWhichIsTested>
<Expand trigger={<span>Click me to expand this element</span>}>
<ComponentReference1></ComponentReference1>
</Expand>
<Expand trigger={<span>Click me to expand this element</span>}>
<ComponentReference2></ComponentReference1>
</Expand>
</ParentComponentWhichIsTested>
Expand
的渲染方法如下所示:
//in expand
render () {
return (
<div>
<ExpandTrigger>{trigger}</ExpandTrigger>
<ExpandContent>{this.props.children}</ExpandContent>
</div>
);
}
我想断言第一个Expand实例的内容组件类型为ComponentReference1
,第二个实例的内容组件类型为ComponentReference2
。
import { mount } from 'enzyme';
const comp = mount(...ParentComponentWhichIsTested...)
console.log(comp.props().children); //will be 2, the trigger and content nodes, but I want to see that I actually *sent* a child, not what the component rendered.
如何查看寄孩子?难道我做错了什么?
提前致谢!