1

假设我有以下组件实例:

<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. 

如何查看发送的孩子?难道我做错了什么?

提前致谢!

4

0 回答 0